Quantcast
Channel: Active questions tagged frames - Stack Overflow
Viewing all articles
Browse latest Browse all 55

Python place in frames

$
0
0

I have been trying to create a 'dice simulator' using Tkinter in python, but when i try to poisition my 'Text' widget inside its Frame, it stays fixed in the top left of the frame. I have tried the grid, move, and place functions but none work. Here is my code:

from tkinter import *from random import *def roll():    txt.delete(0.0, END)    txt.insert(END, str(randint(1,6)))window = Tk()window.title('Dice simulator')canvas = Canvas(window, width=800, height=500, bg='brown')canvas.pack()dice = canvas.create_rectangle(375, 225, 425, 275, fill='white')frame = Frame(canvas, width=25, height=15)window = canvas.create_window(400, 295, window=frame)txtframe = Frame(canvas, width=50, height=50)txtwindow = canvas.create_window(400, 250, window=txtframe, width=49, height=49)txt = Text(txtframe, font=50)                                                                                                                                         button = Button(frame, text='Roll', command=roll)button.pack()txt.pack()

What are your suggestions? Help will be appreciated.

Details given above, not amazing at this website. Just started.


Viewing all articles
Browse latest Browse all 55

Trending Articles