| Ticket UUID: | 58cdb943bed892a646b4c51ce5ef7ad34b42cb19 | |||
| Title: | Internal padding settings of grid geometry manager inside Frame (eg: ipadx and ipady) are not working as explained in TK Documentation. | |||
| Type: | Bug | Version: | 8.6 | |
| Submitter: | oehhar | Created on: | 2023-07-11 06:35:17 | |
| Subsystem: | 49. [grid] | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2023-07-12 07:09:19 | |
| Resolution: | Works For Me | Closed By: | oehhar | |
| Closed on: | 2023-07-12 07:09:19 | |||
| Description: |
(Bug transfered from TCL fossil with reference [https://core.tcl-lang.org/tcl/info/5510bec04291c0ee]) Demonstration program to recreate the bug: from tkinter import * from tkinter import ttk root=Tk() # New window is created. frame1=ttk.Frame(root,relief='sunken',borderwidth=5) # First Frame is been defined. frame1.grid(column=0,row=0,padx=10,pady=10) # Outer padding(padx and pady) is given to First Frame. btn1=ttk.Button(frame1,text='Button1') # Button1, which is use as an slave widget of Frame1, is been defined. btn1.grid() # Button1 is created. frame2=ttk.Frame(root,relief='sunken',borderwidth=5) # Second Frame is been defined. frame2.grid(column=1,row=0,ipadx=10,ipady=10) # Internal padding(ipadx and ipady) is given to Second Frame. btn2=ttk.Button(frame2,text='Button2') # Button2, which is use as an slave widget of Frame2, is been defined. btn2.grid() # Button2 is created. root.mainloop() The above code demonstrate the bug discuss in this bug report. Problem: Internal padding for grid layout inside Frame widget is not working as per Grid reference manual (accessible at : https://tcl.tk/man/tcl8.6/TkCmd/grid.htm). In this reference manual internal padding attribute(ipadx and ipady) are explained as below: -ipadx amount: "The amount specifies how much horizontal internal padding to leave on each side of the content. This is space is added inside the content border. The amount must be a valid screen distance, such as 2 or .5c. It defaults to 0." -ipady amount: "The amount specifies how much vertical internal padding to leave on the top and bottom of the content. This space is added inside the content border. The amount defaults to 0." In above explanation it is clearly mentioned that internal padding is LEAVE ON EACH SIDE OF THE CONTENT. -But as we can see in the demonstrated window generated using our demonstrated program the padding between borders of frame2 and btn2 are not equal on each side. There is no padding between frame2's top border and btn2's top border as well as frame2's left border and btn2's left border. Furthermore, the padding expected on the left side and top side are being added to the right side and bottom side respectively. This behavior is not as per explained in the reference manual. -The external padding (using: padx,pady) is working perfectly as explained in reference manual but internal padding (using: ipadx,ipady) is not working as explained in reference manual. CONCUSSION: THE INTERNAL PADDING MUST BE EQUAL ON EACH SIDE. | |||
| User Comments: |
oehhar added on 2023-07-12 06:28:40:
Thanks, Francois, for the explanation. You learn each day. I was sure, it was something like that. My personal way to solve this issue is to use only -padx/y. So, the example may be solved by adding -padx/y to the button instead of -ipadx/y to the frame: package require Tk; # New window is created. ttk::frame .frame1 -relief sunken -borderwidth 5; # First Frame is been defined. grid .frame1 -column 0 -row 0 -padx 10 -pady 10; # Outer padding(padx and pady) is given to First Frame. ttk::button .frame1.btn1 -text Button1; # Button1, which is use as an slave widget of Frame1, is been defined. grid .frame1.btn1; # Button1 is created. ttk::frame .frame2 -relief sunken -borderwidth 5; # Second Frame is been defined. grid .frame2 -column 1 -row 0; # Internal padding(ipadx and ipady) is given to Second Frame. ttk::button .frame2.btn2 -text Button2; # Button2, which is use as an slave widget of Frame2, is been defined. grid .frame2.btn2 -padx 10 -pady 10; # Button2 is created. I personally never used-ipadx/y in now 30 years of Tk use. I made experiments at the beginning and it did not work out. The ticket author may propose a better wording for the description of -padx/y on the man page: https://www.tcl-lang.org/man/tcl8.6/TkCmd/grid.htm#M13 Thank you all, Harald fvogel added on 2023-07-11 23:05:12: I don't think there is a bug. Difference between -padx and -ipadx is subtle, as explained in TkDocs. Please read this page, it provides a lot of valuable insights. You seem to expect to see Button2 to be centered inside .frame2 but this is not what you specify using -ipadx/y. I readily admit it's not easy to grasp. oehhar added on 2023-07-11 12:03:41: I can confirm that I see the issue on Tk 8.6.13 on Windows. I am not an expert on this, but it feels like a bug on a first sigh. My screen-shot is attached. chrstphrchvz added on 2023-07-11 07:22:50: This looks related to https://github.com/python/cpython/issues/103862 Tcl syntax equivalent: package require Tk; # New window is created. | |||
Attachments:
- screenshot_wish8_6_13_windows.png [download] added by oehhar on 2023-07-11 12:04:27. [details]
