From tkinter import *
From idlelib. tabbedpages import *
Class mainframe (FRAME ):
Def _ init _ (self, Master = none, CNF = {}, ** kW ):
Self. Master = Master
Super (mainframe, self). _ init _ (self. Master, CNF)
# Create a menu
Self. mmenu = menu (Root)
Self. master. config (menu = self. mmenu)
Self. master. rowconfigure (0, Weight = 1)
Self. master. columnconfigure (0, Weight = 1)
Self. Grid (sticky = W + E + N + S)
Self. bottomlabel = label (self. Master, text = 'top', width = 1, BG = 'blue ')
Self. bottomlabel. Pack (side = Top, expand = No, fill = X)
Self. bottomlabel = label (self. Master, text = 'bottom ', width = 1, BG = 'blue ')
Self. bottomlabel. Pack (side = bottom, expand = No, fill = X)
Self. leftcanv = canvas (self. Master, BG = 'blue', width = 175, Height = 30)
Self. leftcanv. Pack (side = left, expand = No, fill = y) # padx = 10, pady = 5, ipadx = 5, ipady = 5,
# Self. leftcanv. Grid (ROW = 0, column = 0, sticky = W + E + N + S)
# Self. tabpage = tabbedpageset (self. Master, page_names = ['foobar', 'baz'], n_rows = 0,
# Expand_tabs = false #, width = 175, Height = 30
#)
# Self. tabpage. Pack (side = left, expand = No, fill = both)
Self. midlabel = label (self. Master, text = '', width = 0, cursor = 'SB _ h_double_arrow ')
Self. midlabel. Pack (side = left, expand = No, fill = y)
Self. midlabel. BIND ("<B1-Motion>", self. setleftcanvsize)
Self. rightcanv = canvas (self. Master, BG = 'pink ')
Self. rightcanv. Pack (side = right, expand = Yes, fill = both)
Obj1 = self. rightcanv. create_text (50, 30, text = 'click me one ')
# Self. rightcanv. Grid (ROW = 0, column = 1, sticky = W + E + N + S)
Self. addmenu ()
Def addmenu (Self ):
Filemenu = menu (self. mmenu)
Filemenu. add_command (Label = "new", command = self. Quit)
Filemenu. add_command (Label = "open...", command = self. Quit)
Filemenu. add_separator ()
Filemenu. add_command (Label = "exit", command = self. Quit)
Self. mmenu. add_cascade (Label = "file", menu = filemenu)
Configmenu = menu (self. mmenu)
Configmenu. add_command (Label = "My Settings", command = self. Quit)
Self. mmenu. add_cascade (Label = "set", menu = configmenu)
Def setleftcanvsize (self, event ):
Self. leftcanv. config (width = self. leftcanv. winfo_width () + event. x-7)
# Self. tabpage. config (width = self. tabpage. winfo_width () + event. x-7)
Def _ del _ (Self ):
Print ('logout ')
If _ name __= = '_ main __':
Root = TK ()
Mf = mainframe (root, width = 800, Height = 600)
Mf. Pack ()
Root. mainloop ()