I want to create a visualised card game. I want to make a system where tkinter would show me a picture but the picture name is made of to other variables. tkinter will let me add only one value but I want to add two walues.
raam=Tk()
raam.title("joonistus")
tahvel=Canvas(raam, width=1900, height=1000, background="black")
tahvel.grid()
kaart=[["poti","ruutu","risti","ärtu"],["kaks","kolm","neli","viis","kuus","seitse","kaheksa","üheksa","kümme","poiss","emand","kuningas","äss"]]
#in the finished game I would have more of these pictures imported
poti kaks= PhotoImage(file="doesn't_matter.gif")
tahvel.create_image(20,950, anchor=SW, image=kaart[0][0], kaart[1][0])
I know that I can also use other libraries but I want to try make this game using only tkinter.
Thank you for your support!
Related
Iv'e tried a bunch of random things. I know I'm supposed to be specific when explaining this but I don't really know what to say. I made a scrollbar in a def function, it was in a whole new screen and I added it to a text box. So I'm wondering if I can just add my main scrollbar to the frame/screen in my main window. My previous scrollbar is in the recipe_steps function.
How do I make a step-by-step GUI Layout with Tkinter Python 3.7? What I mean is that I want to have the user enter some information, press the "NEXT" button and enter some more information, etc. I don't think there's really a feasible way to completely change the layout like this with Tkinter, so I'm hoping there's something I'm missing. How do I do this?
I don't think there's really a feasible way to completely change the layout like this with Tkinter,
That is incorrect. This is trivially easy with Tkinter. Create a function or class for each step. All of the widgets for that step should be inside a single frame.
You then just need to call the first function or class to create the frame. When the user clicks "next", destroy the frame and create the next frame. And so on.
I am currently working on a project to play videos in Tkinter. I have set the code to run through a loop and play each frame (so it would be a bit like a gif) but the code doesn't seem to play the loop, it just displays the first image. What am I doing wrong? Here is the code:
from tkinter import*
root=Tk()
root.geometry=('400x400')
loop=1
while loop>0:
if loop<240:
filepath="Frames\Frame_Layer_"+str(loop)+".png"
imageback=PhotoImage(file=filepath)
button1=Button(root, image=imageback).pack()
loop=loop+1
else:
loop=1
root.mainloop()
When I run the code it comes up with a message saying too early to create image???
Any help would be much appreciated. Thanks in advance,
Mitra0000
I am writing a simple menu-based RPG (combat is turn-based and such), but I have realized I had better organize all of my widgets before I actually start implementing the GUI. My application "changes windows" by lifting frames containing widgets or other frames (or both). Is there a commonly-used or suggested method or organization program to help me keep track of everything neatly before I start?
Thanks.
If you want to say do health as a number like 0/1 then you could do this line of code for a label.
new_label = tkinter.Label(window, text="Health: %s/%s" % current_health, max_health,bg="green")
new_label.pack(side=tkinter.LEFT)
that would assign variables to your label for may health and current health and display it on the left of your screen. Also it will have a green background ofr the label but that can be changed. Really that is basic gui in a tkinter application hope this helped.
Here's the deal. I'm trying to write an arkanoid clone game and the thing is that I need a window menu like you get in pyGTK. For example File->(Open/Save/Exit) .. something like that and opening an "about" context where the author should be written.
I'm already using pyGame for writting the game logic. I've tried pgu to write the GUI but that doesn't help me, altough it has those menu elements I'm taking about, you can't include the screen of the game in it's container.
Does anybody know how to include such window menus with the usage of pyGame ?
wxPython allows you to integrate a Pygame window inside of a "normal" wxPython window - check out their wiki entry for how to do it. This should allow you to have a normal window (with File/Help/etc.) menus, but have a Pygame surface to which you can draw for your game.