Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python tkinter grid

# import tkinter module
from tkinter import * from tkinter.ttk import *
  
# creating main tkinter window/toplevel
master = Tk()
  
# this will create a label widget
l1 = Label(master, text = "Height")
l2 = Label(master, text = "Width")
  
# grid method to arrange labels in respective
# rows and columns as specified
l1.grid(row = 0, column = 0, sticky = W, pady = 2)
l2.grid(row = 1, column = 0, sticky = W, pady = 2)
  
# entry widgets, used to take entry from user
e1 = Entry(master)
e2 = Entry(master)
  
# this will arrange entry widgets
e1.grid(row = 0, column = 1, pady = 2)
e2.grid(row = 1, column = 1, pady = 2)
  
# checkbutton widget
c1 = Checkbutton(master, text = "Preserve")
c1.grid(row = 2, column = 0, sticky = W, columnspan = 2)
  
# adding image (remember image should be PNG and not JPG)
img = PhotoImage(file = r"C:UsersAdminPicturescapture1.png")
img1 = img.subsample(2, 2)
  
# setting image with the help of label
Label(master, image = img1).grid(row = 0, column = 2,
       columnspan = 2, rowspan = 2, padx = 5, pady = 5)
  
# button widget
b1 = Button(master, text = "Zoom in")
b2 = Button(master, text = "Zoom out")
  
# arranging button widgets
b1.grid(row = 2, column = 2, sticky = E)
b2.grid(row = 2, column = 3, sticky = E)
  
# infinite loop which can be terminated 
# by keyboard or mouse interrupt
mainloop()
Comment

tkinter frames and grids

from Tkinter import *

root = Tk()
root.title('Model Definition')
root.resizable(width=FALSE, height=FALSE)
root.geometry('{}x{}'.format(460, 350))

top_frame = Frame(root, bg='cyan', width = 450, height=50, pady=3).grid(row=0, columnspan=3)
Label(top_frame, text = 'Model Dimensions').grid(row = 0, columnspan = 3)
Label(top_frame, text = 'Width:').grid(row = 1, column = 0)
Label(top_frame, text = 'Length:').grid(row = 1, column = 2)
entry_W = Entry(top_frame).grid(row = 1, column = 1)
entry_L = Entry(top_frame).grid(row = 1, column = 3)
#Label(top_frame, text = '').grid(row = 2, column = 2)

center = Frame(root, bg='gray2', width=50, height=40, padx=3, pady=3).grid(row=1, columnspan=3)
ctr_left = Frame(center, bg='blue', width=100, height=190).grid(column = 0, row = 1, rowspan = 2)
ctr_mid = Frame(center, bg='yellow', width=250, height=190, padx=3, pady=3).grid(column = 1, row=1, rowspan=2)
ctr_right = Frame(center, bg='green', width=100, height=190, padx=3, pady=3).grid(column = 2, row=1, rowspan=2)

btm_frame = Frame(root, bg='white', width = 450, height = 45, pady=3).grid(row = 3, columnspan = 3)
btm_frame2 = Frame(root, bg='lavender', width = 450, height = 60, pady=3).grid(row = 4, columnspan = 3)


root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: python create a matrix with one in diagonal 
Python :: sort array python by column 
Python :: python check version 
Python :: python filter a dictionary 
Python :: python selenium get title 
Python :: run sql query on pandas dataframe 
Python :: string to float python pandas 
Python :: how to know where python is installed on windows 
Python :: Python find inverse of matrix 
Python :: multiply column of dataframe by number 
Python :: make longitude -180 to 180 
Python :: python: select specific columns in a data frame 
Python :: youtube-dl python download to specific folder 
Python :: flask debug 
Python :: python boxplot show mean 
Python :: boolean python meaning for idiots 
Python :: dataframe sort by column 
Python :: pandas print full dataframe 
Python :: list of strings to numbers python 
Python :: pandas how to start read csv at a certain row 
Python :: python print to stderr 
Python :: write number of lines in file python 
Python :: python code to open windows command prompt 
Python :: execute python in notepad++ 
Python :: how to change canvas background color in python tkinter 
Python :: check python version conda env 
Python :: mad python 
Python :: author nextcord interactions 
Python :: show battery of my laptop python 
Python :: Creating virtual environments 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =