Python Forum
GUI Tkinter Widget Positions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GUI Tkinter Widget Positions
#1
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
Reply
#2
(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.
Reply
#3
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/...dgets.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() 
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TKinter Widget Attribute and Method Quick Reference zunebuggy 3 861 Oct-15-2023, 05:49 PM
Last Post: zunebuggy
  [Tkinter] Programmatically creating buttons that remember their positions Clunk_Head 6 1,356 Jun-22-2023, 02:51 PM
Last Post: deanhystad
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,915 Jun-26-2022, 06:26 PM
Last Post: menator01
  Tkinter Exit Code based on Entry Widget Nu2Python 6 3,003 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  tkinter text widget word wrap position chrisdb 6 7,583 Mar-18-2021, 03:55 PM
Last Post: chrisdb
  [Tkinter] How to add conversions and fix button positions. javesike1262 7 2,900 Jan-31-2021, 04:39 PM
Last Post: deanhystad
  Tkinter - How can I extend a label widget? TurboC 2 2,799 Oct-13-2020, 12:15 PM
Last Post: zazas321
  [Tkinter] Tkinter custom widget styling and creating custom theme karolp 6 4,854 May-06-2020, 06:11 PM
Last Post: karolp
  Tkinter calendar widget scratchmyhead 4 4,349 May-03-2020, 07:01 PM
Last Post: scratchmyhead
  [PyGUI] Python 3.8.1 Tkinter Widget stete change sasiap 4 2,530 Feb-14-2020, 10:38 AM
Last Post: sasiap

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020