Python Forum
GUI Tkinter Widget Positions - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: GUI Tkinter Widget Positions (/thread-18987.html)



GUI Tkinter Widget Positions - punksnotdead - Jun-09-2019

A colleague has just sent me a GUI that he developed using tkinter. On his Windows10 PC the GUI appears fine - all the button, text, combo widgets appear in their correct positions. However, on my Windows7 Professional PC, the widgets appear squashed up and overlap. Can anyone suggest what the issue might be? (I've tried changing my screen resolution but that makes no difference). Thanks


RE: GUI Tkinter Widget Positions - Yoriz - Jun-09-2019

(Jun-09-2019, 11:19 AM)punksnotdead Wrote: Can anyone suggest what the issue might be?

Not without out seeing the code that creates the GUI, also to recreate what you are seeing someone would also need access to windows 7 and windows 10 to see the difference.


RE: GUI Tkinter Widget Positions - punksnotdead - Jun-12-2019

Here is the code. On my PC running Windows7 Professional the controls overlap. They don't overlap on Windows10

The inconsistency might be related to the following:

https://interactivepython.org/runestone/static/CS152f17/GUIandEventDrivenProgramming/03_widgets.html

import tkinter
from tkinter import ttk
from tkinter import *
from tkinter.ttk import *
from tkinter import messagebox


root = tkinter.Tk()                                                 
root.geometry("470x225")                                            
root.title("My First GUI")                                           

newCanvas = Canvas(root,width=460,height=250)                       
newCanvas.create_line(240,20,240,205,fill="black")


sacol = ttk.Combobox(
    root, values=[1,2,3,4,5],
    state='readonly', width = 2)                                    

sacol.current(0)                                              

sarow = ttk.Combobox(
    root, values=[1,2,3,4,5],
    state='readonly', width = 2)                                   

sarow.current(0)                                            

elementButton = tkinter.Button(root,text = "Calculate", relief=GROOVE)                        
                     

salbl = Label(root,text = "Press 1")               

elbl = Label(root, text = "Press 2")                

sacolTxt = Label(root, text = "Number of aaaaaaaaa columns")  
sarowTxt = Label(root, text = "Number of aaaaaaaaa rows")
sattxt = Label(root, text = "Number of aaaaaaaaa =")
elttxt = Label(root, text = "Number of aaaaaaaa =")

d1Txt = Label(root, text="")
d2Txt = Label(root, text="")


newCanvas.place(x=0,y=0)                                            
sacolTxt.place(x=10,y=10)
sacol.place(x=180,y=10)
sarowTxt.place(x=10,y=35)
sarow.place(x=180,y=35)
sattxt.place(x=10,y=60)
salbl.place(x=143,y=60)
elttxt.place(x=10,y=85)
elbl.place(x=132,y=85)
elementButton.place(x=10,y=110)

d1Txt.place(x=370,y=110)
d2Txt.place(x=370,y=135)

root.mainloop() 



RE: GUI Tkinter Widget Positions - Yoriz - Jun-12-2019

The problem is most likely because the widgets are being placed at co-ordinates.
The widgets are probably different sizes on the different o/s.
If pack or grid is used to place the widgets it will self adjust to their sizes.