Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
PK!}N  matt/pong-demo-1.pynu[from Tkinter import * import string class Pong(Frame): def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) ## The playing field self.draw = Canvas(self, width="5i", height="5i") ## The speed control for the ball self.speed = Scale(self, orient=HORIZONTAL, label="ball speed", from_=-100, to=100) self.speed.pack(side=BOTTOM, fill=X) # The ball self.ball = self.draw.create_oval("0i", "0i", "0.10i", "0.10i", fill="red") self.x = 0.05 self.y = 0.05 self.velocity_x = 0.3 self.velocity_y = 0.5 self.draw.pack(side=LEFT) def moveBall(self, *args): if (self.x > 5.0) or (self.x < 0.0): self.velocity_x = -1.0 * self.velocity_x if (self.y > 5.0) or (self.y < 0.0): self.velocity_y = -1.0 * self.velocity_y deltax = (self.velocity_x * self.speed.get() / 100.0) deltay = (self.velocity_y * self.speed.get() / 100.0) self.x = self.x + deltax self.y = self.y + deltay self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay) self.after(10, self.moveBall) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() self.after(10, self.moveBall) game = Pong() game.mainloop() PK!>;matt/packer-simple.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs|jdGHdS(Ntcommand(thi_there(tself((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pytprintitscCst|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtt|dd |_|jjt|dd |_ |j jdS( NttexttQUITt foregroundtredRtsidetfilltHellosbutton 2sbutton 3( tButtontquitRtpacktLEFTtBOTHRRtguy2tguy3(R((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyt createWidgetss cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyRs N(t__name__t __module__RRtNoneR(((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyRs  N(tTkinterRRttesttmainloop(((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyts  PK!MhΩ matt/canvas-moving-w-mouse.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(cCs|j|_|j|_dS(N(txtlastxtytlasty(tselftevent((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseDown s cCsF|jjt|j|j|j|j|j|_|j|_dS(N(tdrawtmovetCURRENTRRRR(RR((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseMoves* cCs|jjtdddS(Ntfilltred(R t itemconfigR (RR((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseEnterscCs|jjtdddS(NR tblue(R RR (RR((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseLeavesc Cst|ddddd|j|_|jjdtdtt|dd d d |_|jjdt|jjd d d d dd dd}|jj |d|j |jj |d|j t j |jd|jt j |jd|jdS(NttexttQUITt foregroundRtcommandtsideR twidtht5itheightiitgreenttagstselecteds s s<1>s (tButtontquitRtpacktLEFTtBOTHtCanvasR t create_ovalttag_bindRRtWidgettbindRR (Rtfred((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt createWidgets!scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR)(Rtmaster((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyR+1s N( t__name__t __module__RR RRR)tNoneR+(((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyRs     N(tTkinterR*Rttesttmainloop(((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyts 1 PK!~ matt/00-HELLO-WORLD.pynu[from Tkinter import * # note that there is no explicit call to start Tk. # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) # a hello button self.hi_there = Button(self, text='Hello', command=self.printit) self.hi_there.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!)matt/canvas-reading-tag-info.pynu[from Tkinter import * class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.drawing = Canvas(self, width="5i", height="5i") # make a shape pgon = self.drawing.create_polygon( 10, 10, 110, 10, 110, 110, 10 , 110, fill="red", tags=("weee", "foo", "groo")) # this is how you query an object for its attributes # config options FOR CANVAS ITEMS always come back in tuples of length 5. # 0 attribute name # 1 BLANK # 2 BLANK # 3 default value # 4 current value # the blank spots are for consistency with the config command that # is used for widgets. (remember, this is for ITEMS drawn # on a canvas widget, not widgets) option_value = self.drawing.itemconfig(pgon, "stipple") print "pgon's current stipple value is -->", option_value[4], "<--" option_value = self.drawing.itemconfig(pgon, "fill") print "pgon's current fill value is -->", option_value[4], "<--" print " when he is usually colored -->", option_value[3], "<--" ## here we print out all the tags associated with this object option_value = self.drawing.itemconfig(pgon, "tags") print "pgon's tags are", option_value[4] self.drawing.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!f 44#matt/window-creation-w-location.pyonu[ ^c@sYddlTddlZdefdYZdefdYZeZejdS(i(t*Nt QuitButtoncBseZdZRS(cOs\|jdsd|ds   PK!  matt/canvas-gridding.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs8eZdZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pytprintit sc Cs{t|ddddddddd |j|_|jjd td tt|d d dd |_|jjd tdS(NttexttQUITt backgroundtredt foregroundtwhitetheightitcommandtsidetfilltwidtht5i( tButtontquitRtpacktBOTTOMtBOTHtCanvast canvasObjecttLEFT(R((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyt createWidgets scCs@|jj|j|j|_|jj|j|j|_dS(N(Rtcanvasxtxt griddingSizetstartxtcanvasytytstarty(Rtevent((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyt mouseDownscCs|jj|j|j}|jj|j|j}|j|jkr|j|jkr|jj|j |jj |j|j|||_ |j ndS(N( RRRRRRRR tdeletet rubberbandBoxtcreate_rectangletupdate_idletasks(RR!RR((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyt mouseMotions$ cCsotj||tj||jd|_d|_tj |j d|j tj |j d|j dS(Ni2s s( tFramet__init__tPacktconfigRtNoneR$RtWidgettbindRR"R'(Rtmaster((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyR),s    N(t__name__t __module__RRR"R'R,R)(((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyRs    N(tTkinterR(Rttesttmainloop(((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyts 3 PK!kmatt/dialog-box.pyonu[ ^c@sGddlTddlmZdefdYZeZejdS(i(t*(tDialogtTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pytprintitsc Cs1t|ddddddddd d }|jS( sCreate a top-level dialog with some buttons. This uses the Dialog class, which is a wrapper around the Tcl/Tk tk_dialog script. The function returns 0 if the user clicks 'yes' or 1 if the user clicks 'no'. ttitlesfred the dialog boxttextsclick on a choicetbitmaptinfotdefaultitstringstyestno(R R (Rtnum(Rtd((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyt makeWindow s cCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NRtQUITt foregroundtredtcommandtsidetfillsMake a New Window(tButtontquitRtpacktLEFTtBOTHRthi_there(R((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyt createWidgets.s cCs4tj||tj|d|_|jdS(Ni(tFramet__init__tPacktconfigt windownumR(Rtmaster((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyR9s  N(t__name__t __module__RRRtNoneR(((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyRs  # N(tTkinterRRRttesttmainloop(((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyts 8 PK!a>oQ"matt/animation-w-velocity-ctrl.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pytprintit sc Cst|ddddd|j|_|jjdtdtt|dd d d |_t|d t d d dd|_ |j jdtdt |jj dddddddd|jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheighttorienttfrom_ittoidii ttagstthingtblue(tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawtScalet HORIZONTALtspeedtXtcreate_rectangletLEFT(R((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyt createWidgets s!%cGsY|jj}t|d}d|f}|jjd|||jd|jdS(Ng@@s%riRi (RtgettfloatRtmovetaftert moveThing(Rtargstvelocitytstr((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyR's  cCs>tj||tj||j|jd|jdS(Ni (tFramet__init__tPacktconfigR"R&R'(Rtmaster((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyR,#s  N(t__name__t __module__RR"R'tNoneR,(((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyR s   N(tTkinterR+Rttesttmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyts ! PK!]!matt/animation-w-velocity-ctrl.pynu[from Tkinter import * # this is the same as simple-demo-1.py, but uses # subclassing. # note that there is no explicit call to start Tk. # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100) self.speed.pack(side=BOTTOM, fill=X) # all of these work.. self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") self.draw.pack(side=LEFT) def moveThing(self, *args): velocity = self.speed.get() str = float(velocity) / 1000.0 str = "%ri" % (str,) self.draw.move("thing", str, str) self.after(10, self.moveThing) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() self.after(10, self.moveThing) test = Test() test.mainloop() PK!Vkk"matt/menu-all-types-of-entries.pycnu[ ^c@sddlTdZdZdZdadZdZdZd Zd Z d Z e Z e e d ed dZejdeeZeZeZe Ze Zejeeeeee jde jde jdS(i(t*cCs dGHdS(Nsopening new file((((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytnew_file%scCs dGHdS(Nsopening OLD file((((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pyt open_file(scCs dGHdS(Nspicked a menu item((((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytprint_something+sicCst adGtGHdS(Ns anchovies?(t anchovies(((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytprint_anchovies2sc Cs+ttdddd}|jdtddt||_|jjdd |jjdd t|jjdd ddd t |jjdd ddd t |jjddddddd t |jjdd|jj d|jjddddddddd |j |j|d<|S(NttextsSimple Button Commandst underlineitsidetpadxt2mtlabeltUndotstatesNew...tcommandsOpen...sDifferent Fonttfonts&-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*tbitmaptinfot separatortQuitt backgroundtredtactivebackgroundtgreentmenu(t MenubuttontmBartpacktLEFTtMenuRt add_commandt entryconfigtDISABLEDRRRtaddtquit(tCommand_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeCommandMenu7s,    cCsttdddd}|jdtddt||_t|j|j_t|jj|jj_|jjjjdd |jjjjdd |jjjjdd |jjjdd |jjjdd |jjjdd|jjjdd|jjjdd|jjjdd|jjj ddd|jjj|jj ddd|jj|j|d<|S(NRsCascading MenusRiRR R R tavacadosbelgian endivet beefaronit ChocolatetVanillat TuttiFruititWopBopaLoopBapABopBamBooms Rocky Roadt BubbleGums Weird FlavorsRs more choices( RRRRRRtchoicest weirdonesRt add_cascade(tCascade_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeCascadeMenues*  cCsttdddd}|jdtddt||_|jjdd |jjdd |jjdd |jjdd d t|jj|jj d |j|d<|S(NRsCheckbutton MenusRiRR R R t PepperonitSausages Extra CheesetAnchovyRR( RRRRRRtadd_checkbuttonRtinvoketindex(tCheckbutton_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeCheckbuttonMenus  cCs ttdddd}|jdtddt||_|jjdd |jjdd |jjdd |jjdd |jjdd |jjdd|jjdd|jjdd|jjdd|jjdd|j|d<|S(NRsRadiobutton MenusRiRR R R t RepublicantDemocratt LibertariantCommietFacists Labor PartytToriet Independentt Anarchists No OpinionR(RRRRRRtadd_radiobutton(tRadiobutton_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeRadiobuttonMenus   cCs<ttdddd}|jdtddt|d<|S( NRs Dead MenuRiRR R R (RRRRR (t Dummy_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeDisabledMenus trelieft borderwidthitfills menu demoN(tTkinterRRRRRR$R0R8RCREtTktroottFrametRAISEDRRtXR#R/R7RBtNoMenut tk_menuBarttitleticonnametmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pyts, $     . & ,         PK!b*//matt/window-creation-simple.pynu[from Tkinter import * # this shows how to spawn off new windows at a button press class Test(Frame): def printit(self): print "hi" def makeWindow(self): fred = Toplevel() fred.label = Label(fred, text="Here's a new window") fred.label.pack() def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) # a hello button self.hi_there = Button(self, text='Make a New Window', command=self.makeWindow) self.hi_there.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!;U<"matt/subclass-existing-widgets.pyonu[ ^c@sJddlTdefdYZdZeZeeejdS(i(t*t New_ButtoncBseZdZRS(cCs|jGH|jd|_dS(Ni(tcounter(tself((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pytcallbacks(t__name__t __module__R(((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pyRscCst|}|jt|ddddd|j|_|jjdtdtt|dd|_|jj d|jj |jjdtd |j_ dS( NttexttQUITt foregroundtredtcommandtsidetfilltHelloi+( tFrametpacktButtontquitRtLEFTtBOTHRthi_theretconfigRR(ttoptf((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pyt createWidgets s  $N(tTkinterRRRtTktroottmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pyts    PK!br; ; matt/canvas-with-scrollbars.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pytprintit sc Cst|dd|_|jjt|ddddddd|j|_|jjd td tt|dd }|jd tt |d d dd dddd|_ t |dt |j _ t |dt|j _|j j j|j d<|j jj|j d<|j j|j j d<|j j|j jd<|j jddddd d|j jddddd d|j j jd td t|j jjd td t|j jd tdS(NttextsCan Find The BLUE Square??????tQUITt backgroundtredtheightitcommandtsidetfills0.25itwidtht5itwhitet scrollregionit20itorienttxscrollcommandtyscrollcommands3.5itblackt10is13.5itblue(iiRR(tLabeltquestiontpacktButtontquitRtBOTTOMtBOTHtFrametCanvastdrawt Scrollbart HORIZONTALtscrollXtVERTICALtscrollYtsettxviewtyviewtcreate_rectangletXtRIGHTtYtLEFT(Rtspacer((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyt createWidgets s*  cGsdG|GH|jjjGHdS(Nt scrolling(R!R$tget(Rtargs((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyt scrollCanvasX0s cCs+tj||tj||jdS(N(Rt__init__tPacktconfigR0(Rtmaster((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyR55s N(t__name__t __module__RR0R4tNoneR5(((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyRs  $ N(tTkinterRRttesttmainloop(((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyts 2 PK!;mDD matt/canvas-reading-tag-info.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pytprintitscCs!t|ddddd|j|_|jjdtdtt|dd d d |_|jjd d d d d d d d ddd d}|jj |d}dG|dGdGH|jj |d}dG|dGdGHdG|dGdGH|jj |d }dG|dGH|jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheighti inttagstweeetfootgrootstipples#pgon's current stipple value is -->is<--s pgon's current fill value is -->s when he is usually colored -->ispgon's tags are(RRR( tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawingtcreate_polygont itemconfigtLEFT(Rtpgont option_value((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyt createWidgetss   cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR (Rtmaster((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyR"*s N(t__name__t __module__RR tNoneR"(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyRs  "N(tTkinterR!Rttesttmainloop(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyts + PK!jHHmatt/radiobutton-simple.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pytprintitsc Csvt|_|jjdt||_|jjt|jddd|jdddt|j_|jjjdt t|jddd|jdd dt|j_ |jj jdt t|jdd d|jdd dt|j_ |jj jdt t |d |j|_ |j jdt t|dd ddd|j|_|jjdtdtdS(Nt chocolatettextsChocolate FlavortvariabletvaluetanchortfillsStrawberry Flavort strawberrys Lemon Flavortlemont textvariabletQUITt foregroundtredtcommandtside(t StringVartflavortsettFramet radioframetpackt RadiobuttontWtchoctXtstrawR tEntrytentrytButtontquitRtBOTTOMtBOTH(R((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyt createWidgetss0  cCs+tj||tj||jdS(N(Rt__init__tPacktconfigR$(Rtmaster((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyR%7s N(t__name__t __module__RR$tNoneR%(((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyR s  &N(tTkinterRRttesttmainloop(((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyts / PK!gmatt/00-HELLO-WORLD.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pytprintitscCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NttexttQUITt foregroundtredtcommandtsidetfilltHello(tButtontquitRtpacktLEFTtBOTHRthi_there(R((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyt createWidgets s cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyRs N(t__name__t __module__RRtNoneR(((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyRs  N(tTkinterRRttesttmainloop(((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyts  PK!ll#matt/packer-and-placer-together.pyonu[ ^c@seddlTdZdZdZeZeeZejdejddej dS(i(t*cCs#tjjd|jd|jdS(Ntxty(tapptbuttontplaceRR(tevent((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pyt do_motionscCs dGHdS(Ns calling me!((((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pytdothis scCst|dddddd}|jdtddt|d d d d d t|_|jjdddddt|jdt |S(Ntwidthitheightt backgroundtgreentfilltexpandit foregroundtredttexttamazingtcommandtrelxg?trelygtanchors( tFrametpacktBOTHtButtonRRRtNWtbindR(ttoptf((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pyt createWidgets s !t400x400iN( tTkinterRRRtTktrootRtgeometrytmaxsizetmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pyts       PK!D66matt/placer-simple.pynu[from Tkinter import * # This is a program that tests the placer geom manager def do_motion(event): app.button.place(x=event.x, y=event.y) def dothis(): print 'calling me!' def createWidgets(top): # make a frame. Note that the widget is 200 x 200 # and the window containing is 400x400. We do this # simply to show that this is possible. The rest of the # area is inaccesssible. f = Frame(top, width=200, height=200, background='green') # place it so the upper left hand corner of # the frame is in the upper left corner of # the parent f.place(relx=0.0, rely=0.0) # now make a button f.button = Button(f, foreground='red', text='amazing', command=dothis) # and place it so that the nw corner is # 1/2 way along the top X edge of its' parent f.button.place(relx=0.5, rely=0.0, anchor=NW) # allow the user to move the button SUIT-style. f.bind('', do_motion) return f root = Tk() app = createWidgets(root) root.geometry("400x400") root.maxsize(1000, 1000) root.mainloop() PK!3(jjmatt/window-creation-simple.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pytprintitscCs/t}t|dd|_|jjdS(NttextsHere's a new window(tTopleveltLabeltlabeltpack(Rtfred((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyt makeWindow s cCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NRtQUITt foregroundtredtcommandtsidetfillsMake a New Window(tButtontquitR R tLEFTtBOTHR thi_there(R((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyt createWidgetss cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyRs N(t__name__t __module__RR RtNoneR(((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyRs   N(tTkinterRRttesttmainloop(((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyts  PK!*hh#matt/entry-with-shared-variable.pycnu[ ^c@sSddlTddlZdefdYZeZejjdejdS(i(t*NtAppcBs&eZddZdZdZRS(cCstj|||jt||_|jjt|ddd|j|_|jjt|_ |j j d|jj d|j |jj d|j dS(NttextsUppercase The Entrytcommandsthis is a variablet textvariables (tFramet__init__tpacktEntryt entrythingytButtontuppertbuttont StringVartcontentstsettconfigtbindtprint_contents(tselftmaster((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyRs    cCs,tj|jj}|jj|dS(N(tstringR RtgetR(Rtstr((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyR scCsdG|jjGHdS(Ns"hi. contents of entry is now ---->(RR(Rtevent((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyR)sN(t__name__t __module__tNoneRR R(((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyRs  tFoo(tTkinterRRRtrootRttitletmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyts  & PK!X "matt/packer-and-placer-together.pynu[from Tkinter import * # This is a program that tests the placer geom manager in conjunction with # the packer. The background (green) is packed, while the widget inside is placed def do_motion(event): app.button.place(x=event.x, y=event.y) def dothis(): print 'calling me!' def createWidgets(top): # make a frame. Note that the widget is 200 x 200 # and the window containing is 400x400. We do this # simply to show that this is possible. The rest of the # area is inaccesssible. f = Frame(top, width=200, height=200, background='green') # note that we use a different manager here. # This way, the top level frame widget resizes when the # application window does. f.pack(fill=BOTH, expand=1) # now make a button f.button = Button(f, foreground='red', text='amazing', command=dothis) # and place it so that the nw corner is # 1/2 way along the top X edge of its' parent f.button.place(relx=0.5, rely=0.0, anchor=NW) # allow the user to move the button SUIT-style. f.bind('', do_motion) return f root = Tk() app = createWidgets(root) root.geometry("400x400") root.maxsize(1000, 1000) root.mainloop() PK!*hh#matt/entry-with-shared-variable.pyonu[ ^c@sSddlTddlZdefdYZeZejjdejdS(i(t*NtAppcBs&eZddZdZdZRS(cCstj|||jt||_|jjt|ddd|j|_|jjt|_ |j j d|jj d|j |jj d|j dS(NttextsUppercase The Entrytcommandsthis is a variablet textvariables (tFramet__init__tpacktEntryt entrythingytButtontuppertbuttont StringVartcontentstsettconfigtbindtprint_contents(tselftmaster((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyRs    cCs,tj|jj}|jj|dS(N(tstringR RtgetR(Rtstr((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyR scCsdG|jjGHdS(Ns"hi. contents of entry is now ---->(RR(Rtevent((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyR)sN(t__name__t __module__tNoneRR R(((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyRs  tFoo(tTkinterRRRtrootRttitletmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/entry-with-shared-variable.pyts  & PK!t44matt/entry-simple.pyonu[ ^c@sSddlTddlZdefdYZeZejjdejdS(i(t*NtAppcBseZddZdZRS(cCsMtj|||jt|_|jj|jjd|jdS(Ns (tFramet__init__tpacktEntryt entrythingytbindtprint_contents(tselftmaster((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyRs    cCsdG|jjGHdS(Ns"hi. contents of entry is now ---->(Rtget(R tevent((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyRsN(t__name__t __module__tNoneRR(((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyRs tFoo(tTkintertstringRRtrootR ttitletmainloop(((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyts   PK!ZZmatt/window-creation-more.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pytprintitscCsOt}t|dd|jd|j|_|jj|jd|_dS(NttextsThis is window number %d.tcommandi(tTopleveltButtont windownumt makeWindowtlabeltpack(Rtfred((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyR s     cCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NRtQUITt foregroundtredRtsidetfillsMake a New Window(RtquitRR tLEFTtBOTHR thi_there(R((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyt createWidgetss cCs4tj||tj|d|_|jdS(Ni(tFramet__init__tPacktconfigR R(Rtmaster((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyRs  N(t__name__t __module__RR RtNoneR(((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyRs   N(tTkinterRRttesttmainloop(((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyts  PK!gmatt/00-HELLO-WORLD.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pytprintitscCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NttexttQUITt foregroundtredtcommandtsidetfilltHello(tButtontquitRtpacktLEFTtBOTHRthi_there(R((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyt createWidgets s cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyRs N(t__name__t __module__RRtNoneR(((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyRs  N(tTkinterRRttesttmainloop(((s8/usr/lib64/python2.7/Demo/tkinter/matt/00-HELLO-WORLD.pyts  PK!3--"matt/window-creation-w-location.pynu[from Tkinter import * import sys ##sys.path.append("/users/mjc4y/projects/python/tkinter/utils") ##from TkinterUtils import * # this shows how to create a new window with a button in it that # can create new windows class QuitButton(Button): def __init__(self, master, *args, **kwargs): if not kwargs.has_key("text"): kwargs["text"] = "QUIT" if not kwargs.has_key("command"): kwargs["command"] = master.quit apply(Button.__init__, (self, master) + args, kwargs) class Test(Frame): def makeWindow(self, *args): fred = Toplevel() fred.label = Canvas (fred, width="2i", height="2i") fred.label.create_line("0", "0", "2i", "2i") fred.label.create_line("0", "2i", "2i", "0") fred.label.pack() ##centerWindow(fred, self.master) def createWidgets(self): self.QUIT = QuitButton(self) self.QUIT.pack(side=LEFT, fill=BOTH) self.makeWindow = Button(self, text='Make a New Window', width=50, height=20, command=self.makeWindow) self.makeWindow.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!P6matt/slider-demo-1.pynu[from Tkinter import * # shows how to make a slider, set and get its value under program control class Test(Frame): def print_value(self, val): print "slider now at", val def reset(self): self.slider.set(0) def createWidgets(self): self.slider = Scale(self, from_=0, to=100, orient=HORIZONTAL, length="3i", label="happy slider", command=self.print_value) self.reset = Button(self, text='reset slider', command=self.reset) self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.slider.pack(side=LEFT) self.reset.pack(side=LEFT) self.QUIT.pack(side=LEFT, fill=BOTH) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!Vkk"matt/menu-all-types-of-entries.pyonu[ ^c@sddlTdZdZdZdadZdZdZd Zd Z d Z e Z e e d ed dZejdeeZeZeZe Ze Zejeeeeee jde jde jdS(i(t*cCs dGHdS(Nsopening new file((((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytnew_file%scCs dGHdS(Nsopening OLD file((((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pyt open_file(scCs dGHdS(Nspicked a menu item((((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytprint_something+sicCst adGtGHdS(Ns anchovies?(t anchovies(((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytprint_anchovies2sc Cs+ttdddd}|jdtddt||_|jjdd |jjdd t|jjdd ddd t |jjdd ddd t |jjddddddd t |jjdd|jj d|jjddddddddd |j |j|d<|S(NttextsSimple Button Commandst underlineitsidetpadxt2mtlabeltUndotstatesNew...tcommandsOpen...sDifferent Fonttfonts&-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*tbitmaptinfot separatortQuitt backgroundtredtactivebackgroundtgreentmenu(t MenubuttontmBartpacktLEFTtMenuRt add_commandt entryconfigtDISABLEDRRRtaddtquit(tCommand_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeCommandMenu7s,    cCsttdddd}|jdtddt||_t|j|j_t|jj|jj_|jjjjdd |jjjjdd |jjjjdd |jjjdd |jjjdd |jjjdd|jjjdd|jjjdd|jjjdd|jjj ddd|jjj|jj ddd|jj|j|d<|S(NRsCascading MenusRiRR R R tavacadosbelgian endivet beefaronit ChocolatetVanillat TuttiFruititWopBopaLoopBapABopBamBooms Rocky Roadt BubbleGums Weird FlavorsRs more choices( RRRRRRtchoicest weirdonesRt add_cascade(tCascade_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeCascadeMenues*  cCsttdddd}|jdtddt||_|jjdd |jjdd |jjdd |jjdd d t|jj|jj d |j|d<|S(NRsCheckbutton MenusRiRR R R t PepperonitSausages Extra CheesetAnchovyRR( RRRRRRtadd_checkbuttonRtinvoketindex(tCheckbutton_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeCheckbuttonMenus  cCs ttdddd}|jdtddt||_|jjdd |jjdd |jjdd |jjdd |jjdd |jjdd|jjdd|jjdd|jjdd|jjdd|j|d<|S(NRsRadiobutton MenusRiRR R R t RepublicantDemocratt LibertariantCommietFacists Labor PartytToriet Independentt Anarchists No OpinionR(RRRRRRtadd_radiobutton(tRadiobutton_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeRadiobuttonMenus   cCs<ttdddd}|jdtddt|d<|S( NRs Dead MenuRiRR R R (RRRRR (t Dummy_button((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pytmakeDisabledMenus trelieft borderwidthitfills menu demoN(tTkinterRRRRRR$R0R8RCREtTktroottFrametRAISEDRRtXR#R/R7RBtNoMenut tk_menuBarttitleticonnametmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/menu-all-types-of-entries.pyts, $     . & ,         PK!w matt/bind-w-mult-calls-p-type.pynu[from Tkinter import * import string # This program shows how to use a simple type-in box class App(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.entrythingy = Entry() self.entrythingy.pack() # and here we get a callback when the user hits return. we could # make the key that triggers the callback anything we wanted to. # other typical options might be or (for anything) self.entrythingy.bind('', self.print_contents) # Note that here is where we bind a completely different callback to # the same event. We pass "+" here to indicate that we wish to ADD # this callback to the list associated with this event type. # Not specifying "+" would simply override whatever callback was # defined on this event. self.entrythingy.bind('', self.print_something_else, "+") def print_contents(self, event): print "hi. contents of entry is now ---->", self.entrythingy.get() def print_something_else(self, event): print "hi. Now doing something completely different" root = App() root.master.title("Foo") root.mainloop() # secret tip for experts: if you pass *any* non-false value as # the third parameter to bind(), Tkinter.py will accumulate # callbacks instead of overwriting. I use "+" here because that's # the Tk notation for getting this sort of behavior. The perfect GUI # interface would use a less obscure notation. PK!Fֳ matt/menu-simple.pynu[from Tkinter import * # some vocabulary to keep from getting confused. This terminology # is something I cooked up for this file, but follows the man pages # pretty closely # # # # This is a MENUBUTTON # V # +-------------+ # | | # # +------------++------------++------------+ # | || || | # | File || Edit || Options | <-------- the MENUBAR # | || || | # +------------++------------++------------+ # | New... | # | Open... | # | Print | # | | <------ This is a MENU. The lines of text in the menu are # | | MENU ENTRIES # | +---------------+ # | Open Files > | file1 | # | | file2 | # | | another file | <------ this cascading part is also a MENU # +----------------| | # | | # | | # | | # +---------------+ def new_file(): print "opening new file" def open_file(): print "opening OLD file" def makeFileMenu(): # make menu button : "File" File_button = Menubutton(mBar, text='File', underline=0) File_button.pack(side=LEFT, padx="1m") File_button.menu = Menu(File_button) # add an item. The first param is a menu entry type, # must be one of: "cascade", "checkbutton", "command", "radiobutton", "separator" # see menu-demo-2.py for examples of use File_button.menu.add_command(label='New...', underline=0, command=new_file) File_button.menu.add_command(label='Open...', underline=0, command=open_file) File_button.menu.add_command(label='Quit', underline=0, command='exit') # set up a pointer from the file menubutton back to the file menu File_button['menu'] = File_button.menu return File_button def makeEditMenu(): Edit_button = Menubutton(mBar, text='Edit', underline=0) Edit_button.pack(side=LEFT, padx="1m") Edit_button.menu = Menu(Edit_button) # just to be cute, let's disable the undo option: Edit_button.menu.add('command', label="Undo") # Since the tear-off bar is the 0th entry, # undo is the 1st entry... Edit_button.menu.entryconfig(1, state=DISABLED) # and these are just for show. No "command" callbacks attached. Edit_button.menu.add_command(label="Cut") Edit_button.menu.add_command(label="Copy") Edit_button.menu.add_command(label="Paste") # set up a pointer from the file menubutton back to the file menu Edit_button['menu'] = Edit_button.menu return Edit_button ################################################# #### Main starts here ... root = Tk() # make a menu bar mBar = Frame(root, relief=RAISED, borderwidth=2) mBar.pack(fill=X) File_button = makeFileMenu() Edit_button = makeEditMenu() # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(File_button, Edit_button) root.title('menu demo') root.iconname('packer') root.mainloop() PK!F77#matt/not-what-you-might-think-2.pycnu[ ^c@sWddlTdefdYZeZejjdejjdejdS(i(t*tTestcBseZdZddZRS(cCst|dddddd|_|jjd|jjdtt|jdd d d d |j|j_|jjjdtdS( Ntwidtht1itheightt backgroundtgreenitsidettexttQUITt foregroundtredtcommand(tFrametGpanelt propagatetpacktLEFTtButtontquitR (tself((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyt createWidgetss cCs+tj||tj||jdS(N(R t__init__tPacktconfigR(Rtmaster((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyRs N(t__name__t __module__RtNoneR(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyRs s packer demotpackerN(tTkinterR RttestRttitleticonnametmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyts  PK!ll#matt/packer-and-placer-together.pycnu[ ^c@seddlTdZdZdZeZeeZejdejddej dS(i(t*cCs#tjjd|jd|jdS(Ntxty(tapptbuttontplaceRR(tevent((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pyt do_motionscCs dGHdS(Ns calling me!((((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pytdothis scCst|dddddd}|jdtddt|d d d d d t|_|jjdddddt|jdt |S(Ntwidthitheightt backgroundtgreentfilltexpandit foregroundtredttexttamazingtcommandtrelxg?trelygtanchors( tFrametpacktBOTHtButtonRRRtNWtbindR(ttoptf((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pyt createWidgets s !t400x400iN( tTkinterRRRtTktrootRtgeometrytmaxsizetmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/packer-and-placer-together.pyts       PK!>;matt/packer-simple.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs|jdGHdS(Ntcommand(thi_there(tself((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pytprintitscCst|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtt|dd |_|jjt|dd |_ |j jdS( NttexttQUITt foregroundtredRtsidetfilltHellosbutton 2sbutton 3( tButtontquitRtpacktLEFTtBOTHRRtguy2tguy3(R((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyt createWidgetss cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyRs N(t__name__t __module__RRtNoneR(((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyRs  N(tTkinterRRttesttmainloop(((s7/usr/lib64/python2.7/Demo/tkinter/matt/packer-simple.pyts  PK! yy!matt/bind-w-mult-calls-p-type.pyonu[ ^c@sSddlTddlZdefdYZeZejjdejdS(i(t*NtAppcBs&eZddZdZdZRS(cCsftj|||jt|_|jj|jjd|j|jjd|jddS(Ns t+(tFramet__init__tpacktEntryt entrythingytbindtprint_contentstprint_something_else(tselftmaster((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyRs    cCsdG|jjGHdS(Ns"hi. contents of entry is now ---->(Rtget(R tevent((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyR scCs dGHdS(Ns,hi. Now doing something completely different((R R((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyR sN(t__name__t __module__tNoneRR R (((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyRs  tFoo(tTkintertstringRRtrootR ttitletmainloop(((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyts   PK!ʥE"matt/not-what-you-might-think-1.pynu[from Tkinter import * class Test(Frame): def createWidgets(self): self.Gpanel = Frame(self, width='1i', height='1i', background='green') self.Gpanel.pack(side=LEFT) # a QUIT button self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', foreground='red', command=self.quit) self.Gpanel.QUIT.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.master.title('packer demo') test.master.iconname('packer') test.mainloop() PK!v matt/rubber-band-box-demo-1.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pytprintitsc Cs{t|ddddddddd |j|_|jjd td tt|d d dd |_|jjd tdS(NttexttQUITt backgroundtredt foregroundtwhitetheightitcommandtsidetfilltwidtht5i( tButtontquitRtpacktBOTTOMtBOTHtCanvast canvasObjecttLEFT(R((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyt createWidgetsscCs4|jj|j|_|jj|j|_dS(N(Rtcanvasxtxtstartxtcanvasytytstarty(Rtevent((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyt mouseDownscCs|jj|j}|jj|j}|j|jkr|j|jkr|jj|j|jj |j|j|||_|j ndS(N( RRRRRRRtdeletet rubberbandBoxtcreate_rectangletupdate_idletasks(RR RR((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyt mouseMotions$ cCs|jj|jdS(N(RR"R#(RR ((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pytmouseUp'scCstj||tj||jd|_tj|j d|j tj|j d|j tj|j d|j dS(Ns ss( tFramet__init__tPacktconfigRtNoneR#tWidgettbindRR!R&R'(Rtmaster((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyR)*s   N( t__name__t __module__RRR!R&R'R,R)(((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyRs     N(tTkinterR(Rttesttmainloop(((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyts 5 PK!! matt/READMEnu[This directory contains some ad-hoc examples of Tkinter widget creation. The files named *-simple.py are the ones to start with if you're looking for a bare-bones usage of a widget. The other files are meant to show common usage patters that are a tad more involved. If you have a suggestion for an example program, please send mail to conway@virginia.edu and I'll include it. matt TODO ------- The X selection Dialog Boxes More canvas examples Message widgets Text Editors Scrollbars Listboxes PK!e̍matt/canvas-demo-simple.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pytprintitscCst|ddddd|j|_|jjdtdtt|dd d d |_|jjd d d d dd |jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheightit3itblack( tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawtcreate_rectangletLEFT(R((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyt createWidgets s cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyRs N(t__name__t __module__RRtNoneR(((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyRs  N(tTkinterRRttesttmainloop(((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyts  PK!a>oQ"matt/animation-w-velocity-ctrl.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pytprintit sc Cst|ddddd|j|_|jjdtdtt|dd d d |_t|d t d d dd|_ |j jdtdt |jj dddddddd|jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheighttorienttfrom_ittoidii ttagstthingtblue(tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawtScalet HORIZONTALtspeedtXtcreate_rectangletLEFT(R((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyt createWidgets s!%cGsY|jj}t|d}d|f}|jjd|||jd|jdS(Ng@@s%riRi (RtgettfloatRtmovetaftert moveThing(Rtargstvelocitytstr((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyR's  cCs>tj||tj||j|jd|jdS(Ni (tFramet__init__tPacktconfigR"R&R'(Rtmaster((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyR,#s  N(t__name__t __module__RR"R'tNoneR,(((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyR s   N(tTkinterR+Rttesttmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/animation-w-velocity-ctrl.pyts ! PK! matt/slider-demo-1.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dG|GHdS(Ns slider now at((tselftval((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyt print_valuescCs|jjddS(Ni(tslidertset(R((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pytreset scCst|dddddtdddd d |j|_t|d d d |j|_t|d d ddd |j|_|jjdt |jjdt |jjdt dt dS(Ntfrom_ittoidtorienttlengtht3itlabels happy slidertcommandttexts reset slidertQUITt foregroundtredtsidetfill( tScalet HORIZONTALRRtButtonRtquitRtpacktLEFTtBOTH(R((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyt createWidgets scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyRs N(t__name__t __module__RRRtNoneR(((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyRs   N(tTkinterRRttesttmainloop(((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyts  PK!Ca33matt/packer-simple.pynu[from Tkinter import * class Test(Frame): def printit(self): print self.hi_there["command"] def createWidgets(self): # a hello button self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) self.hi_there = Button(self, text='Hello', command=self.printit) self.hi_there.pack(side=LEFT) # note how Packer defaults to side=TOP self.guy2 = Button(self, text='button 2') self.guy2.pack() self.guy3 = Button(self, text='button 3') self.guy3.pack() def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!`MY!matt/subclass-existing-widgets.pynu[from Tkinter import * # This is a program that makes a simple two button application class New_Button(Button): def callback(self): print self.counter self.counter = self.counter + 1 def createWidgets(top): f = Frame(top) f.pack() f.QUIT = Button(f, text='QUIT', foreground='red', command=top.quit) f.QUIT.pack(side=LEFT, fill=BOTH) # a hello button f.hi_there = New_Button(f, text='Hello') # we do this on a different line because we need to reference f.hi_there f.hi_there.config(command=f.hi_there.callback) f.hi_there.pack(side=LEFT) f.hi_there.counter = 43 root = Tk() createWidgets(root) root.mainloop() PK!|=4>>matt/canvas-with-scrollbars.pynu[from Tkinter import * # This example program creates a scrolling canvas, and demonstrates # how to tie scrollbars and canvases together. The mechanism # is analogus for listboxes and other widgets with # "xscroll" and "yscroll" configuration options. class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.question = Label(self, text="Can Find The BLUE Square??????") self.question.pack() self.QUIT = Button(self, text='QUIT', background='red', height=3, command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) spacer = Frame(self, height="0.25i") spacer.pack(side=BOTTOM) # notice that the scroll region (20" x 20") is larger than # displayed size of the widget (5" x 5") self.draw = Canvas(self, width="5i", height="5i", background="white", scrollregion=(0, 0, "20i", "20i")) self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL) self.draw.scrollY = Scrollbar(self, orient=VERTICAL) # now tie the three together. This is standard boilerplate text self.draw['xscrollcommand'] = self.draw.scrollX.set self.draw['yscrollcommand'] = self.draw.scrollY.set self.draw.scrollX['command'] = self.draw.xview self.draw.scrollY['command'] = self.draw.yview # draw something. Note that the first square # is visible, but you need to scroll to see the second one. self.draw.create_rectangle(0, 0, "3.5i", "3.5i", fill="black") self.draw.create_rectangle("10i", "10i", "13.5i", "13.5i", fill="blue") # pack 'em up self.draw.scrollX.pack(side=BOTTOM, fill=X) self.draw.scrollY.pack(side=RIGHT, fill=Y) self.draw.pack(side=LEFT) def scrollCanvasX(self, *args): print "scrolling", args print self.draw.scrollX.get() def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!'matt/canvas-gridding.pynu[from Tkinter import * # this is the same as simple-demo-1.py, but uses # subclassing. # note that there is no explicit call to start Tk. # Tkinter is smart enough to start the system if it's not already going. class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', background='red', foreground='white', height=3, command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.canvasObject = Canvas(self, width="5i", height="5i") self.canvasObject.pack(side=LEFT) def mouseDown(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object self.startx = self.canvasObject.canvasx(event.x, self.griddingSize) self.starty = self.canvasObject.canvasy(event.y, self.griddingSize) def mouseMotion(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object x = self.canvasObject.canvasx(event.x, self.griddingSize) y = self.canvasObject.canvasy(event.y, self.griddingSize) if (self.startx != event.x) and (self.starty != event.y) : self.canvasObject.delete(self.rubberbandBox) self.rubberbandBox = self.canvasObject.create_rectangle( self.startx, self.starty, x, y) # this flushes the output, making sure that # the rectangle makes it to the screen # before the next event is handled self.update_idletasks() def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() # this is a "tagOrId" for the rectangle we draw on the canvas self.rubberbandBox = None # this is the size of the gridding squares self.griddingSize = 50 Widget.bind(self.canvasObject, "", self.mouseDown) Widget.bind(self.canvasObject, "", self.mouseMotion) test = Test() test.mainloop() PK!v matt/rubber-band-box-demo-1.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pytprintitsc Cs{t|ddddddddd |j|_|jjd td tt|d d dd |_|jjd tdS(NttexttQUITt backgroundtredt foregroundtwhitetheightitcommandtsidetfilltwidtht5i( tButtontquitRtpacktBOTTOMtBOTHtCanvast canvasObjecttLEFT(R((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyt createWidgetsscCs4|jj|j|_|jj|j|_dS(N(Rtcanvasxtxtstartxtcanvasytytstarty(Rtevent((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyt mouseDownscCs|jj|j}|jj|j}|j|jkr|j|jkr|jj|j|jj |j|j|||_|j ndS(N( RRRRRRRtdeletet rubberbandBoxtcreate_rectangletupdate_idletasks(RR RR((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyt mouseMotions$ cCs|jj|jdS(N(RR"R#(RR ((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pytmouseUp'scCstj||tj||jd|_tj|j d|j tj|j d|j tj|j d|j dS(Ns ss( tFramet__init__tPacktconfigRtNoneR#tWidgettbindRR!R&R'(Rtmaster((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyR)*s   N( t__name__t __module__RRR!R&R'R,R)(((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyRs     N(tTkinterR(Rttesttmainloop(((s@/usr/lib64/python2.7/Demo/tkinter/matt/rubber-band-box-demo-1.pyts 5 PK!;matt/window-creation-more.pynu[from Tkinter import * # this shows how to create a new window with a button in it # that can create new windows class Test(Frame): def printit(self): print "hi" def makeWindow(self): fred = Toplevel() fred.label = Button(fred, text="This is window number %d." % self.windownum, command=self.makeWindow) fred.label.pack() self.windownum = self.windownum + 1 def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) # a hello button self.hi_there = Button(self, text='Make a New Window', command=self.makeWindow) self.hi_there.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.windownum = 0 self.createWidgets() test = Test() test.mainloop() PK!Q.matt/killing-window-w-wm.pynu[from Tkinter import * # This file shows how to trap the killing of a window # when the user uses window manager menus (typ. upper left hand corner # menu in the decoration border). ### ******* this isn't really called -- read the comments def my_delete_callback(): print "whoops -- tried to delete me!" class Test(Frame): def deathHandler(self, event): print self, "is now getting nuked. performing some save here...." def createWidgets(self): # a hello button self.hi_there = Button(self, text='Hello') self.hi_there.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() ### ### PREVENT WM kills from happening ### # the docs would have you do this: # self.master.protocol("WM_DELETE_WINDOW", my_delete_callback) # unfortunately, some window managers will not send this request to a window. # the "protocol" function seems incapable of trapping these "aggressive" window kills. # this line of code catches everything, tho. The window is deleted, but you have a chance # of cleaning up first. self.bind_all("", self.deathHandler) test = Test() test.mainloop() PK!matt/animation-simple.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pytprintitsc Cst|ddddd|j|_|jjdtdtt|dd d d |_|jjd d d d d ddd|jjdtdS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheightii ttagstthingtblue( tButtontquitRtpacktLEFTtBOTHtCanvastdrawtcreate_rectangle(R((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyt createWidgets s %cGs-|jjddd|jd|jdS(NRs0.01ii (Rtmovetaftert moveThing(Rtargs((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyRscCs>tj||tj||j|jd|jdS(Ni (tFramet__init__tPacktconfigRRR(Rtmaster((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyR s  N(t__name__t __module__RRRtNoneR (((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyRs  N(tTkinterRRttesttmainloop(((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyts  PK!;mDD matt/canvas-reading-tag-info.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pytprintitscCs!t|ddddd|j|_|jjdtdtt|dd d d |_|jjd d d d d d d d ddd d}|jj |d}dG|dGdGH|jj |d}dG|dGdGHdG|dGdGH|jj |d }dG|dGH|jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheighti inttagstweeetfootgrootstipples#pgon's current stipple value is -->is<--s pgon's current fill value is -->s when he is usually colored -->ispgon's tags are(RRR( tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawingtcreate_polygont itemconfigtLEFT(Rtpgont option_value((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyt createWidgetss   cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR (Rtmaster((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyR"*s N(t__name__t __module__RR tNoneR"(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyRs  "N(tTkinterR!Rttesttmainloop(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-reading-tag-info.pyts + PK!matt/rubber-line-demo-1.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs8eZdZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pytprintitsc Cs{t|ddddddddd |j|_|jjd td tt|d d dd |_|jjd tdS(NttexttQUITt backgroundtredt foregroundtwhitetheightitcommandtsidetfilltwidtht5i( tButtontquitRtpacktBOTTOMtBOTHtCanvast canvasObjecttLEFT(R((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyt createWidgetsscCs4|jj|j|_|jj|j|_dS(N(Rtcanvasxtxtstartxtcanvasytytstarty(Rtevent((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyt mouseDownscCs|jj|j}|jj|j}|j|jkr|j|jkr|jj|j|jj |j|j|||_|j ndS(N( RRRRRRRtdeletetrubberbandLinet create_linetupdate_idletasks(RR RR((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyt mouseMotions$ cCsftj||tj||jd|_tj|j d|j tj|j d|j dS(Ns s( tFramet__init__tPacktconfigRtNoneR#tWidgettbindRR!R&(Rtmaster((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyR('s    N(t__name__t __module__RRR!R&R+R((((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyRs    N(tTkinterR'Rttesttmainloop(((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyts . PK!S"  matt/placer-simple.pyonu[ ^c@seddlTdZdZdZeZeeZejdejddej dS(i(t*cCs#tjjd|jd|jdS(Ntxty(tapptbuttontplaceRR(tevent((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pyt do_motionscCs dGHdS(Ns calling me!((((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pytdothisscCst|dddddd}|jddddt|d d d d d t|_|jjdddddt|jdt|S(Ntwidthitheightt backgroundtgreentrelxgtrelyt foregroundtredttexttamazingtcommandg?tanchors(tFrameRtButtonRRtNWtbindR(ttoptf((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pyt createWidgets s !t400x400iN( tTkinterRRRtTktrootRtgeometrytmaxsizetmainloop(((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pyts       PK!kmatt/dialog-box.pycnu[ ^c@sGddlTddlmZdefdYZeZejdS(i(t*(tDialogtTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pytprintitsc Cs1t|ddddddddd d }|jS( sCreate a top-level dialog with some buttons. This uses the Dialog class, which is a wrapper around the Tcl/Tk tk_dialog script. The function returns 0 if the user clicks 'yes' or 1 if the user clicks 'no'. ttitlesfred the dialog boxttextsclick on a choicetbitmaptinfotdefaultitstringstyestno(R R (Rtnum(Rtd((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyt makeWindow s cCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NRtQUITt foregroundtredtcommandtsidetfillsMake a New Window(tButtontquitRtpacktLEFTtBOTHRthi_there(R((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyt createWidgets.s cCs4tj||tj|d|_|jdS(Ni(tFramet__init__tPacktconfigt windownumR(Rtmaster((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyR9s  N(t__name__t __module__RRRtNoneR(((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyRs  # N(tTkinterRRRttesttmainloop(((s4/usr/lib64/python2.7/Demo/tkinter/matt/dialog-box.pyts 8 PK!  matt/canvas-gridding.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs8eZdZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pytprintit sc Cs{t|ddddddddd |j|_|jjd td tt|d d dd |_|jjd tdS(NttexttQUITt backgroundtredt foregroundtwhitetheightitcommandtsidetfilltwidtht5i( tButtontquitRtpacktBOTTOMtBOTHtCanvast canvasObjecttLEFT(R((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyt createWidgets scCs@|jj|j|j|_|jj|j|j|_dS(N(Rtcanvasxtxt griddingSizetstartxtcanvasytytstarty(Rtevent((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyt mouseDownscCs|jj|j|j}|jj|j|j}|j|jkr|j|jkr|jj|j |jj |j|j|||_ |j ndS(N( RRRRRRRR tdeletet rubberbandBoxtcreate_rectangletupdate_idletasks(RR!RR((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyt mouseMotions$ cCsotj||tj||jd|_d|_tj |j d|j tj |j d|j dS(Ni2s s( tFramet__init__tPacktconfigRtNoneR$RtWidgettbindRR"R'(Rtmaster((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyR),s    N(t__name__t __module__RRR"R'R,R)(((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyRs    N(tTkinterR(Rttesttmainloop(((s9/usr/lib64/python2.7/Demo/tkinter/matt/canvas-gridding.pyts 3 PK!aI  "matt/canvas-moving-or-creating.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(c Cs|jjts|jj|jd|jd|jd|jddddt}|jj|d|j|jj|d|j n|j|_ |j|_ dS(Ni tfilltgreenttagss s ( twidgett find_withtagtCURRENTtdrawt create_ovaltxtyttag_bindt mouseEntert mouseLeavetlastxtlasty(tselfteventtfred((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyt mouseDown s + cCsF|jjt|j|j|j|j|j|_|j|_dS(N(RtmoveRR RR R(RR((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyt mouseMoves* cCs|jjtdddS(NRtred(Rt itemconfigR(RR((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyR $scCs|jjtdddS(NRtblue(RRR(RR((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyR)scCst|ddddd|j|_|jjdtdtt|dd d d |_|jjdttj |jd |j tj |jd |j dS( NttexttQUITt foregroundRtcommandtsideRtwidtht5itheights<1>s ( tButtontquitRtpacktLEFTtBOTHtCanvasRtWidgettbindRR(R((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyt createWidgets.scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR*(Rtmaster((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyR,8s N( t__name__t __module__RRR RR*tNoneR,(((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyRs      N(tTkinterR+Rttesttmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyts 7 PK!0Lmatt/killing-window-w-wm.pycnu[ ^c@s@ddlTdZdefdYZeZejdS(i(t*cCs dGHdS(Nswhoops -- tried to delete me!((((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pytmy_delete_callback stTestcBs&eZdZdZddZRS(cCs |GdGHdS(Ns3is now getting nuked. performing some save here....((tselftevent((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyt deathHandler scCs,t|dd|_|jjdtdS(NttexttHellotside(tButtonthi_theretpacktLEFT(R((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyt createWidgetsscCs>tj||tj||j|jd|jdS(Ns (tFramet__init__tPacktconfigR tbind_allR(Rtmaster((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyRs  N(t__name__t __module__RR tNoneR(((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyR s  N(tTkinterRRRttesttmainloop(((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyts   PK! matt/slider-demo-1.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dG|GHdS(Ns slider now at((tselftval((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyt print_valuescCs|jjddS(Ni(tslidertset(R((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pytreset scCst|dddddtdddd d |j|_t|d d d |j|_t|d d ddd |j|_|jjdt |jjdt |jjdt dt dS(Ntfrom_ittoidtorienttlengtht3itlabels happy slidertcommandttexts reset slidertQUITt foregroundtredtsidetfill( tScalet HORIZONTALRRtButtonRtquitRtpacktLEFTtBOTH(R((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyt createWidgets scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyRs N(t__name__t __module__RRRtNoneR(((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyRs   N(tTkinterRRttesttmainloop(((s7/usr/lib64/python2.7/Demo/tkinter/matt/slider-demo-1.pyts  PK!0Lmatt/killing-window-w-wm.pyonu[ ^c@s@ddlTdZdefdYZeZejdS(i(t*cCs dGHdS(Nswhoops -- tried to delete me!((((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pytmy_delete_callback stTestcBs&eZdZdZddZRS(cCs |GdGHdS(Ns3is now getting nuked. performing some save here....((tselftevent((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyt deathHandler scCs,t|dd|_|jjdtdS(NttexttHellotside(tButtonthi_theretpacktLEFT(R((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyt createWidgetsscCs>tj||tj||j|jd|jdS(Ns (tFramet__init__tPacktconfigR tbind_allR(Rtmaster((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyRs  N(t__name__t __module__RR tNoneR(((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyR s  N(tTkinterRRRttesttmainloop(((s=/usr/lib64/python2.7/Demo/tkinter/matt/killing-window-w-wm.pyts   PK!S"  matt/placer-simple.pycnu[ ^c@seddlTdZdZdZeZeeZejdejddej dS(i(t*cCs#tjjd|jd|jdS(Ntxty(tapptbuttontplaceRR(tevent((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pyt do_motionscCs dGHdS(Ns calling me!((((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pytdothisscCst|dddddd}|jddddt|d d d d d t|_|jjdddddt|jdt|S(Ntwidthitheightt backgroundtgreentrelxgtrelyt foregroundtredttexttamazingtcommandg?tanchors(tFrameRtButtonRRtNWtbindR(ttoptf((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pyt createWidgets s !t400x400iN( tTkinterRRRtTktrootRtgeometrytmaxsizetmainloop(((s7/usr/lib64/python2.7/Demo/tkinter/matt/placer-simple.pyts       PK!;U<"matt/subclass-existing-widgets.pycnu[ ^c@sJddlTdefdYZdZeZeeejdS(i(t*t New_ButtoncBseZdZRS(cCs|jGH|jd|_dS(Ni(tcounter(tself((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pytcallbacks(t__name__t __module__R(((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pyRscCst|}|jt|ddddd|j|_|jjdtdtt|dd|_|jj d|jj |jjdtd |j_ dS( NttexttQUITt foregroundtredtcommandtsidetfilltHelloi+( tFrametpacktButtontquitRtLEFTtBOTHRthi_theretconfigRR(ttoptf((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pyt createWidgets s  $N(tTkinterRRRtTktroottmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/subclass-existing-widgets.pyts    PK!̆^#matt/not-what-you-might-think-1.pyonu[ ^c@sWddlTdefdYZeZejjdejjdejdS(i(t*tTestcBseZdZddZRS(cCsxt|dddddd|_|jjdtt|jddd d d |j|j_|jjjdtdS( Ntwidtht1itheightt backgroundtgreentsidettexttQUITt foregroundtredtcommand(tFrametGpaneltpacktLEFTtButtontquitR (tself((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyt createWidgetss cCs+tj||tj||jdS(N(R t__init__tPacktconfigR(Rtmaster((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyRs N(t__name__t __module__RtNoneR(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyRs s packer demotpackerN(tTkinterR RttestRttitleticonnametmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyts  PK!3(jjmatt/window-creation-simple.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pytprintitscCs/t}t|dd|_|jjdS(NttextsHere's a new window(tTopleveltLabeltlabeltpack(Rtfred((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyt makeWindow s cCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NRtQUITt foregroundtredtcommandtsidetfillsMake a New Window(tButtontquitR R tLEFTtBOTHR thi_there(R((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyt createWidgetss cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyRs N(t__name__t __module__RR RtNoneR(((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyRs   N(tTkinterRRttesttmainloop(((s@/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-simple.pyts  PK!matt/animation-simple.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pytprintitsc Cst|ddddd|j|_|jjdtdtt|dd d d |_|jjd d d d d ddd|jjdtdS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheightii ttagstthingtblue( tButtontquitRtpacktLEFTtBOTHtCanvastdrawtcreate_rectangle(R((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyt createWidgets s %cGs-|jjddd|jd|jdS(NRs0.01ii (Rtmovetaftert moveThing(Rtargs((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyRscCs>tj||tj||j|jd|jdS(Ni (tFramet__init__tPacktconfigRRR(Rtmaster((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyR s  N(t__name__t __module__RRRtNoneR (((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyRs  N(tTkinterRRttesttmainloop(((s:/usr/lib64/python2.7/Demo/tkinter/matt/animation-simple.pyts  PK!MhΩ matt/canvas-moving-w-mouse.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(cCs|j|_|j|_dS(N(txtlastxtytlasty(tselftevent((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseDown s cCsF|jjt|j|j|j|j|j|_|j|_dS(N(tdrawtmovetCURRENTRRRR(RR((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseMoves* cCs|jjtdddS(Ntfilltred(R t itemconfigR (RR((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseEnterscCs|jjtdddS(NR tblue(R RR (RR((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt mouseLeavesc Cst|ddddd|j|_|jjdtdtt|dd d d |_|jjdt|jjd d d d dd dd}|jj |d|j |jj |d|j t j |jd|jt j |jd|jdS(NttexttQUITt foregroundRtcommandtsideR twidtht5itheightiitgreenttagstselecteds s s<1>s (tButtontquitRtpacktLEFTtBOTHtCanvasR t create_ovalttag_bindRRtWidgettbindRR (Rtfred((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyt createWidgets!scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR)(Rtmaster((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyR+1s N( t__name__t __module__RR RRR)tNoneR+(((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyRs     N(tTkinterR*Rttesttmainloop(((s?/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-w-mouse.pyts 1 PK!nЈ matt/dialog-box.pynu[from Tkinter import * from Dialog import Dialog # this shows how to create a new window with a button in it # that can create new windows class Test(Frame): def printit(self): print "hi" def makeWindow(self): """Create a top-level dialog with some buttons. This uses the Dialog class, which is a wrapper around the Tcl/Tk tk_dialog script. The function returns 0 if the user clicks 'yes' or 1 if the user clicks 'no'. """ # the parameters to this call are as follows: d = Dialog( self, ## name of a toplevel window title="fred the dialog box",## title on the window text="click on a choice", ## message to appear in window bitmap="info", ## bitmap (if any) to appear; ## if none, use "" # legal values here are: # string what it looks like # ---------------------------------------------- # error a circle with a slash through it # grey25 grey square # grey50 darker grey square # hourglass use for "wait.." # info a large, lower case "i" # questhead a human head with a "?" in it # question a large "?" # warning a large "!" # @fname X bitmap where fname is the path to the file # default=0, # the index of the default button choice. # hitting return selects this strings=("yes", "no")) # values of the 'strings' key are the labels for the # buttons that appear left to right in the dialog box return d.num def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) # a hello button self.hi_there = Button(self, text='Make a New Window', command=self.makeWindow) self.hi_there.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.windownum = 0 self.createWidgets() test = Test() test.mainloop() PK! NNmatt/canvas-moving-w-mouse.pynu[from Tkinter import * # this file demonstrates the movement of a single canvas item under mouse control class Test(Frame): ################################################################### ###### Event callbacks for THE CANVAS (not the stuff drawn on it) ################################################################### def mouseDown(self, event): # remember where the mouse went down self.lastx = event.x self.lasty = event.y def mouseMove(self, event): # whatever the mouse is over gets tagged as CURRENT for free by tk. self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) self.lastx = event.x self.lasty = event.y ################################################################### ###### Event callbacks for canvas ITEMS (stuff drawn on the canvas) ################################################################### def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="red") def mouseLeave(self, event): # the CURRENT tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") self.draw.pack(side=LEFT) fred = self.draw.create_oval(0, 0, 20, 20, fill="green", tags="selected") self.draw.tag_bind(fred, "", self.mouseEnter) self.draw.tag_bind(fred, "", self.mouseLeave) Widget.bind(self.draw, "<1>", self.mouseDown) Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!matt/rubber-line-demo-1.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs8eZdZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pytprintitsc Cs{t|ddddddddd |j|_|jjd td tt|d d dd |_|jjd tdS(NttexttQUITt backgroundtredt foregroundtwhitetheightitcommandtsidetfilltwidtht5i( tButtontquitRtpacktBOTTOMtBOTHtCanvast canvasObjecttLEFT(R((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyt createWidgetsscCs4|jj|j|_|jj|j|_dS(N(Rtcanvasxtxtstartxtcanvasytytstarty(Rtevent((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyt mouseDownscCs|jj|j}|jj|j}|j|jkr|j|jkr|jj|j|jj |j|j|||_|j ndS(N( RRRRRRRtdeletetrubberbandLinet create_linetupdate_idletasks(RR RR((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyt mouseMotions$ cCsftj||tj||jd|_tj|j d|j tj|j d|j dS(Ns s( tFramet__init__tPacktconfigRtNoneR#tWidgettbindRR!R&(Rtmaster((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyR('s    N(t__name__t __module__RRR!R&R+R((((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyRs    N(tTkinterR'Rttesttmainloop(((s</usr/lib64/python2.7/Demo/tkinter/matt/rubber-line-demo-1.pyts . PK!e̍matt/canvas-demo-simple.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pytprintitscCst|ddddd|j|_|jjdtdtt|dd d d |_|jjd d d d dd |jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheightit3itblack( tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawtcreate_rectangletLEFT(R((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyt createWidgets s cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyRs N(t__name__t __module__RRtNoneR(((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyRs  N(tTkinterRRttesttmainloop(((s</usr/lib64/python2.7/Demo/tkinter/matt/canvas-demo-simple.pyts  PK!L  !matt/printing-coords-of-items.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(cCs|jjts|jj|jd|jd|jd|jddd}|jj|d|j|jj|d|j n|j|_ |j|_ dS(Ni tfilltgreenss( twidgett find_withtagtCURRENTtdrawt create_ovaltxtyttag_bindt mouseEntert mouseLeavetlastxtlasty(tselfteventtfred((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyt mouseDown s +  cCsF|jjt|j|j|j|j|j|_|j|_dS(N(RtmoveRR RR R(RR((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyt mouseMoves* cCs+|jjtdd|jjtGHdS(NRtred(Rt itemconfigRtcoords(RR((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyR "scCs|jjtdddS(NRtblue(RRR(RR((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyR (scCst|ddddd|j|_|jjdtdtt|dd d d |_|jjdttj |jd |j tj |jd |j dS( NttexttQUITt foregroundRtcommandtsideRtwidtht5itheights<1>s ( tButtontquitRtpacktLEFTtBOTHtCanvasRtWidgettbindRR(R((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyt createWidgets-scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR*(Rtmaster((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyR,7s N( t__name__t __module__RRR R R*tNoneR,(((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyRs      N(tTkinterR+Rttesttmainloop(((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyts 7 PK!br; ; matt/canvas-with-scrollbars.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pytprintit sc Cst|dd|_|jjt|ddddddd|j|_|jjd td tt|dd }|jd tt |d d dd dddd|_ t |dt |j _ t |dt|j _|j j j|j d<|j jj|j d<|j j|j j d<|j j|j jd<|j jddddd d|j jddddd d|j j jd td t|j jjd td t|j jd tdS(NttextsCan Find The BLUE Square??????tQUITt backgroundtredtheightitcommandtsidetfills0.25itwidtht5itwhitet scrollregionit20itorienttxscrollcommandtyscrollcommands3.5itblackt10is13.5itblue(iiRR(tLabeltquestiontpacktButtontquitRtBOTTOMtBOTHtFrametCanvastdrawt Scrollbart HORIZONTALtscrollXtVERTICALtscrollYtsettxviewtyviewtcreate_rectangletXtRIGHTtYtLEFT(Rtspacer((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyt createWidgets s*  cGsdG|GH|jjjGHdS(Nt scrolling(R!R$tget(Rtargs((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyt scrollCanvasX0s cCs+tj||tj||jdS(N(Rt__init__tPacktconfigR0(Rtmaster((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyR55s N(t__name__t __module__RR0R4tNoneR5(((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyRs  $ N(tTkinterRRttesttmainloop(((s@/usr/lib64/python2.7/Demo/tkinter/matt/canvas-with-scrollbars.pyts 2 PK!>kv v !matt/canvas-moving-or-creating.pynu[from Tkinter import * # this file demonstrates a more sophisticated movement -- # move dots or create new ones if you click outside the dots class Test(Frame): ################################################################### ###### Event callbacks for THE CANVAS (not the stuff drawn on it) ################################################################### def mouseDown(self, event): # see if we're inside a dot. If we are, it # gets tagged as CURRENT for free by tk. if not event.widget.find_withtag(CURRENT): # there is no dot here, so we can make one, # and bind some interesting behavior to it. # ------ # create a dot, and mark it as CURRENT fred = self.draw.create_oval( event.x - 10, event.y -10, event.x +10, event.y + 10, fill="green", tags=CURRENT) self.draw.tag_bind(fred, "", self.mouseEnter) self.draw.tag_bind(fred, "", self.mouseLeave) self.lastx = event.x self.lasty = event.y def mouseMove(self, event): self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) self.lastx = event.x self.lasty = event.y ################################################################### ###### Event callbacks for canvas ITEMS (stuff drawn on the canvas) ################################################################### def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="red") def mouseLeave(self, event): # the CURRENT tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") self.draw.pack(side=LEFT) Widget.bind(self.draw, "<1>", self.mouseDown) Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!x##!matt/menu-all-types-of-entries.pynu[from Tkinter import * # some vocabulary to keep from getting confused. This terminology # is something I cooked up for this file, but follows the man pages # pretty closely # # # # This is a MENUBUTTON # V # +-------------+ # | | # # +------------++------------++------------+ # | || || | # | File || Edit || Options | <-------- the MENUBAR # | || || | # +------------++------------++------------+ # | New... | # | Open... | # | Print | # | | <-------- This is a MENU. The lines of text in the menu are # | | MENU ENTRIES # | +---------------+ # | Open Files > | file1 | # | | file2 | # | | another file | <------ this cascading part is also a MENU # +----------------| | # | | # | | # | | # +---------------+ # some miscellaneous callbacks def new_file(): print "opening new file" def open_file(): print "opening OLD file" def print_something(): print "picked a menu item" anchovies = 0 def print_anchovies(): global anchovies anchovies = not anchovies print "anchovies?", anchovies def makeCommandMenu(): # make menu button Command_button = Menubutton(mBar, text='Simple Button Commands', underline=0) Command_button.pack(side=LEFT, padx="2m") # make the pulldown part of the File menu. The parameter passed is the master. # we attach it to the button as a python attribute called "menu" by convention. # hopefully this isn't too confusing... Command_button.menu = Menu(Command_button) # just to be cute, let's disable the undo option: Command_button.menu.add_command(label="Undo") # undo is the 0th entry... Command_button.menu.entryconfig(0, state=DISABLED) Command_button.menu.add_command(label='New...', underline=0, command=new_file) Command_button.menu.add_command(label='Open...', underline=0, command=open_file) Command_button.menu.add_command(label='Different Font', underline=0, font='-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*', command=print_something) # we can make bitmaps be menu entries too. File format is X11 bitmap. # if you use XV, save it under X11 bitmap format. duh-uh.,.. Command_button.menu.add_command( bitmap="info") #bitmap='@/home/mjc4y/dilbert/project.status.is.doomed.last.panel.bm') # this is just a line Command_button.menu.add('separator') # change the color Command_button.menu.add_command(label='Quit', underline=0, background='red', activebackground='green', command=Command_button.quit) # set up a pointer from the file menubutton back to the file menu Command_button['menu'] = Command_button.menu return Command_button def makeCascadeMenu(): # make menu button Cascade_button = Menubutton(mBar, text='Cascading Menus', underline=0) Cascade_button.pack(side=LEFT, padx="2m") # the primary pulldown Cascade_button.menu = Menu(Cascade_button) # this is the menu that cascades from the primary pulldown.... Cascade_button.menu.choices = Menu(Cascade_button.menu) # ...and this is a menu that cascades from that. Cascade_button.menu.choices.weirdones = Menu(Cascade_button.menu.choices) # then you define the menus from the deepest level on up. Cascade_button.menu.choices.weirdones.add_command(label='avacado') Cascade_button.menu.choices.weirdones.add_command(label='belgian endive') Cascade_button.menu.choices.weirdones.add_command(label='beefaroni') # definition of the menu one level up... Cascade_button.menu.choices.add_command(label='Chocolate') Cascade_button.menu.choices.add_command(label='Vanilla') Cascade_button.menu.choices.add_command(label='TuttiFruiti') Cascade_button.menu.choices.add_command(label='WopBopaLoopBapABopBamBoom') Cascade_button.menu.choices.add_command(label='Rocky Road') Cascade_button.menu.choices.add_command(label='BubbleGum') Cascade_button.menu.choices.add_cascade( label='Weird Flavors', menu=Cascade_button.menu.choices.weirdones) # and finally, the definition for the top level Cascade_button.menu.add_cascade(label='more choices', menu=Cascade_button.menu.choices) Cascade_button['menu'] = Cascade_button.menu return Cascade_button def makeCheckbuttonMenu(): global fred # make menu button Checkbutton_button = Menubutton(mBar, text='Checkbutton Menus', underline=0) Checkbutton_button.pack(side=LEFT, padx='2m') # the primary pulldown Checkbutton_button.menu = Menu(Checkbutton_button) # and all the check buttons. Note that the "variable" "onvalue" and "offvalue" options # are not supported correctly at present. You have to do all your application # work through the calback. Checkbutton_button.menu.add_checkbutton(label='Pepperoni') Checkbutton_button.menu.add_checkbutton(label='Sausage') Checkbutton_button.menu.add_checkbutton(label='Extra Cheese') # so here's a callback Checkbutton_button.menu.add_checkbutton(label='Anchovy', command=print_anchovies) # and start with anchovies selected to be on. Do this by # calling invoke on this menu option. To refer to the "anchovy" menu # entry we need to know it's index. To do this, we use the index method # which takes arguments of several forms: # # argument what it does # ----------------------------------- # a number -- this is useless. # "last" -- last option in the menu # "none" -- used with the activate command. see the man page on menus # "active" -- the currently active menu option. A menu option is made active # with the 'activate' method # "@number" -- where 'number' is an integer and is treated like a y coordinate in pixels # string pattern -- this is the option used below, and attempts to match "labels" using the # rules of Tcl_StringMatch Checkbutton_button.menu.invoke(Checkbutton_button.menu.index('Anchovy')) # set up a pointer from the file menubutton back to the file menu Checkbutton_button['menu'] = Checkbutton_button.menu return Checkbutton_button def makeRadiobuttonMenu(): # make menu button Radiobutton_button = Menubutton(mBar, text='Radiobutton Menus', underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) # and all the Radio buttons. Note that the "variable" "onvalue" and "offvalue" options # are not supported correctly at present. You have to do all your application # work through the calback. Radiobutton_button.menu.add_radiobutton(label='Republican') Radiobutton_button.menu.add_radiobutton(label='Democrat') Radiobutton_button.menu.add_radiobutton(label='Libertarian') Radiobutton_button.menu.add_radiobutton(label='Commie') Radiobutton_button.menu.add_radiobutton(label='Facist') Radiobutton_button.menu.add_radiobutton(label='Labor Party') Radiobutton_button.menu.add_radiobutton(label='Torie') Radiobutton_button.menu.add_radiobutton(label='Independent') Radiobutton_button.menu.add_radiobutton(label='Anarchist') Radiobutton_button.menu.add_radiobutton(label='No Opinion') # set up a pointer from the file menubutton back to the file menu Radiobutton_button['menu'] = Radiobutton_button.menu return Radiobutton_button def makeDisabledMenu(): Dummy_button = Menubutton(mBar, text='Dead Menu', underline=0) Dummy_button.pack(side=LEFT, padx='2m') # this is the standard way of turning off a whole menu Dummy_button["state"] = DISABLED return Dummy_button ################################################# #### Main starts here ... root = Tk() # make a menu bar mBar = Frame(root, relief=RAISED, borderwidth=2) mBar.pack(fill=X) Command_button = makeCommandMenu() Cascade_button = makeCascadeMenu() Checkbutton_button = makeCheckbuttonMenu() Radiobutton_button = makeRadiobuttonMenu() NoMenu = makeDisabledMenu() # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(Command_button, Cascade_button, Checkbutton_button, Radiobutton_button, NoMenu) root.title('menu demo') root.iconname('menu demo') root.mainloop() PK!: matt/canvas-mult-item-sel.pyonu[ ^c@sCddlTdZdZdefdYZeZejdS(i(t*tredtbluetTestcBs8eZdZdZdZdZddZRS(cCs|jjts;|jjddt|jjdn,|jjddt|jjddt|j |_ |j |_ dS(Ntselectedtfilltwithtag( twidgett find_withtagtCURRENTtdrawt itemconfigtUNSELECTED_COLORtdtagtaddtagtSELECTED_COLORtxtlastxtytlasty(tselftevent((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt mouseDown s cCsF|jjd|j|j|j|j|j|_|j|_dS(NR(R tmoveRRRR(RR((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt mouseMove!s* c CsA|jjdddddtdt}|jjddtdS(NiiRttagsRR(R t create_ovalRR R(Rtfred((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt makeNewDot&scCs(t|ddddd|j|_t|dddd|_tj|jd |jtj|jd |jt|dd dd d|j |_ d t t f}t |ddd||_|jjdtdt|jjdtdtdd|j jdtdt|jjdtdS(NttexttQUITt foregroundRtcommandtwidtht5itheights<1>s smake a new dotRs%s dots are selected and can be dragged. %s are not selected. Click in a dot to select it. Click on empty space to deselect all dots.tsideRtexpandi(tButtontquitRtCanvasR tWidgettbindRRRtbuttonRR tMessagetlabeltpacktBOTTOMtBOTHtXtLEFT(Rtmessage((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt createWidgets-s cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR4(Rtmaster((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyR6Hs N(t__name__t __module__RRRR4tNoneR6(((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyRs     N(tTkinterRR R5Rttesttmainloop(((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyts E PK!F77#matt/not-what-you-might-think-2.pyonu[ ^c@sWddlTdefdYZeZejjdejjdejdS(i(t*tTestcBseZdZddZRS(cCst|dddddd|_|jjd|jjdtt|jdd d d d |j|j_|jjjdtdS( Ntwidtht1itheightt backgroundtgreenitsidettexttQUITt foregroundtredtcommand(tFrametGpanelt propagatetpacktLEFTtButtontquitR (tself((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyt createWidgetss cCs+tj||tj||jdS(N(R t__init__tPacktconfigR(Rtmaster((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyRs N(t__name__t __module__RtNoneR(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyRs s packer demotpackerN(tTkinterR RttestRttitleticonnametmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-2.pyts  PK!L  !matt/printing-coords-of-items.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(cCs|jjts|jj|jd|jd|jd|jddd}|jj|d|j|jj|d|j n|j|_ |j|_ dS(Ni tfilltgreenss( twidgett find_withtagtCURRENTtdrawt create_ovaltxtyttag_bindt mouseEntert mouseLeavetlastxtlasty(tselfteventtfred((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyt mouseDown s +  cCsF|jjt|j|j|j|j|j|_|j|_dS(N(RtmoveRR RR R(RR((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyt mouseMoves* cCs+|jjtdd|jjtGHdS(NRtred(Rt itemconfigRtcoords(RR((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyR "scCs|jjtdddS(NRtblue(RRR(RR((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyR (scCst|ddddd|j|_|jjdtdtt|dd d d |_|jjdttj |jd |j tj |jd |j dS( NttexttQUITt foregroundRtcommandtsideRtwidtht5itheights<1>s ( tButtontquitRtpacktLEFTtBOTHtCanvasRtWidgettbindRR(R((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyt createWidgets-scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR*(Rtmaster((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyR,7s N( t__name__t __module__RRR R R*tNoneR,(((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyRs      N(tTkinterR+Rttesttmainloop(((sB/usr/lib64/python2.7/Demo/tkinter/matt/printing-coords-of-items.pyts 7 PK!aI  "matt/canvas-moving-or-creating.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBsAeZdZdZdZdZdZddZRS(c Cs|jjts|jj|jd|jd|jd|jddddt}|jj|d|j|jj|d|j n|j|_ |j|_ dS(Ni tfilltgreenttagss s ( twidgett find_withtagtCURRENTtdrawt create_ovaltxtyttag_bindt mouseEntert mouseLeavetlastxtlasty(tselfteventtfred((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyt mouseDown s + cCsF|jjt|j|j|j|j|j|_|j|_dS(N(RtmoveRR RR R(RR((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyt mouseMoves* cCs|jjtdddS(NRtred(Rt itemconfigR(RR((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyR $scCs|jjtdddS(NRtblue(RRR(RR((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyR)scCst|ddddd|j|_|jjdtdtt|dd d d |_|jjdttj |jd |j tj |jd |j dS( NttexttQUITt foregroundRtcommandtsideRtwidtht5itheights<1>s ( tButtontquitRtpacktLEFTtBOTHtCanvasRtWidgettbindRR(R((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyt createWidgets.scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR*(Rtmaster((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyR,8s N( t__name__t __module__RRR RR*tNoneR,(((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyRs      N(tTkinterR+Rttesttmainloop(((sC/usr/lib64/python2.7/Demo/tkinter/matt/canvas-moving-or-creating.pyts 7 PK!d matt/canvas-w-widget-draw-el.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pytprinthiscCst|ddddd|j|_|jjdtdtt|dd d d |_t|dd d|j|_ |jj d d d |j |jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheightsthis is a buttoni,twindow( tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawRtbuttont create_windowtLEFT(R((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyt createWidgets scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyRs N(t__name__t __module__RRtNoneR(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyRs  N(tTkinterRRttesttmainloop(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyts  PK!uk/matt/animation-simple.pynu[from Tkinter import * # This program shows how to use the "after" function to make animation. class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") # all of these work.. self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") self.draw.pack(side=LEFT) def moveThing(self, *args): # move 1/10 of an inch every 1/10 sec (1" per second, smoothly) self.draw.move("thing", "0.01i", "0.01i") self.after(10, self.moveThing) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() self.after(10, self.moveThing) test = Test() test.mainloop() PK!t44matt/entry-simple.pycnu[ ^c@sSddlTddlZdefdYZeZejjdejdS(i(t*NtAppcBseZddZdZRS(cCsMtj|||jt|_|jj|jjd|jdS(Ns (tFramet__init__tpacktEntryt entrythingytbindtprint_contents(tselftmaster((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyRs    cCsdG|jjGHdS(Ns"hi. contents of entry is now ---->(Rtget(R tevent((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyRsN(t__name__t __module__tNoneRR(((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyRs tFoo(tTkintertstringRRtrootR ttitletmainloop(((s6/usr/lib64/python2.7/Demo/tkinter/matt/entry-simple.pyts   PK! yy!matt/bind-w-mult-calls-p-type.pycnu[ ^c@sSddlTddlZdefdYZeZejjdejdS(i(t*NtAppcBs&eZddZdZdZRS(cCsftj|||jt|_|jj|jjd|j|jjd|jddS(Ns t+(tFramet__init__tpacktEntryt entrythingytbindtprint_contentstprint_something_else(tselftmaster((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyRs    cCsdG|jjGHdS(Ns"hi. contents of entry is now ---->(Rtget(R tevent((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyR scCs dGHdS(Ns,hi. Now doing something completely different((R R((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyR sN(t__name__t __module__tNoneRR R (((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyRs  tFoo(tTkintertstringRRtrootR ttitletmainloop(((sB/usr/lib64/python2.7/Demo/tkinter/matt/bind-w-mult-calls-p-type.pyts   PK!~ǁ"matt/not-what-you-might-think-2.pynu[from Tkinter import * class Test(Frame): def createWidgets(self): self.Gpanel = Frame(self, width='1i', height='1i', background='green') # this line turns off the recalculation of geometry by masters. self.Gpanel.propagate(0) self.Gpanel.pack(side=LEFT) # a QUIT button self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', foreground='red', command=self.quit) self.Gpanel.QUIT.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.master.title('packer demo') test.master.iconname('packer') test.mainloop() PK! 4+matt/two-radio-groups.pycnu[ ^c@sddlTdZdZdZeZeededdZej de e Z e Zee ZeeZejeeeed d d d d eZej deejdejdejdS(i(t*cCsttdddd}|jdtddt||_|jjdd d |d d |jjd idd6|d 6dd 6|jjd idd6|d 6dd 6|jd|j|d<|S(NttextsPolitical Partyt underlineitsidetpadxt2mtlabelt Republicantvariabletvalueit radiobuttontDemocratit Libertarianitmenu( t MenubuttontmBartpacktLEFTtMenuR tadd_radiobuttontaddtset(tvartRadiobutton_button((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pytmakePoliticalPartiess      cCsttdddd}|jdtddt||_|jjdd d |d d |jjdd d |d d |jjdd d |d d |jd |j|d<|S(NRtFlavorsRiRRRRt StrawberryRR t Chocolates Rocky RoadR (RRRRRR RR(RR((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pyt makeFlavors2s      cCs#dGtjGHdGtjGHHdS(Nsparty iss flavor is(tpartytgettflavor(((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pyt printStuffMstrelieft borderwidthitfillRsprint party and flavort foregroundtredtcommandRs menu demoN(tTkinterRRR tTktroottFrametRAISEDRRtXtIntVarRt StringVarRRtRadiobutton_button2t tk_menuBartButtontbtTOPttitleticonnametmainloop(((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pyts"            PK!PPmatt/pong-demo-1.pycnu[ ^c@sCddlTddlZdefdYZeZejdS(i(t*NtPongcBs&eZdZdZddZRS(c Cst|ddddd|j|_|jjdtdtt|dd d d |_t|d t d d dddd|_ |j jdt dt |jj dddddd|_d|_d|_d|_d|_|jjdtdS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheighttorienttlabels ball speedtfrom_ittoidt0is0.10ig?g333333?g?(tButtontquitRtpacktLEFTtBOTHtCanvastdrawtScalet HORIZONTALtspeedtBOTTOMtXt create_ovaltballtxtyt velocity_xt velocity_y(tself((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyt createWidgetss     cGs|jdks|jdkr1d|j|_n|jdksO|jdkrbd|j|_n|j|jjd}|j|jjd}|j||_|j||_|jj|jd|d||j d|j dS(Ng@gggY@s%rii ( RR!R R"RtgetRtmoveRtaftertmoveBall(R#targstdeltaxtdeltay((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyR(s!cCs>tj||tj||j|jd|jdS(Ni (tFramet__init__tPacktconfigR$R'R((R#tmaster((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyR--s  N(t__name__t __module__R$R(tNoneR-(((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyRs  (tTkintertstringR,Rtgametmainloop(((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyts  . PK!: matt/canvas-mult-item-sel.pycnu[ ^c@sCddlTdZdZdefdYZeZejdS(i(t*tredtbluetTestcBs8eZdZdZdZdZddZRS(cCs|jjts;|jjddt|jjdn,|jjddt|jjddt|j |_ |j |_ dS(Ntselectedtfilltwithtag( twidgett find_withtagtCURRENTtdrawt itemconfigtUNSELECTED_COLORtdtagtaddtagtSELECTED_COLORtxtlastxtytlasty(tselftevent((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt mouseDown s cCsF|jjd|j|j|j|j|j|_|j|_dS(NR(R tmoveRRRR(RR((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt mouseMove!s* c CsA|jjdddddtdt}|jjddtdS(NiiRttagsRR(R t create_ovalRR R(Rtfred((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt makeNewDot&scCs(t|ddddd|j|_t|dddd|_tj|jd |jtj|jd |jt|dd dd d|j |_ d t t f}t |ddd||_|jjdtdt|jjdtdtdd|j jdtdt|jjdtdS(NttexttQUITt foregroundRtcommandtwidtht5itheights<1>s smake a new dotRs%s dots are selected and can be dragged. %s are not selected. Click in a dot to select it. Click on empty space to deselect all dots.tsideRtexpandi(tButtontquitRtCanvasR tWidgettbindRRRtbuttonRR tMessagetlabeltpacktBOTTOMtBOTHtXtLEFT(Rtmessage((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyt createWidgets-s cCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR4(Rtmaster((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyR6Hs N(t__name__t __module__RRRR4tNoneR6(((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyRs     N(tTkinterRR R5Rttesttmainloop(((s>/usr/lib64/python2.7/Demo/tkinter/matt/canvas-mult-item-sel.pyts E PK!PPmatt/pong-demo-1.pyonu[ ^c@sCddlTddlZdefdYZeZejdS(i(t*NtPongcBs&eZdZdZddZRS(c Cst|ddddd|j|_|jjdtdtt|dd d d |_t|d t d d dddd|_ |j jdt dt |jj dddddd|_d|_d|_d|_d|_|jjdtdS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheighttorienttlabels ball speedtfrom_ittoidt0is0.10ig?g333333?g?(tButtontquitRtpacktLEFTtBOTHtCanvastdrawtScalet HORIZONTALtspeedtBOTTOMtXt create_ovaltballtxtyt velocity_xt velocity_y(tself((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyt createWidgetss     cGs|jdks|jdkr1d|j|_n|jdksO|jdkrbd|j|_n|j|jjd}|j|jjd}|j||_|j||_|jj|jd|d||j d|j dS(Ng@gggY@s%rii ( RR!R R"RtgetRtmoveRtaftertmoveBall(R#targstdeltaxtdeltay((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyR(s!cCs>tj||tj||j|jd|jdS(Ni (tFramet__init__tPacktconfigR$R'R((R#tmaster((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyR--s  N(t__name__t __module__R$R(tNoneR-(((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyRs  (tTkintertstringR,Rtgametmainloop(((s5/usr/lib64/python2.7/Demo/tkinter/matt/pong-demo-1.pyts  . PK!R۩matt/menu-simple.pycnu[ ^c@sddlTdZdZdZdZeZeededdZ e j d e eZ eZ e je e ejd ejd ejd S( i(t*cCs dGHdS(Nsopening new file((((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pytnew_file$scCs dGHdS(Nsopening OLD file((((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyt open_file(scCsttdddd}|jdtddt||_|jjdd ddd t|jjdd ddd t|jjdd ddd d |j|d<|S(NttexttFilet underlineitsidetpadxt1mtlabelsNew...tcommandsOpen...tQuittexittmenu( t MenubuttontmBartpacktLEFTtMenuR t add_commandRR(t File_button((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyt makeFileMenu,s cCsttdddd}|jdtddt||_|jjdd d |jjd d t|jj d d |jj d d|jj d d|j|d<|S(NRtEditRiRRRR R tUndoitstatetCuttCopytPasteR ( RRRRRR taddt entryconfigtDISABLEDR(t Edit_button((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyt makeEditMenuFs trelieft borderwidthitfills menu demotpackerN(tTkinterRRRR tTktroottFrametRAISEDRRtXRRt tk_menuBarttitleticonnametmainloop(((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyts #         PK!}` ` matt/printing-coords-of-items.pynu[from Tkinter import * # this file demonstrates the creation of widgets as part of a canvas object class Test(Frame): ################################################################### ###### Event callbacks for THE CANVAS (not the stuff drawn on it) ################################################################### def mouseDown(self, event): # see if we're inside a dot. If we are, it # gets tagged as CURRENT for free by tk. if not event.widget.find_withtag(CURRENT): # there is no dot here, so we can make one, # and bind some interesting behavior to it. # ------ # create a dot, and mark it as current fred = self.draw.create_oval( event.x - 10, event.y -10, event.x +10, event.y + 10, fill="green") self.draw.tag_bind(fred, "", self.mouseEnter) self.draw.tag_bind(fred, "", self.mouseLeave) self.lastx = event.x self.lasty = event.y def mouseMove(self, event): self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty) self.lastx = event.x self.lasty = event.y ################################################################### ###### Event callbacks for canvas ITEMS (stuff drawn on the canvas) ################################################################### def mouseEnter(self, event): # the "current" tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="red") print self.draw.coords(CURRENT) def mouseLeave(self, event): # the "current" tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="blue") def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") self.draw.pack(side=LEFT) Widget.bind(self.draw, "<1>", self.mouseDown) Widget.bind(self.draw, "", self.mouseMove) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!_ matt/canvas-demo-simple.pynu[from Tkinter import * # this program creates a canvas and puts a single polygon on the canvas class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") # see the other demos for other ways of specifying coords for a polygon self.draw.create_rectangle(0, 0, "3i", "3i", fill="black") self.draw.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!>matt/two-radio-groups.pynu[from Tkinter import * # The way to think about this is that each radio button menu # controls a different variable -- clicking on one of the # mutually exclusive choices in a radiobutton assigns some value # to an application variable you provide. When you define a # radiobutton menu choice, you have the option of specifying the # name of a varaible and value to assign to that variable when # that choice is selected. This clever mechanism relieves you, # the programmer, from having to write a dumb callback that # probably wouldn't have done anything more than an assignment # anyway. The Tkinter options for this follow their Tk # counterparts: # {"variable" : my_flavor_variable, "value" : "strawberry"} # where my_flavor_variable is an instance of one of the # subclasses of Variable, provided in Tkinter.py (there is # StringVar(), IntVar(), DoubleVar() and BooleanVar() to choose # from) def makePoliticalParties(var): # make menu button Radiobutton_button = Menubutton(mBar, text='Political Party', underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) Radiobutton_button.menu.add_radiobutton(label='Republican', variable=var, value=1) Radiobutton_button.menu.add('radiobutton', {'label': 'Democrat', 'variable' : var, 'value' : 2}) Radiobutton_button.menu.add('radiobutton', {'label': 'Libertarian', 'variable' : var, 'value' : 3}) var.set(2) # set up a pointer from the file menubutton back to the file menu Radiobutton_button['menu'] = Radiobutton_button.menu return Radiobutton_button def makeFlavors(var): # make menu button Radiobutton_button = Menubutton(mBar, text='Flavors', underline=0) Radiobutton_button.pack(side=LEFT, padx='2m') # the primary pulldown Radiobutton_button.menu = Menu(Radiobutton_button) Radiobutton_button.menu.add_radiobutton(label='Strawberry', variable=var, value='Strawberry') Radiobutton_button.menu.add_radiobutton(label='Chocolate', variable=var, value='Chocolate') Radiobutton_button.menu.add_radiobutton(label='Rocky Road', variable=var, value='Rocky Road') # choose a default var.set("Chocolate") # set up a pointer from the file menubutton back to the file menu Radiobutton_button['menu'] = Radiobutton_button.menu return Radiobutton_button def printStuff(): print "party is", party.get() print "flavor is", flavor.get() print ################################################# #### Main starts here ... root = Tk() # make a menu bar mBar = Frame(root, relief=RAISED, borderwidth=2) mBar.pack(fill=X) # make two application variables, # one to control each radio button set party = IntVar() flavor = StringVar() Radiobutton_button = makePoliticalParties(party) Radiobutton_button2 = makeFlavors(flavor) # finally, install the buttons in the menu bar. # This allows for scanning from one menubutton to the next. mBar.tk_menuBar(Radiobutton_button, Radiobutton_button2) b = Button(root, text="print party and flavor", foreground="red", command=printStuff) b.pack(side=TOP) root.title('menu demo') root.iconname('menu demo') root.mainloop() PK!̆^#matt/not-what-you-might-think-1.pycnu[ ^c@sWddlTdefdYZeZejjdejjdejdS(i(t*tTestcBseZdZddZRS(cCsxt|dddddd|_|jjdtt|jddd d d |j|j_|jjjdtdS( Ntwidtht1itheightt backgroundtgreentsidettexttQUITt foregroundtredtcommand(tFrametGpaneltpacktLEFTtButtontquitR (tself((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyt createWidgetss cCs+tj||tj||jdS(N(R t__init__tPacktconfigR(Rtmaster((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyRs N(t__name__t __module__RtNoneR(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyRs s packer demotpackerN(tTkinterR RttestRttitleticonnametmainloop(((sD/usr/lib64/python2.7/Demo/tkinter/matt/not-what-you-might-think-1.pyts  PK!d matt/canvas-w-widget-draw-el.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pytprinthiscCst|ddddd|j|_|jjdtdtt|dd d d |_t|dd d|j|_ |jj d d d |j |jjdt dS(NttexttQUITt foregroundtredtcommandtsidetfilltwidtht5itheightsthis is a buttoni,twindow( tButtontquitRtpacktBOTTOMtBOTHtCanvastdrawRtbuttont create_windowtLEFT(R((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyt createWidgets scCs+tj||tj||jdS(N(tFramet__init__tPacktconfigR(Rtmaster((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyRs N(t__name__t __module__RRtNoneR(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyRs  N(tTkinterRRttesttmainloop(((sA/usr/lib64/python2.7/Demo/tkinter/matt/canvas-w-widget-draw-el.pyts  PK!#~"matt/entry-with-shared-variable.pynu[from Tkinter import * import string # This program shows how to make a typein box shadow a program variable. class App(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.entrythingy = Entry(self) self.entrythingy.pack() self.button = Button(self, text="Uppercase The Entry", command=self.upper) self.button.pack() # here we have the text in the entry widget tied to a variable. # changes in the variable are echoed in the widget and vice versa. # Very handy. # there are other Variable types. See Tkinter.py for all # the other variable types that can be shadowed self.contents = StringVar() self.contents.set("this is a variable") self.entrythingy.config(textvariable=self.contents) # and here we get a callback when the user hits return. we could # make the key that triggers the callback anything we wanted to. # other typical options might be or (for anything) self.entrythingy.bind('', self.print_contents) def upper(self): # notice here, we don't actually refer to the entry box. # we just operate on the string variable and we # because it's being looked at by the entry widget, changing # the variable changes the entry widget display automatically. # the strange get/set operators are clunky, true... str = string.upper(self.contents.get()) self.contents.set(str) def print_contents(self, event): print "hi. contents of entry is now ---->", self.contents.get() root = App() root.master.title("Foo") root.mainloop() PK!Jmatt/radiobutton-simple.pynu[from Tkinter import * # This is a demo program that shows how to # create radio buttons and how to get other widgets to # share the information in a radio button. # # There are other ways of doing this too, but # the "variable" option of radiobuttons seems to be the easiest. # # note how each button has a value it sets the variable to as it gets hit. class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.flavor = StringVar() self.flavor.set("chocolate") self.radioframe = Frame(self) self.radioframe.pack() # 'text' is the label # 'variable' is the name of the variable that all these radio buttons share # 'value' is the value this variable takes on when the radio button is selected # 'anchor' makes the text appear left justified (default is centered. ick) self.radioframe.choc = Radiobutton( self.radioframe, text="Chocolate Flavor", variable=self.flavor, value="chocolate", anchor=W) self.radioframe.choc.pack(fill=X) self.radioframe.straw = Radiobutton( self.radioframe, text="Strawberry Flavor", variable=self.flavor, value="strawberry", anchor=W) self.radioframe.straw.pack(fill=X) self.radioframe.lemon = Radiobutton( self.radioframe, text="Lemon Flavor", variable=self.flavor, value="lemon", anchor=W) self.radioframe.lemon.pack(fill=X) # this is a text entry that lets you type in the name of a flavor too. self.entry = Entry(self, textvariable=self.flavor) self.entry.pack(fill=X) self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!matt/canvas-w-widget-draw-el.pynu[from Tkinter import * # this file demonstrates the creation of widgets as part of a canvas object class Test(Frame): def printhi(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.draw = Canvas(self, width="5i", height="5i") self.button = Button(self, text="this is a button", command=self.printhi) # note here the coords are given in pixels (form the # upper right and corner of the window, as usual for X) # but might just have well been given in inches or points or # whatever...use the "anchor" option to control what point of the # widget (in this case the button) gets mapped to the given x, y. # you can specify corners, edges, center, etc... self.draw.create_window(300, 300, window=self.button) self.draw.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!oVVmatt/rubber-band-box-demo-1.pynu[from Tkinter import * class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', background='red', foreground='white', height=3, command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.canvasObject = Canvas(self, width="5i", height="5i") self.canvasObject.pack(side=LEFT) def mouseDown(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object self.startx = self.canvasObject.canvasx(event.x) self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object x = self.canvasObject.canvasx(event.x) y = self.canvasObject.canvasy(event.y) if (self.startx != event.x) and (self.starty != event.y) : self.canvasObject.delete(self.rubberbandBox) self.rubberbandBox = self.canvasObject.create_rectangle( self.startx, self.starty, x, y) # this flushes the output, making sure that # the rectangle makes it to the screen # before the next event is handled self.update_idletasks() def mouseUp(self, event): self.canvasObject.delete(self.rubberbandBox) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() # this is a "tagOrId" for the rectangle we draw on the canvas self.rubberbandBox = None # and the bindings that make it work.. Widget.bind(self.canvasObject, "", self.mouseDown) Widget.bind(self.canvasObject, "", self.mouseMotion) Widget.bind(self.canvasObject, "", self.mouseUp) test = Test() test.mainloop() PK!ZZmatt/window-creation-more.pyonu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs/eZdZdZdZddZRS(cCs dGHdS(Nthi((tself((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pytprintitscCsOt}t|dd|jd|j|_|jj|jd|_dS(NttextsThis is window number %d.tcommandi(tTopleveltButtont windownumt makeWindowtlabeltpack(Rtfred((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyR s     cCsrt|ddddd|j|_|jjdtdtt|ddd|j|_|jjdtdS( NRtQUITt foregroundtredRtsidetfillsMake a New Window(RtquitRR tLEFTtBOTHR thi_there(R((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyt createWidgetss cCs4tj||tj|d|_|jdS(Ni(tFramet__init__tPacktconfigR R(Rtmaster((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyRs  N(t__name__t __module__RR RtNoneR(((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyRs   N(tTkinterRRttesttmainloop(((s>/usr/lib64/python2.7/Demo/tkinter/matt/window-creation-more.pyts  PK!jHHmatt/radiobutton-simple.pycnu[ ^c@s7ddlTdefdYZeZejdS(i(t*tTestcBs&eZdZdZddZRS(cCs dGHdS(Nthi((tself((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pytprintitsc Csvt|_|jjdt||_|jjt|jddd|jdddt|j_|jjjdt t|jddd|jdd dt|j_ |jj jdt t|jdd d|jdd dt|j_ |jj jdt t |d |j|_ |j jdt t|dd ddd|j|_|jjdtdtdS(Nt chocolatettextsChocolate FlavortvariabletvaluetanchortfillsStrawberry Flavort strawberrys Lemon Flavortlemont textvariabletQUITt foregroundtredtcommandtside(t StringVartflavortsettFramet radioframetpackt RadiobuttontWtchoctXtstrawR tEntrytentrytButtontquitRtBOTTOMtBOTH(R((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyt createWidgetss0  cCs+tj||tj||jdS(N(Rt__init__tPacktconfigR$(Rtmaster((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyR%7s N(t__name__t __module__RR$tNoneR%(((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyR s  &N(tTkinterRRttesttmainloop(((s</usr/lib64/python2.7/Demo/tkinter/matt/radiobutton-simple.pyts / PK!f 44#matt/window-creation-w-location.pycnu[ ^c@sYddlTddlZdefdYZdefdYZeZejdS(i(t*Nt QuitButtoncBseZdZRS(cOs\|jdsd|ds   PK!(  matt/canvas-mult-item-sel.pynu[from Tkinter import * # allows moving dots with multiple selection. SELECTED_COLOR = "red" UNSELECTED_COLOR = "blue" class Test(Frame): ################################################################### ###### Event callbacks for THE CANVAS (not the stuff drawn on it) ################################################################### def mouseDown(self, event): # see if we're inside a dot. If we are, it # gets tagged as CURRENT for free by tk. if not event.widget.find_withtag(CURRENT): # we clicked outside of all dots on the canvas. unselect all. # re-color everything back to an unselected color self.draw.itemconfig("selected", fill=UNSELECTED_COLOR) # unselect everything self.draw.dtag("selected") else: # mark as "selected" the thing the cursor is under self.draw.addtag("selected", "withtag", CURRENT) # color it as selected self.draw.itemconfig("selected", fill=SELECTED_COLOR) self.lastx = event.x self.lasty = event.y def mouseMove(self, event): self.draw.move("selected", event.x - self.lastx, event.y - self.lasty) self.lastx = event.x self.lasty = event.y def makeNewDot(self): # create a dot, and mark it as current fred = self.draw.create_oval(0, 0, 20, 20, fill=SELECTED_COLOR, tags=CURRENT) # and make it selected self.draw.addtag("selected", "withtag", CURRENT) def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) ################ # make the canvas and bind some behavior to it ################ self.draw = Canvas(self, width="5i", height="5i") Widget.bind(self.draw, "<1>", self.mouseDown) Widget.bind(self.draw, "", self.mouseMove) # and other things..... self.button = Button(self, text="make a new dot", foreground="blue", command=self.makeNewDot) message = ("%s dots are selected and can be dragged.\n" "%s are not selected.\n" "Click in a dot to select it.\n" "Click on empty space to deselect all dots." ) % (SELECTED_COLOR, UNSELECTED_COLOR) self.label = Message(self, width="5i", text=message) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.label.pack(side=BOTTOM, fill=X, expand=1) self.button.pack(side=BOTTOM, fill=X) self.draw.pack(side=LEFT) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() test = Test() test.mainloop() PK!Qmatt/rubber-line-demo-1.pynu[from Tkinter import * class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', background='red', foreground='white', height=3, command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.canvasObject = Canvas(self, width="5i", height="5i") self.canvasObject.pack(side=LEFT) def mouseDown(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object self.startx = self.canvasObject.canvasx(event.x) self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object x = self.canvasObject.canvasx(event.x) y = self.canvasObject.canvasy(event.y) if (self.startx != event.x) and (self.starty != event.y) : self.canvasObject.delete(self.rubberbandLine) self.rubberbandLine = self.canvasObject.create_line( self.startx, self.starty, x, y) # this flushes the output, making sure that # the rectangle makes it to the screen # before the next event is handled self.update_idletasks() def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() # this is a "tagOrId" for the rectangle we draw on the canvas self.rubberbandLine = None Widget.bind(self.canvasObject, "", self.mouseDown) Widget.bind(self.canvasObject, "", self.mouseMotion) test = Test() test.mainloop() PK!R۩matt/menu-simple.pyonu[ ^c@sddlTdZdZdZdZeZeededdZ e j d e eZ eZ e je e ejd ejd ejd S( i(t*cCs dGHdS(Nsopening new file((((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pytnew_file$scCs dGHdS(Nsopening OLD file((((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyt open_file(scCsttdddd}|jdtddt||_|jjdd ddd t|jjdd ddd t|jjdd ddd d |j|d<|S(NttexttFilet underlineitsidetpadxt1mtlabelsNew...tcommandsOpen...tQuittexittmenu( t MenubuttontmBartpacktLEFTtMenuR t add_commandRR(t File_button((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyt makeFileMenu,s cCsttdddd}|jdtddt||_|jjdd d |jjd d t|jj d d |jj d d|jj d d|j|d<|S(NRtEditRiRRRR R tUndoitstatetCuttCopytPasteR ( RRRRRR taddt entryconfigtDISABLEDR(t Edit_button((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyt makeEditMenuFs trelieft borderwidthitfills menu demotpackerN(tTkinterRRRR tTktroottFrametRAISEDRRtXRRt tk_menuBarttitleticonnametmainloop(((s5/usr/lib64/python2.7/Demo/tkinter/matt/menu-simple.pyts #         PK! 4+matt/two-radio-groups.pyonu[ ^c@sddlTdZdZdZeZeededdZej de e Z e Zee ZeeZejeeeed d d d d eZej deejdejdejdS(i(t*cCsttdddd}|jdtddt||_|jjdd d |d d |jjd idd6|d 6dd 6|jjd idd6|d 6dd 6|jd|j|d<|S(NttextsPolitical Partyt underlineitsidetpadxt2mtlabelt Republicantvariabletvalueit radiobuttontDemocratit Libertarianitmenu( t MenubuttontmBartpacktLEFTtMenuR tadd_radiobuttontaddtset(tvartRadiobutton_button((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pytmakePoliticalPartiess      cCsttdddd}|jdtddt||_|jjdd d |d d |jjdd d |d d |jjdd d |d d |jd |j|d<|S(NRtFlavorsRiRRRRt StrawberryRR t Chocolates Rocky RoadR (RRRRRR RR(RR((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pyt makeFlavors2s      cCs#dGtjGHdGtjGHHdS(Nsparty iss flavor is(tpartytgettflavor(((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pyt printStuffMstrelieft borderwidthitfillRsprint party and flavort foregroundtredtcommandRs menu demoN(tTkinterRRR tTktroottFrametRAISEDRRtXtIntVarRt StringVarRRtRadiobutton_button2t tk_menuBartButtontbtTOPttitleticonnametmainloop(((s:/usr/lib64/python2.7/Demo/tkinter/matt/two-radio-groups.pyts"            PK!#Umatt/entry-simple.pynu[from Tkinter import * import string # This program shows how to use a simple type-in box class App(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.entrythingy = Entry() self.entrythingy.pack() # and here we get a callback when the user hits return. we could # make the key that triggers the callback anything we wanted to. # other typical options might be or (for anything) self.entrythingy.bind('', self.print_contents) def print_contents(self, event): print "hi. contents of entry is now ---->", self.entrythingy.get() root = App() root.master.title("Foo") root.mainloop() PK!$&$&ttk/ttkcalendar.pycnu[ ^c@s{dZddlZddlZddlZddlZdZdejfdYZdZe dkrwendS(sQ Simple calendar using ttk Treeview together with calendar and datetime classes. iNcCs-|dkrtj|Stj||SdS(N(tNonetcalendart TextCalendartLocaleTextCalendar(tlocaletfwday((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt get_calendar s  tCalendarcBseZejjZejjZddZdZdZdZ dZ dZ dZ dZ dZd Zd Zd Zd Zed ZRS(c KsY|jdtj}|jd|jjj}|jd|jjj}|jdd}|jdd}|jdd}|j||d |_d|_ t j j |||t |||_|j|j|j|j||gtd D]!} |jjd d d d ^q |_|j|jjd|jdS(s WIDGET-SPECIFIC OPTIONS locale, firstweekday, year, month, selectbackground, selectforeground t firstweekdaytyeartmonthRtselectbackgrounds#ecffc4tselectforegrounds#05640eiittendtvaluessN(tpopRtMONDAYtdatetimetnowR R Rt_datet _selectiontttktFramet__init__Rt_calt_Calendar__setup_stylest_Calendar__place_widgetst_Calendar__config_calendart_Calendar__setup_selectiontranget _calendartinsertt_itemst_build_calendartbindt_Calendar__minsize( tselftmastertkwRR R Rtsel_bgtsel_fgt_((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRs$    4 cCs|dkrtd|n]|dkr;||jdTss L.TButtontlefts R.TButtontright(RtStyleR&tlayout(R%tstylet arrow_layout((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__setup_stylesQs c Cs&tj|}tj|ddd|j}tj|ddd|j}tj|dddd|_tjd d d d d d|_|j d|dddddd|j d||jj d|dddddd|j d|dddd|jj d|dddddddS(NR@s L.TButtontcommands R.TButtontwidthitanchortcentertshowR t selectmodetnonetheightitin_tsidettoptpadyitcolumnitrowitpadxi itexpandR3tbothtbottom( RRtButtont _prev_montht _next_monthtLabelt_headertTreeviewRtpacktgrid(R%thframetlbtntrbtn((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__place_widgetsZs!"%c s|jjdj}||jd<|jjddd|jjddd|d dtjtfd |D}x0|D](}|jj |d |d |d dqWdS(NitcolumnstheaderR+tgrey90R RRttagc3s|]}j|VqdS(N(tmeasure(t.0tcol(tfont(s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pys qsRDtminwidthREte( RtformatweekheadertsplitRt tag_configureR ttkFonttFonttmaxRO(R%tcolstmaxwidthRg((Rhs4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__config_calendarjs   cstj|_tj|jd|dddd|_jddd|dd_j dfd |jj d fd |jj d|j dS( NR+t borderwidthithighlightthicknessR3REtwscs jS(N(t place_forget(tevt(tcanvas(s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR;|R s cs jS(N(Rw(Rx(Ry(s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR;}R ( RnRot_fonttTkintertCanvasRR.t create_textR0R#t_pressed(R%R(R)((Rys4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__setup_selectionvs!cCsN|jjjjd\}}||jd }|jjj||dS(Ntxt+(RR&tgeometryRltindextminsize(R%RxRDRJ((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt __minsizes!c Cs|jj|jj}}|jj||d}|j|jd<|jj||}x~t|j D]m\}}|t |kr||ng}g|D]}|rd|nd^q} |j j |d| qiWdS(NiR0s%02dR R( RR R RtformatmonthnamettitleRYtmonthdayscalendart enumerateR!tlenRR,( R%R R RbtcaltindxR,tweektdaytfmt_week((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR"s")c Cs|\}}}}|jj|}|j}|jd|d||j|j|||dd|j|jd||jd|jd|d|d S( s%Configure canvas for a new selection.RDRJiiR0RKRtyN( RzReR.t configuretcoordsR0R/tplaceR( R%R0tbboxRRRDRJttextwRy((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt_show_selections "c Cs|j|j|j}}}|j|}|j|}| sQ||jkrUdS|j|d}t|sxdS|t|dd}|sdS|j ||} | sdSd|}|||f|_ |j || dS(s"Clicked somewhere in the calendar.NRis%02d( RRtwidgett identify_rowtidentify_columnR!R,RtintRRR( R%RxRRRR,ROt item_valuesR0R((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR~s"  cCs[|jj|j|jdd|_|j|jj|jjd|_|jdS(s,Updated calendar to show the previous month.tdaysiN(R.RwRt timedeltaRR R R"(R%((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRVs $cCs|jj|jj|jj}}|j|jdtj||dd|_|j|jj|jjd|_|j dS(s'Update calendar to show the next month.RiN( R.RwRR R RRt monthrangeRR"(R%R R ((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRWs  !$cCsF|js dS|jj|jj}}|j||t|jdS(s9Return a datetime representing the current selected date.iN(RRRR R RR(R%R R ((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt selections N(t__name__t __module__RRRRRR1R7RRRRR$R"RR~RVRWtpropertyR(((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRs    %       cCsddl}tj}|jdtdtj}|jddddd|jkrxt j }|j d n|j dS( Nis Ttk CalendarRRRiR3RStwintclam( tsysR{tTkRRRtSUNDAYR[tplatformRR>t theme_usetmainloop(RtroottttkcalR@((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyttests    t__main__( t__doc__RR{RnRRRRRR(((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyts      PK![ttk/mac_searchentry.pynu["""Mac style search widget Translated from Tcl code by Schelte Bron, http://wiki.tcl.tk/18188 """ import Tkinter import ttk root = Tkinter.Tk() data = """ R0lGODlhKgAaAOfnAFdZVllbWFpcWVtdWlxeW11fXF9hXmBiX2ZnZWhpZ2lraGxua25wbXJ0 cXR2c3V3dHZ4dXh6d3x+e31/fH6AfYSGg4eJhoiKh4qMiYuNio2PjHmUqnqVq3yXrZGTkJKU kX+asJSWk32cuJWXlIGcs5aYlX6euZeZloOetZial4SftpqbmIWgt4GhvYahuIKivpudmYei uYOjv5yem4ijuoSkwIWlwYmlu56gnYamwp+hnoenw4unvaCin4ioxJCnuZykrImpxZmlsoaq zI2pv6KkoZGouoqqxpqms4erzaOloo6qwYurx5Kqu5untIiszqSmo5CrwoysyJeqtpOrvJyo tZGsw42typSsvaaopZKtxJWtvp6qt4+uy6epppOuxZCvzKiqp5quuZSvxoyx06mrqJWwx42y 1JKxzpmwwaqsqZaxyI6z1ZqxwqutqpOzz4+01qyuq56yvpizypS00Jm0y5W10Zq1zJa20rCy rpu3zqizwbGzr6C3yZy4z7K0saG4yp250LO1sqK5y5660Z+70qO7zKy4xaC806S8zba4taG9 1KW9zq66x6+7yLi6t6S/1rC8yrm7uLO8xLG9y7q8ubS9xabB2anB07K+zLW+xrO/za7CzrTA zrjAyLXBz77BvbbC0K/G2LjD0bnE0rLK28TGw8bIxcLL07vP28HN28rMycvOyr/T38DU4cnR 2s/RztHT0NLU0cTY5MrW5MvX5dHX2c3Z59bY1dPb5Nbb3dLe7Nvd2t3f3NXh797g3d3j5dnl 9OPl4eTm4+Ln6tzo9uXn5Obo5eDp8efp5uHq8uXq7ejq5+nr6OPs9Ovu6unu8O3v6+vw8+7w 7ezx9O/x7vDy7/Hz8O/19/P18vT38/L3+fb49Pf59vX6/fj69/b7/vn7+Pr8+ff9//v9+vz/ +/7//P////////////////////////////////////////////////////////////////// /////////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJZAD/ACwC AAIAKAAWAAAI/gD/CRz4bwUGCg8eQFjIsGHDBw4iTLAQgqBFgisuePCiyJOpUyBDihRpypMi Lx8qaLhIMIyGFZ5sAUsmjZrNmzhzWpO2DJgtTysqfGDpxoMbW8ekeQsXzty4p1CjRjUXrps3 asJsuclQ4uKKSbamMR3n1JzZs2jRkh1HzuxVXX8y4CDYAwqua+DInVrRwMGJU2kDp31KThy1 XGWGDlxhi1rTPAUICBBAoEAesoIzn6Vm68MKgVAUHftmzhOCBCtQwQKSoABgzZnJdSMmyIPA FbCotdUQAIhNa9B6DPCAGbZac+SowVIMRVe4pwkA4GpqDlwuAAmMZx4nTtfnf1mO5JEDNy46 MHJkxQEDgKC49rPjwC0bqGaZuOoZAKjBPE4NgAzUvYcWOc0QZF91imAnCDHJ5JFAAJN0I2Ba 4iRDUC/gOEVNDwIUcEABCAgAAATUTIgWOMBYRFp80ghiAQIIVAAEAwJIYI2JZnUji0XSYAYO NcsQA8wy0hCTwAASXGOiONFcxAtpTokTHznfiLMNMAkcAMuE43jDC0vLeGOWe2R5o4sn1LgH GzkWsvTPMgEOaA433Ag4TjjMuDkQMNi0tZ12sqWoJ0HATMPNffAZZ6U0wLAyqJ62RGoLLrhI aqmlpzwaEAAh+QQJZAD/ACwAAAAAKgAaAAAI/gD/CRw40JEhQoEC+fGjcOHCMRAjRkxDsKLF f5YcAcID582ZjyBDJhmZZIjJIUySEDHiBMhFghrtdNnRAgSHmzhz6sTZQcSLITx+CHn5bxSk Nz5MCMGy55CjTVCjbuJEtSrVQ3uwqDBRQwrFi476SHHxow8qXcemVbPGtm21t3CnTaP27Jgu VHtuiIjBsuImQkRiiEEFTNo2cOTMKV7MuLE5cN68QUOGSgwKG1EqJqJDY8+rZt8UjxtNunTj cY3DgZOWS46KIFgGjiI0ZIsqaqNNjWjgYMUpx8Adc3v2aosNMAI1DbqyI9WycOb4IAggQEAB A3lQBxet/TG4cMpI/tHwYeSfIzxM0uTKNs7UgAQrYL1akaDA7+3bueVqY4NJlUhIcQLNYx8E AIQ01mwjTQ8DeNAdfouNA8440GBCQxJY3MEGD6p4Y844CQCAizcSgpMLAAlAuJ03qOyQRBR3 nEHEK+BMGKIui4kDDAAIPKiiYuSYSMQQRCDCxhiziPMYBgDkEaEaAGQA3Y+MjUPOLFoMoUUh cKxRC4ngeILiH8Qkk0cCAUzSDZWpzbLEE1EwggcYqWCj2DNADFDAAQUgIAAAEFDDJmPYqNJF F1s4cscTmCDjDTjdSPOHBQggUAEQDAgggTWDPoYMJkFoUdRmddyyjWLeULMMMcAsIw0x4wkM IME1g25zyxpHxFYUHmyIggw4H4ojITnfiLMNMAkcAAub4BQjihRdDGTJHmvc4Qo1wD6Imje6 eILbj+BQ4wqu5Q3ECSJ0FOKKMtv4mBg33Pw4zjbKuBIIE1xYpIkhdQQiyi7OtAucj6dt48wu otQhBRa6VvSJIRwhIkotvgRTzMUYZ6xxMcj4QkspeKDxxRhEmUfIHWjAgQcijEDissuXvCyz zH7Q8YQURxDhUsn/bCInR3AELfTQZBRt9BBJkCGFFVhMwTNBlnBCSCGEIJQQIAklZMXWRBAR RRRWENHwRQEBADs=""" s1 = Tkinter.PhotoImage("search1", data=data, format="gif -index 0") s2 = Tkinter.PhotoImage("search2", data=data, format="gif -index 1") style = ttk.Style() style.element_create("Search.field", "image", "search1", ("focus", "search2"), border=[22, 7, 14], sticky="ew") style.layout("Search.entry", [ ("Search.field", {"sticky": "nswe", "border": 1, "children": [("Entry.padding", {"sticky": "nswe", "children": [("Entry.textarea", {"sticky": "nswe"})] })] })] ) style.configure("Search.entry", background="#b2b2b2") root.configure(background="#b2b2b2") e1 = ttk.Entry(style="Search.entry", width=20) e2 = ttk.Entry(style="Search.entry", width=20) e1.grid(padx=10, pady=10) e2.grid(padx=10, pady=10) root.mainloop() PK!|&C]ttk/combo_themes.pycnu[ ^c@sNdZddlZdejfdYZdZedkrJendS(sTtk Theme Selector. Although it is a theme selector, you won't notice many changes since there is only a combobox and a frame around. iNtAppcBs#eZdZdZdZRS(cCs-tjj|tj|_|jdS(N(tttktFramet__init__tStyletstylet_setup_widgets(tself((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyR scCs5|jjr1|jj}|jj|ndS(N(twidgettcurrenttgetRt theme_use(Rteventtnewtheme((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyt _change_themescCst|jj}|jddtj|d|dddd}|j|d|jd|j|j d d |j d d d d dS(Nis Pick a themetvalueststatetreadonlytheightis<>tfilltxtbothtexpandi( tlistRt theme_namestinsertRtComboboxtsettbindRtpack(Rtthemest themes_combo((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyRs (t__name__t __module__RRR(((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyRs  cCs't}|jjd|jdS(Ns Ttk Combobox(Rtmasterttitletmainloop(tapp((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pytmain(s t__main__(t__doc__RRRR&R (((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyts    PK!|&C]ttk/combo_themes.pyonu[ ^c@sNdZddlZdejfdYZdZedkrJendS(sTtk Theme Selector. Although it is a theme selector, you won't notice many changes since there is only a combobox and a frame around. iNtAppcBs#eZdZdZdZRS(cCs-tjj|tj|_|jdS(N(tttktFramet__init__tStyletstylet_setup_widgets(tself((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyR scCs5|jjr1|jj}|jj|ndS(N(twidgettcurrenttgetRt theme_use(Rteventtnewtheme((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyt _change_themescCst|jj}|jddtj|d|dddd}|j|d|jd|j|j d d |j d d d d dS(Nis Pick a themetvalueststatetreadonlytheightis<>tfilltxtbothtexpandi( tlistRt theme_namestinsertRtComboboxtsettbindRtpack(Rtthemest themes_combo((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyRs (t__name__t __module__RRR(((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyRs  cCs't}|jjd|jdS(Ns Ttk Combobox(Rtmasterttitletmainloop(tapp((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pytmain(s t__main__(t__doc__RRRR&R (((s5/usr/lib64/python2.7/Demo/tkinter/ttk/combo_themes.pyts    PK!Rh|@@ttk/listbox_scrollcmd.pyonu[ ^c@sWdZddlZddlZejZejddZejdddddd ejd ej d d Z e j ed s"     PK!xa##ttk/roundframe.pyonu[ ^c @sdZddlZddlZejZejdddZejdddZejZ e j dd dd%d d d de j ddidd 6fge j dddej ddddZejddej ddddZejddddejeddZejddejddejddejeddd d!d"dZejddddejdd#ejdd$ejdS(&shTtk Frame with rounded corners. Based on an example by Bryan Oakley, found at: http://wiki.tcl.tk/20152iNtframeFocusBordertdatas R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI 5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/ /wD//2gAAGEAABYAAAAAAAC0/AHj5AASEgAAAAA01gBkWACDTAB8AFf43PT3 5IASEnwAAOAYd+PuMBKQTwB8AGgAEGG35RaSEgB8AOj/NOL/ZBL/gwD/fMkc q4sA5UGpEn4AAIg02xBk/0eD/358fx/4iADk5QASEgAAAALnHABkAACDqQB8 AMyINARkZA2DgwB8fBABHL0AAEUAqQAAAIAxKOMAPxIwAAAAAIScAOPxABIS AAAAAIIAnQwA/0IAR3cAACwAAAAAQABAAAAI/wA/CBxIsKDBgwgTKlzIsKFD gxceNnxAsaLFixgzUrzAsWPFCw8kDgy5EeQDkBxPolypsmXKlx1hXnS48UEH CwooMCDAgIJOCjx99gz6k+jQnkWR9lRgYYDJkAk/DlAgIMICZlizat3KtatX rAsiCNDgtCJClQkoFMgqsu3ArBkoZDgA8uDJAwk4bGDmtm9BZgcYzK078m4D Cgf4+l0skNkGCg3oUhR4d4GCDIoZM2ZWQMECyZQvLMggIbPmzQIyfCZ5YcME AwFMn/bLLIKBCRtMHljQQcDV2ZqZTRDQYfWFAwMqUJANvC8zBhUWbDi5YUAB Bsybt2VGoUKH3AcmdP+Im127xOcJih+oXsEDdvOLuQfIMGBD9QwBlsOnzcBD hfrsuVfefgzJR599A+CnH4Hb9fcfgu29x6BIBgKYYH4DTojQc/5ZGGGGGhpU IYIKghgiQRw+GKCEJxZIwXwWlthiQyl6KOCMLsJIIoY4LlQjhDf2mNCI9/Eo 5IYO2sjikX+9eGCRCzL5V5JALillY07GaOSVb1G5ookzEnlhlFx+8OOXZb6V 5Y5kcnlmckGmKaaMaZrpJZxWXjnnlmW++WGdZq5ZXQEetKmnlxPgl6eUYhJq KKOI0imnoNbF2ScFHQJJwW99TsBAAAVYWEAAHEQAZoi1cQDqAAeEV0EACpT/ JqcACgRQAW6uNWCbYKcyyEwGDBgQwa2tTlBBAhYIQMFejC5AgQAWJNDABK3y loEDEjCgV6/aOcYBAwp4kIF6rVkXgAEc8IQZVifCBRQHGqya23HGIpsTBgSU OsFX/PbrVVjpYsCABA4kQCxHu11ogAQUIOAwATpBLDFQFE9sccUYS0wAxD5h 4DACFEggbAHk3jVBA/gtTIHHEADg8sswxyzzzDQDAAEECGAQsgHiTisZResN gLIHBijwLQEYePzx0kw37fTSSjuMr7ZMzfcgYZUZi58DGsTKwbdgayt22GSP bXbYY3MggQIaONDzAJ8R9kFlQheQQAAOWGCAARrwdt23Bn8H7vfggBMueOEG WOBBAAkU0EB9oBGUdXIFZJBABAEEsPjmmnfO+eeeh/55BBEk0Ph/E8Q9meQq bbDABAN00EADFRRQ++2254777rr3jrvjFTTQwQCpz7u6QRut5/oEzA/g/PPQ Ry/99NIz//oGrZpUUEAAOw==t frameBorders R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI 5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/ /wD//2gAAGEAABYAAAAAAAC0/AHj5AASEgAAAAA01gBkWACDTAB8AFf43PT3 5IASEnwAAOAYd+PuMBKQTwB8AGgAEGG35RaSEgB8AOj/NOL/ZBL/gwD/fMkc q4sA5UGpEn4AAIg02xBk/0eD/358fx/4iADk5QASEgAAAALnHABkAACDqQB8 AMyINARkZA2DgwB8fBABHL0AAEUAqQAAAIAxKOMAPxIwAAAAAIScAOPxABIS AAAAAIIAnQwA/0IAR3cAACwAAAAAQABAAAAI/wA/CBxIsKDBgwgTKlzIsKFD gxceNnxAsaLFixgzUrzAsWPFCw8kDgy5EeQDkBxPolypsmXKlx1hXnS48UEH CwooMCDAgIJOCjx99gz6k+jQnkWR9lRgYYDJkAk/DlAgIMICkVgHLoggQIPT ighVJqBQIKvZghkoZDgA8uDJAwk4bDhLd+ABBmvbjnzbgMKBuoA/bKDQgC1F gW8XKMgQOHABBQsMI76wIIOExo0FZIhM8sKGCQYCYA4cwcCEDSYPLOgg4Oro uhMEdOB84cCAChReB2ZQYcGGkxsGFGCgGzCFCh1QH5jQIW3xugwSzD4QvIIH 4s/PUgiQYcCG4BkC5P/ObpaBhwreq18nb3Z79+8Dwo9nL9I8evjWsdOX6D59 fPH71Xeef/kFyB93/sln4EP2Ebjegg31B5+CEDLUIH4PVqiQhOABqKFCF6qn 34cHcfjffCQaFOJtGaZYkIkUuljQigXK+CKCE3po40A0trgjjDru+EGPI/6I Y4co7kikkAMBmaSNSzL5gZNSDjkghkXaaGIBHjwpY4gThJeljFt2WSWYMQpZ 5pguUnClehS4tuMEDARQgH8FBMBBBExGwIGdAxywXAUBKHCZkAIoEEAFp33W QGl47ZgBAwZEwKigE1SQgAUCUDCXiwtQIIAFCTQwgaCrZeCABAzIleIGHDD/ oIAHGUznmXABGMABT4xpmBYBHGgAKGq1ZbppThgAG8EEAW61KwYMSOBAApdy pNp/BkhAAQLcEqCTt+ACJW645I5rLrgEeOsTBtwiQIEElRZg61sTNBBethSw CwEA/Pbr778ABywwABBAgAAG7xpAq6mGUUTdAPZ6YIACsRKAAbvtZqzxxhxn jDG3ybbKFHf36ZVYpuE5oIGhHMTqcqswvyxzzDS/HDMHEiiggQMLDxCZXh8k BnEBCQTggAUGGKCB0ktr0PTTTEfttNRQT22ABR4EkEABDXgnGUEn31ZABglE EEAAWaeN9tpqt832221HEEECW6M3wc+Hga3SBgtMODBABw00UEEBgxdO+OGG J4744oZzXUEDHQxwN7F5G7QRdXxPoPkAnHfu+eeghw665n1vIKhJBQUEADs=t RoundedFrametimagetfocustborderitstickytnsewtTEntryt borderwidthitstyletpaddingi tfilltxtbothtexpandittexttTests cCstjdgS(NR(tframetstate(tevt((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pytgts cCstjdgS(Ns!focus(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyRhRtbgtwhitethighlightthicknesscCstjdgS(NR(tframe2R(R((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyRlRcCstjdgS(Ns!focus(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyRmR(RR(t__doc__tTkintertttktTktroott PhotoImagetimg1timg2tStyleR telement_createtlayoutt configuretFrameRtpackRtEntrytentrytbindtTextRtmainloop(((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyts2    &  $   !PK!/ QQttk/combo_themes.pynu["""Ttk Theme Selector. Although it is a theme selector, you won't notice many changes since there is only a combobox and a frame around. """ import ttk class App(ttk.Frame): def __init__(self): ttk.Frame.__init__(self) self.style = ttk.Style() self._setup_widgets() def _change_theme(self, event): if event.widget.current(): # value #0 is not a theme newtheme = event.widget.get() # change to the new theme and refresh all the widgets self.style.theme_use(newtheme) def _setup_widgets(self): themes = list(self.style.theme_names()) themes.insert(0, "Pick a theme") # Create a readonly Combobox which will display 4 values at max, # which will cause it to create a scrollbar if there are more # than 4 values in total. themes_combo = ttk.Combobox(self, values=themes, state="readonly", height=4) themes_combo.set(themes[0]) # sets the combobox value to "Pick a theme" # Combobox widget generates a <> virtual event # when the user selects an element. This event is generated after # the listbox is unposted (after you select an item, the combobox's # listbox disappears, then it is said that listbox is now unposted). themes_combo.bind("<>", self._change_theme) themes_combo.pack(fill='x') self.pack(fill='both', expand=1) def main(): app = App() app.master.title("Ttk Combobox") app.mainloop() if __name__ == "__main__": main() PK!Rh|@@ttk/listbox_scrollcmd.pycnu[ ^c@sWdZddlZddlZejZejddZejdddddd ejd ej d d Z e j ed s"     PK!8~ ~ ttk/ttkcalendar.pynu[""" Simple calendar using ttk Treeview together with calendar and datetime classes. """ import calendar import Tkinter import tkFont import ttk def get_calendar(locale, fwday): # instantiate proper calendar class if locale is None: return calendar.TextCalendar(fwday) else: return calendar.LocaleTextCalendar(fwday, locale) class Calendar(ttk.Frame): # XXX ToDo: cget and configure datetime = calendar.datetime.datetime timedelta = calendar.datetime.timedelta def __init__(self, master=None, **kw): """ WIDGET-SPECIFIC OPTIONS locale, firstweekday, year, month, selectbackground, selectforeground """ # remove custom options from kw before initializating ttk.Frame fwday = kw.pop('firstweekday', calendar.MONDAY) year = kw.pop('year', self.datetime.now().year) month = kw.pop('month', self.datetime.now().month) locale = kw.pop('locale', None) sel_bg = kw.pop('selectbackground', '#ecffc4') sel_fg = kw.pop('selectforeground', '#05640e') self._date = self.datetime(year, month, 1) self._selection = None # no date selected ttk.Frame.__init__(self, master, **kw) self._cal = get_calendar(locale, fwday) self.__setup_styles() # creates custom styles self.__place_widgets() # pack/grid used widgets self.__config_calendar() # adjust calendar columns and setup tags # configure a canvas, and proper bindings, for selecting dates self.__setup_selection(sel_bg, sel_fg) # store items ids, used for insertion later self._items = [self._calendar.insert('', 'end', values='') for _ in range(6)] # insert dates in the currently empty calendar self._build_calendar() # set the minimal size for the widget self._calendar.bind('', self.__minsize) def __setitem__(self, item, value): if item in ('year', 'month'): raise AttributeError("attribute '%s' is not writeable" % item) elif item == 'selectbackground': self._canvas['background'] = value elif item == 'selectforeground': self._canvas.itemconfigure(self._canvas.text, item=value) else: ttk.Frame.__setitem__(self, item, value) def __getitem__(self, item): if item in ('year', 'month'): return getattr(self._date, item) elif item == 'selectbackground': return self._canvas['background'] elif item == 'selectforeground': return self._canvas.itemcget(self._canvas.text, 'fill') else: r = ttk.tclobjs_to_py({item: ttk.Frame.__getitem__(self, item)}) return r[item] def __setup_styles(self): # custom ttk styles style = ttk.Style(self.master) arrow_layout = lambda dir: ( [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})] ) style.layout('L.TButton', arrow_layout('left')) style.layout('R.TButton', arrow_layout('right')) def __place_widgets(self): # header frame and its widgets hframe = ttk.Frame(self) lbtn = ttk.Button(hframe, style='L.TButton', command=self._prev_month) rbtn = ttk.Button(hframe, style='R.TButton', command=self._next_month) self._header = ttk.Label(hframe, width=15, anchor='center') # the calendar self._calendar = ttk.Treeview(show='', selectmode='none', height=7) # pack the widgets hframe.pack(in_=self, side='top', pady=4, anchor='center') lbtn.grid(in_=hframe) self._header.grid(in_=hframe, column=1, row=0, padx=12) rbtn.grid(in_=hframe, column=2, row=0) self._calendar.pack(in_=self, expand=1, fill='both', side='bottom') def __config_calendar(self): cols = self._cal.formatweekheader(3).split() self._calendar['columns'] = cols self._calendar.tag_configure('header', background='grey90') self._calendar.insert('', 'end', values=cols, tag='header') # adjust its columns width font = tkFont.Font() maxwidth = max(font.measure(col) for col in cols) for col in cols: self._calendar.column(col, width=maxwidth, minwidth=maxwidth, anchor='e') def __setup_selection(self, sel_bg, sel_fg): self._font = tkFont.Font() self._canvas = canvas = Tkinter.Canvas(self._calendar, background=sel_bg, borderwidth=0, highlightthickness=0) canvas.text = canvas.create_text(0, 0, fill=sel_fg, anchor='w') canvas.bind('', lambda evt: canvas.place_forget()) self._calendar.bind('', lambda evt: canvas.place_forget()) self._calendar.bind('', self._pressed) def __minsize(self, evt): width, height = self._calendar.master.geometry().split('x') height = height[:height.index('+')] self._calendar.master.minsize(width, height) def _build_calendar(self): year, month = self._date.year, self._date.month # update header text (Month, YEAR) header = self._cal.formatmonthname(year, month, 0) self._header['text'] = header.title() # update calendar shown dates cal = self._cal.monthdayscalendar(year, month) for indx, item in enumerate(self._items): week = cal[indx] if indx < len(cal) else [] fmt_week = [('%02d' % day) if day else '' for day in week] self._calendar.item(item, values=fmt_week) def _show_selection(self, text, bbox): """Configure canvas for a new selection.""" x, y, width, height = bbox textw = self._font.measure(text) canvas = self._canvas canvas.configure(width=width, height=height) canvas.coords(canvas.text, width - textw, height / 2 - 1) canvas.itemconfigure(canvas.text, text=text) canvas.place(in_=self._calendar, x=x, y=y) # Callbacks def _pressed(self, evt): """Clicked somewhere in the calendar.""" x, y, widget = evt.x, evt.y, evt.widget item = widget.identify_row(y) column = widget.identify_column(x) if not column or not item in self._items: # clicked in the weekdays row or just outside the columns return item_values = widget.item(item)['values'] if not len(item_values): # row is empty for this month return text = item_values[int(column[1]) - 1] if not text: # date is empty return bbox = widget.bbox(item, column) if not bbox: # calendar not visible yet return # update and then show selection text = '%02d' % text self._selection = (text, item, column) self._show_selection(text, bbox) def _prev_month(self): """Updated calendar to show the previous month.""" self._canvas.place_forget() self._date = self._date - self.timedelta(days=1) self._date = self.datetime(self._date.year, self._date.month, 1) self._build_calendar() # reconstruct calendar def _next_month(self): """Update calendar to show the next month.""" self._canvas.place_forget() year, month = self._date.year, self._date.month self._date = self._date + self.timedelta( days=calendar.monthrange(year, month)[1] + 1) self._date = self.datetime(self._date.year, self._date.month, 1) self._build_calendar() # reconstruct calendar # Properties @property def selection(self): """Return a datetime representing the current selected date.""" if not self._selection: return None year, month = self._date.year, self._date.month return self.datetime(year, month, int(self._selection[0])) def test(): import sys root = Tkinter.Tk() root.title('Ttk Calendar') ttkcal = Calendar(firstweekday=calendar.SUNDAY) ttkcal.pack(expand=1, fill='both') if 'win' not in sys.platform: style = ttk.Style() style.theme_use('clam') root.mainloop() if __name__ == '__main__': test() PK!Ottk/dirbrowser.pyonu[ ^c @sdZddlZddlZddlZddlZdZdZdZdZdZ ej Z ej dd Z ej dd Zejd d)ddddddZeje d|dkr>|jn |j|j||dS(s"Hide and show scrollbar as needed.iiN(tfloatt grid_removetgridR (tsbartfirsttlast((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pyt autoscroll9s   torienttverticalt horizontaltcolumnsRRR tdisplaycolumnstyscrollcommandcCstt||S(N(R5tvsb(tftl((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pytHR%txscrollcommandcCstt||S(N(R5thsb(R=R>((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pyR?IR%tcommands#0RsDirectory Structuretanchortws File Sizetstretchitwidthids<>stcolumntrowtstickytnsweitnstewtweight(RRR (t__doc__RRtTkintertttkR$R(R,R.R5tTktroott ScrollbarR<RAtTreeviewRtyviewtxviewtheadingRGtbindR1tgrid_columnconfiguretgrid_rowconfiguretmainloop(((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pyts:            PK!#ggttk/treeview_multicolumn.pyonu[ ^c@sdZddlZddlZddlZd6Zd7d8d9d:d;d<d=d>d?d@dAdBdCdDdEgZd1Zd2efd3YZd4Z e d5kre ndS(FsCDemo based on the demo mclist included with tk source distribution.iNtcountrytcapitaltcurrencyt Argentinas Buenos AirestARSt AustraliatCanberratAUDtBraziltBraziliatBRLtCanadatOttawatCADtChinatBeijingtCNYtFrancetParistEURtGermanytBerlintIndias New DelhitINRtItalytRometJapantTokyotJPYtMexicos Mexico CitytMXNtRussiatMoscowtRUBs South AfricatPretoriatZARsUnited KingdomtLondontGBPs United StatessWashington, D.C.tUSDcsgjdD]}j|||f^q}|jdx1t|D]#\}}j|dd|qQWj|d|fddS(s/Sort tree contents when a column is clicked on.ttreverseitcommandcst|t S(N(tsortbytint(tcol(t descendingttree(s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyt%R'N(t get_childrentsettsortt enumeratetmovetheading(R.R,R-tchildtdatatindxtitem((R-R.s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR*s 4 tAppcBs#eZdZdZdZRS(cCs!d|_|j|jdS(N(tNoneR.t_setup_widgetst _build_tree(tself((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyt__init__(s  c Csetjdddddddd$d d }|jd dtj}|jd ddttjdtdd|_tjddd|jj }tjddd|jj }|jj d|j d|j |jj ddddddd||j dd dddd!d||j dddd dd"d||jdd#d |jdd#d dS(%Nt wraplengtht4itjustifytlefttanchortntpaddingi iittextsTtk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which can be configured to display multiple columns of informational data without displaying the tree itself. This is a simple way to build a listbox that has multiple columns. Clicking on the heading for a column will sort the data by that column. You can also change the width of the columns by dragging the boundary between them.tfilltxtbothtexpandtcolumnstshowtheadingstorienttverticalR)t horizontaltyscrollcommandtxscrollcommandtcolumnitrowtstickytnsewtin_itnstewtweight(i ii i(tttktLabeltpacktFrametTruetTreeviewt tree_columnsR.t Scrollbartyviewtxviewt configureR1tgridtgrid_columnconfiguretgrid_rowconfigure(R>tmsgt containertvsbthsb((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR<-s  %""c s xgtD]_}jj|d|jd|fdjj|dtjj|jqWxtD]}jj ddd|xnt |D]`\}}tjj|}jjt|dd|krjjt|d|qqWqqWdS(NRGR)cstj|dS(Ni(R*R.(tc(R>(s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR/MR'twidthR'tendtvalues( RbR.R5ttitleRTttkFonttFonttmeasuret tree_datatinsertR3R;(R>R,R9R8tvaltilen((R>s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR=Js / "(t__name__t __module__R?R<R=(((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR:'s  cCstj}|jd|jdddl}y|jdWn*tk roddl}|jdnXt }|j dS(NsMulti-Column Listtmclistis~/tile-themes/plastik/plastiks'plastik theme being used without images( tTkintertTktwm_titlet wm_iconnamet plastik_themetinstallt ExceptiontwarningstwarnR:tmainloop(trootRRtapp((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pytmain[s       t__main__(RRR(Rs Buenos AiresR(RRR(RR R (R R R (RRR(RRR(RRR(Rs New DelhiR(RRR(RRR(Rs Mexico CityR(RR R!(s South AfricaR"R#(sUnited KingdomR$R%(s United StatessWashington, D.C.R&( t__doc__R}RsR\RbRvR*tobjectR:RRz(((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyts0     4  PK!-ttk/listbox_scrollcmd.pynu["""Sample taken from: http://www.tkdocs.com/tutorial/morewidgets.html and converted to Python, mainly to demonstrate xscrollcommand option. grid [tk::listbox .l -yscrollcommand ".s set" -height 5] -column 0 -row 0 -sticky nwes grid [ttk::scrollbar .s -command ".l yview" -orient vertical] -column 1 -row 0 -sticky ns grid [ttk::label .stat -text "Status message here" -anchor w] -column 0 -row 1 -sticky we grid [ttk::sizegrip .sz] -column 1 -row 1 -sticky se grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1 for {set i 0} {$i<100} {incr i} { .l insert end "Line $i of 100" } """ import Tkinter import ttk root = Tkinter.Tk() l = Tkinter.Listbox(height=5) l.grid(column=0, row=0, sticky='nwes') s = ttk.Scrollbar(command=l.yview, orient='vertical') l['yscrollcommand'] = s.set s.grid(column=1, row=0, sticky="ns") stat = ttk.Label(text="Status message here", anchor='w') stat.grid(column=0, row=1, sticky='we') sz = ttk.Sizegrip() sz.grid(column=1, row=1, sticky='se') root.grid_columnconfigure(0, weight=1) root.grid_rowconfigure(0, weight=1) for i in range(100): l.insert('end', "Line %d of 100" % i) root.mainloop() PK!>ttk/mac_searchentry.pyonu[ ^c @sdZddlZddlZejZdZejddeddZejddedd Zej Z e j d d dd!d dddgdde j dd idd6dd 6didd6didd6fgd6fgd6fge j dddej ddejddddZejddddZejddd dejddd dejdS("s\Mac style search widget Translated from Tcl code by Schelte Bron, http://wiki.tcl.tk/18188 iNs R0lGODlhKgAaAOfnAFdZVllbWFpcWVtdWlxeW11fXF9hXmBiX2ZnZWhpZ2lraGxua25wbXJ0 cXR2c3V3dHZ4dXh6d3x+e31/fH6AfYSGg4eJhoiKh4qMiYuNio2PjHmUqnqVq3yXrZGTkJKU kX+asJSWk32cuJWXlIGcs5aYlX6euZeZloOetZial4SftpqbmIWgt4GhvYahuIKivpudmYei uYOjv5yem4ijuoSkwIWlwYmlu56gnYamwp+hnoenw4unvaCin4ioxJCnuZykrImpxZmlsoaq zI2pv6KkoZGouoqqxpqms4erzaOloo6qwYurx5Kqu5untIiszqSmo5CrwoysyJeqtpOrvJyo tZGsw42typSsvaaopZKtxJWtvp6qt4+uy6epppOuxZCvzKiqp5quuZSvxoyx06mrqJWwx42y 1JKxzpmwwaqsqZaxyI6z1ZqxwqutqpOzz4+01qyuq56yvpizypS00Jm0y5W10Zq1zJa20rCy rpu3zqizwbGzr6C3yZy4z7K0saG4yp250LO1sqK5y5660Z+70qO7zKy4xaC806S8zba4taG9 1KW9zq66x6+7yLi6t6S/1rC8yrm7uLO8xLG9y7q8ubS9xabB2anB07K+zLW+xrO/za7CzrTA zrjAyLXBz77BvbbC0K/G2LjD0bnE0rLK28TGw8bIxcLL07vP28HN28rMycvOyr/T38DU4cnR 2s/RztHT0NLU0cTY5MrW5MvX5dHX2c3Z59bY1dPb5Nbb3dLe7Nvd2t3f3NXh797g3d3j5dnl 9OPl4eTm4+Ln6tzo9uXn5Obo5eDp8efp5uHq8uXq7ejq5+nr6OPs9Ovu6unu8O3v6+vw8+7w 7ezx9O/x7vDy7/Hz8O/19/P18vT38/L3+fb49Pf59vX6/fj69/b7/vn7+Pr8+ff9//v9+vz/ +/7//P////////////////////////////////////////////////////////////////// /////////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJZAD/ACwC AAIAKAAWAAAI/gD/CRz4bwUGCg8eQFjIsGHDBw4iTLAQgqBFgisuePCiyJOpUyBDihRpypMi Lx8qaLhIMIyGFZ5sAUsmjZrNmzhzWpO2DJgtTysqfGDpxoMbW8ekeQsXzty4p1CjRjUXrps3 asJsuclQ4uKKSbamMR3n1JzZs2jRkh1HzuxVXX8y4CDYAwqua+DInVrRwMGJU2kDp31KThy1 XGWGDlxhi1rTPAUICBBAoEAesoIzn6Vm68MKgVAUHftmzhOCBCtQwQKSoABgzZnJdSMmyIPA FbCotdUQAIhNa9B6DPCAGbZac+SowVIMRVe4pwkA4GpqDlwuAAmMZx4nTtfnf1mO5JEDNy46 MHJkxQEDgKC49rPjwC0bqGaZuOoZAKjBPE4NgAzUvYcWOc0QZF91imAnCDHJ5JFAAJN0I2Ba 4iRDUC/gOEVNDwIUcEABCAgAAATUTIgWOMBYRFp80ghiAQIIVAAEAwJIYI2JZnUji0XSYAYO NcsQA8wy0hCTwAASXGOiONFcxAtpTokTHznfiLMNMAkcAMuE43jDC0vLeGOWe2R5o4sn1LgH GzkWsvTPMgEOaA433Ag4TjjMuDkQMNi0tZ12sqWoJ0HATMPNffAZZ6U0wLAyqJ62RGoLLrhI aqmlpzwaEAAh+QQJZAD/ACwAAAAAKgAaAAAI/gD/CRw40JEhQoEC+fGjcOHCMRAjRkxDsKLF f5YcAcID582ZjyBDJhmZZIjJIUySEDHiBMhFghrtdNnRAgSHmzhz6sTZQcSLITx+CHn5bxSk Nz5MCMGy55CjTVCjbuJEtSrVQ3uwqDBRQwrFi476SHHxow8qXcemVbPGtm21t3CnTaP27Jgu VHtuiIjBsuImQkRiiEEFTNo2cOTMKV7MuLE5cN68QUOGSgwKG1EqJqJDY8+rZt8UjxtNunTj cY3DgZOWS46KIFgGjiI0ZIsqaqNNjWjgYMUpx8Adc3v2aosNMAI1DbqyI9WycOb4IAggQEAB A3lQBxet/TG4cMpI/tHwYeSfIzxM0uTKNs7UgAQrYL1akaDA7+3bueVqY4NJlUhIcQLNYx8E AIQ01mwjTQ8DeNAdfouNA8440GBCQxJY3MEGD6p4Y844CQCAizcSgpMLAAlAuJ03qOyQRBR3 nEHEK+BMGKIui4kDDAAIPKiiYuSYSMQQRCDCxhiziPMYBgDkEaEaAGQA3Y+MjUPOLFoMoUUh cKxRC4ngeILiH8Qkk0cCAUzSDZWpzbLEE1EwggcYqWCj2DNADFDAAQUgIAAAEFDDJmPYqNJF F1s4cscTmCDjDTjdSPOHBQggUAEQDAgggTWDPoYMJkFoUdRmddyyjWLeULMMMcAsIw0x4wkM IME1g25zyxpHxFYUHmyIggw4H4ojITnfiLMNMAkcAAub4BQjihRdDGTJHmvc4Qo1wD6Imje6 eILbj+BQ4wqu5Q3ECSJ0FOKKMtv4mBg33Pw4zjbKuBIIE1xYpIkhdQQiyi7OtAucj6dt48wu otQhBRa6VvSJIRwhIkotvgRTzMUYZ6xxMcj4QkspeKDxxRhEmUfIHWjAgQcijEDissuXvCyz zH7Q8YQURxDhUsn/bCInR3AELfTQZBRt9BBJkCGFFVhMwTNBlnBCSCGEIJQQIAklZMXWRBAR RRRWENHwRQEBADs=tsearch1tdatatformats gif -index 0tsearch2s gif -index 1s Search.fieldtimagetfocustborderiiitstickytews Search.entrytnsweis Entry.paddingsEntry.textareatchildrent backgrounds#b2b2b2tstyletwidthitpadxi tpady(RR(t__doc__tTkintertttktTktrootRt PhotoImagets1ts2tStyleR telement_createtlayoutt configuretEntryte1te2tgridtmainloop(((s8/usr/lib64/python2.7/Demo/tkinter/ttk/mac_searchentry.pyts(   )   +PK!y5Lttk/roundframe.pynu["""Ttk Frame with rounded corners. Based on an example by Bryan Oakley, found at: http://wiki.tcl.tk/20152""" import Tkinter import ttk root = Tkinter.Tk() img1 = Tkinter.PhotoImage("frameFocusBorder", data=""" R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI 5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/ /wD//2gAAGEAABYAAAAAAAC0/AHj5AASEgAAAAA01gBkWACDTAB8AFf43PT3 5IASEnwAAOAYd+PuMBKQTwB8AGgAEGG35RaSEgB8AOj/NOL/ZBL/gwD/fMkc q4sA5UGpEn4AAIg02xBk/0eD/358fx/4iADk5QASEgAAAALnHABkAACDqQB8 AMyINARkZA2DgwB8fBABHL0AAEUAqQAAAIAxKOMAPxIwAAAAAIScAOPxABIS AAAAAIIAnQwA/0IAR3cAACwAAAAAQABAAAAI/wA/CBxIsKDBgwgTKlzIsKFD gxceNnxAsaLFixgzUrzAsWPFCw8kDgy5EeQDkBxPolypsmXKlx1hXnS48UEH CwooMCDAgIJOCjx99gz6k+jQnkWR9lRgYYDJkAk/DlAgIMICZlizat3KtatX rAsiCNDgtCJClQkoFMgqsu3ArBkoZDgA8uDJAwk4bGDmtm9BZgcYzK078m4D Cgf4+l0skNkGCg3oUhR4d4GCDIoZM2ZWQMECyZQvLMggIbPmzQIyfCZ5YcME AwFMn/bLLIKBCRtMHljQQcDV2ZqZTRDQYfWFAwMqUJANvC8zBhUWbDi5YUAB Bsybt2VGoUKH3AcmdP+Im127xOcJih+oXsEDdvOLuQfIMGBD9QwBlsOnzcBD hfrsuVfefgzJR599A+CnH4Hb9fcfgu29x6BIBgKYYH4DTojQc/5ZGGGGGhpU IYIKghgiQRw+GKCEJxZIwXwWlthiQyl6KOCMLsJIIoY4LlQjhDf2mNCI9/Eo 5IYO2sjikX+9eGCRCzL5V5JALillY07GaOSVb1G5ookzEnlhlFx+8OOXZb6V 5Y5kcnlmckGmKaaMaZrpJZxWXjnnlmW++WGdZq5ZXQEetKmnlxPgl6eUYhJq KKOI0imnoNbF2ScFHQJJwW99TsBAAAVYWEAAHEQAZoi1cQDqAAeEV0EACpT/ JqcACgRQAW6uNWCbYKcyyEwGDBgQwa2tTlBBAhYIQMFejC5AgQAWJNDABK3y loEDEjCgV6/aOcYBAwp4kIF6rVkXgAEc8IQZVifCBRQHGqya23HGIpsTBgSU OsFX/PbrVVjpYsCABA4kQCxHu11ogAQUIOAwATpBLDFQFE9sccUYS0wAxD5h 4DACFEggbAHk3jVBA/gtTIHHEADg8sswxyzzzDQDAAEECGAQsgHiTisZResN gLIHBijwLQEYePzx0kw37fTSSjuMr7ZMzfcgYZUZi58DGsTKwbdgayt22GSP bXbYY3MggQIaONDzAJ8R9kFlQheQQAAOWGCAARrwdt23Bn8H7vfggBMueOEG WOBBAAkU0EB9oBGUdXIFZJBABAEEsPjmmnfO+eeeh/55BBEk0Ph/E8Q9meQq bbDABAN00EADFRRQ++2254777rr3jrvjFTTQwQCpz7u6QRut5/oEzA/g/PPQ Ry/99NIz//oGrZpUUEAAOw==""") img2 = Tkinter.PhotoImage("frameBorder", data=""" R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI 5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/ /wD//2gAAGEAABYAAAAAAAC0/AHj5AASEgAAAAA01gBkWACDTAB8AFf43PT3 5IASEnwAAOAYd+PuMBKQTwB8AGgAEGG35RaSEgB8AOj/NOL/ZBL/gwD/fMkc q4sA5UGpEn4AAIg02xBk/0eD/358fx/4iADk5QASEgAAAALnHABkAACDqQB8 AMyINARkZA2DgwB8fBABHL0AAEUAqQAAAIAxKOMAPxIwAAAAAIScAOPxABIS AAAAAIIAnQwA/0IAR3cAACwAAAAAQABAAAAI/wA/CBxIsKDBgwgTKlzIsKFD gxceNnxAsaLFixgzUrzAsWPFCw8kDgy5EeQDkBxPolypsmXKlx1hXnS48UEH CwooMCDAgIJOCjx99gz6k+jQnkWR9lRgYYDJkAk/DlAgIMICkVgHLoggQIPT ighVJqBQIKvZghkoZDgA8uDJAwk4bDhLd+ABBmvbjnzbgMKBuoA/bKDQgC1F gW8XKMgQOHABBQsMI76wIIOExo0FZIhM8sKGCQYCYA4cwcCEDSYPLOgg4Oro uhMEdOB84cCAChReB2ZQYcGGkxsGFGCgGzCFCh1QH5jQIW3xugwSzD4QvIIH 4s/PUgiQYcCG4BkC5P/ObpaBhwreq18nb3Z79+8Dwo9nL9I8evjWsdOX6D59 fPH71Xeef/kFyB93/sln4EP2Ebjegg31B5+CEDLUIH4PVqiQhOABqKFCF6qn 34cHcfjffCQaFOJtGaZYkIkUuljQigXK+CKCE3po40A0trgjjDru+EGPI/6I Y4co7kikkAMBmaSNSzL5gZNSDjkghkXaaGIBHjwpY4gThJeljFt2WSWYMQpZ 5pguUnClehS4tuMEDARQgH8FBMBBBExGwIGdAxywXAUBKHCZkAIoEEAFp33W QGl47ZgBAwZEwKigE1SQgAUCUDCXiwtQIIAFCTQwgaCrZeCABAzIleIGHDD/ oIAHGUznmXABGMABT4xpmBYBHGgAKGq1ZbppThgAG8EEAW61KwYMSOBAApdy pNp/BkhAAQLcEqCTt+ACJW645I5rLrgEeOsTBtwiQIEElRZg61sTNBBethSw CwEA/Pbr778ABywwABBAgAAG7xpAq6mGUUTdAPZ6YIACsRKAAbvtZqzxxhxn jDG3ybbKFHf36ZVYpuE5oIGhHMTqcqswvyxzzDS/HDMHEiiggQMLDxCZXh8k BnEBCQTggAUGGKCB0ktr0PTTTEfttNRQT22ABR4EkEABDXgnGUEn31ZABglE EEAAWaeN9tpqt832221HEEECW6M3wc+Hga3SBgtMODBABw00UEEBgxdO+OGG J4744oZzXUEDHQxwN7F5G7QRdXxPoPkAnHfu+eeghw665n1vIKhJBQUEADs=""") style = ttk.Style() style.element_create("RoundedFrame", "image", "frameBorder", ("focus", "frameFocusBorder"), border=16, sticky="nsew") style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})]) style.configure("TEntry", borderwidth=0) frame = ttk.Frame(style="RoundedFrame", padding=10) frame.pack(fill='x') frame2 = ttk.Frame(style="RoundedFrame", padding=10) frame2.pack(fill='both', expand=1) entry = ttk.Entry(frame, text='Test') entry.pack(fill='x') entry.bind("", lambda evt: frame.state(["focus"])) entry.bind("", lambda evt: frame.state(["!focus"])) text = Tkinter.Text(frame2, borderwidth=0, bg="white", highlightthickness=0) text.pack(fill='both', expand=1) text.bind("", lambda evt: frame2.state(["focus"])) text.bind("", lambda evt: frame2.state(["!focus"])) root.mainloop() PK!#ggttk/treeview_multicolumn.pycnu[ ^c@sdZddlZddlZddlZd6Zd7d8d9d:d;d<d=d>d?d@dAdBdCdDdEgZd1Zd2efd3YZd4Z e d5kre ndS(FsCDemo based on the demo mclist included with tk source distribution.iNtcountrytcapitaltcurrencyt Argentinas Buenos AirestARSt AustraliatCanberratAUDtBraziltBraziliatBRLtCanadatOttawatCADtChinatBeijingtCNYtFrancetParistEURtGermanytBerlintIndias New DelhitINRtItalytRometJapantTokyotJPYtMexicos Mexico CitytMXNtRussiatMoscowtRUBs South AfricatPretoriatZARsUnited KingdomtLondontGBPs United StatessWashington, D.C.tUSDcsgjdD]}j|||f^q}|jdx1t|D]#\}}j|dd|qQWj|d|fddS(s/Sort tree contents when a column is clicked on.ttreverseitcommandcst|t S(N(tsortbytint(tcol(t descendingttree(s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyt%R'N(t get_childrentsettsortt enumeratetmovetheading(R.R,R-tchildtdatatindxtitem((R-R.s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR*s 4 tAppcBs#eZdZdZdZRS(cCs!d|_|j|jdS(N(tNoneR.t_setup_widgetst _build_tree(tself((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyt__init__(s  c Csetjdddddddd$d d }|jd dtj}|jd ddttjdtdd|_tjddd|jj }tjddd|jj }|jj d|j d|j |jj ddddddd||j dd dddd!d||j dddd dd"d||jdd#d |jdd#d dS(%Nt wraplengtht4itjustifytlefttanchortntpaddingi iittextsTtk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which can be configured to display multiple columns of informational data without displaying the tree itself. This is a simple way to build a listbox that has multiple columns. Clicking on the heading for a column will sort the data by that column. You can also change the width of the columns by dragging the boundary between them.tfilltxtbothtexpandtcolumnstshowtheadingstorienttverticalR)t horizontaltyscrollcommandtxscrollcommandtcolumnitrowtstickytnsewtin_itnstewtweight(i ii i(tttktLabeltpacktFrametTruetTreeviewt tree_columnsR.t Scrollbartyviewtxviewt configureR1tgridtgrid_columnconfiguretgrid_rowconfigure(R>tmsgt containertvsbthsb((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR<-s  %""c s xgtD]_}jj|d|jd|fdjj|dtjj|jqWxtD]}jj ddd|xnt |D]`\}}tjj|}jjt|dd|krjjt|d|qqWqqWdS(NRGR)cstj|dS(Ni(R*R.(tc(R>(s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR/MR'twidthR'tendtvalues( RbR.R5ttitleRTttkFonttFonttmeasuret tree_datatinsertR3R;(R>R,R9R8tvaltilen((R>s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR=Js / "(t__name__t __module__R?R<R=(((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyR:'s  cCstj}|jd|jdddl}y|jdWn*tk roddl}|jdnXt }|j dS(NsMulti-Column Listtmclistis~/tile-themes/plastik/plastiks'plastik theme being used without images( tTkintertTktwm_titlet wm_iconnamet plastik_themetinstallt ExceptiontwarningstwarnR:tmainloop(trootRRtapp((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pytmain[s       t__main__(RRR(Rs Buenos AiresR(RRR(RR R (R R R (RRR(RRR(RRR(Rs New DelhiR(RRR(RRR(Rs Mexico CityR(RR R!(s South AfricaR"R#(sUnited KingdomR$R%(s United StatessWashington, D.C.R&( t__doc__R}RsR\RbRvR*tobjectR:RRz(((s=/usr/lib64/python2.7/Demo/tkinter/ttk/treeview_multicolumn.pyts0     4  PK!nnF ttk/notebook_closebtn.pynu["""A Ttk Notebook with close buttons. Based on an example by patthoyts, http://paste.tclers.tk/896 """ import os import Tkinter import ttk root = Tkinter.Tk() imgdir = os.path.join(os.path.dirname(__file__), 'img') i1 = Tkinter.PhotoImage("img_close", file=os.path.join(imgdir, 'close.gif')) i2 = Tkinter.PhotoImage("img_closeactive", file=os.path.join(imgdir, 'close_active.gif')) i3 = Tkinter.PhotoImage("img_closepressed", file=os.path.join(imgdir, 'close_pressed.gif')) style = ttk.Style() style.element_create("close", "image", "img_close", ("active", "pressed", "!disabled", "img_closepressed"), ("active", "!disabled", "img_closeactive"), border=8, sticky='') style.layout("ButtonNotebook", [("ButtonNotebook.client", {"sticky": "nswe"})]) style.layout("ButtonNotebook.Tab", [ ("ButtonNotebook.tab", {"sticky": "nswe", "children": [("ButtonNotebook.padding", {"side": "top", "sticky": "nswe", "children": [("ButtonNotebook.focus", {"side": "top", "sticky": "nswe", "children": [("ButtonNotebook.label", {"side": "left", "sticky": ''}), ("ButtonNotebook.close", {"side": "left", "sticky": ''})] })] })] })] ) def btn_press(event): x, y, widget = event.x, event.y, event.widget elem = widget.identify(x, y) index = widget.index("@%d,%d" % (x, y)) if "close" in elem: widget.state(['pressed']) widget.pressed_index = index def btn_release(event): x, y, widget = event.x, event.y, event.widget if not widget.instate(['pressed']): return elem = widget.identify(x, y) index = widget.index("@%d,%d" % (x, y)) if "close" in elem and widget.pressed_index == index: widget.forget(index) widget.event_generate("<>") widget.state(["!pressed"]) widget.pressed_index = None root.bind_class("TNotebook", "", btn_press, True) root.bind_class("TNotebook", "", btn_release) # create a ttk notebook with our custom style, and add some tabs to it nb = ttk.Notebook(width=200, height=200, style="ButtonNotebook") nb.pressed_index = None f1 = Tkinter.Frame(nb, background="red") f2 = Tkinter.Frame(nb, background="green") f3 = Tkinter.Frame(nb, background="blue") nb.add(f1, text='Red', padding=3) nb.add(f2, text='Green', padding=3) nb.add(f3, text='Blue', padding=3) nb.pack(expand=1, fill='both') root.mainloop() PK!yTt%t%ttk/plastik_theme.pynu["""This demonstrates good part of the syntax accepted by theme_create. This is a translation of plastik.tcl to python. You will need the images used by the plastik theme to test this. The images (and other tile themes) can be retrived by doing: $ cvs -z3 -d:pserver:anonymous@tktable.cvs.sourceforge.net:/cvsroot/tktable \ co tile-themes To test this module you should do, for example: import Tkinter import plastik_theme root = Tkinter.Tk() plastik_theme.install(plastik_image_dir) ... Where plastik_image_dir contains the path to the images directory used by the plastik theme, something like: tile-themes/plastik/plastik """ import os import glob import ttk from Tkinter import PhotoImage __all__ = ['install'] colors = { "frame": "#efefef", "disabledfg": "#aaaaaa", "selectbg": "#657a9e", "selectfg": "#ffffff" } imgs = {} def _load_imgs(imgdir): imgdir = os.path.expanduser(imgdir) if not os.path.isdir(imgdir): raise Exception("%r is not a directory, can't load images" % imgdir) for f in glob.glob("%s/*.gif" % imgdir): img = os.path.split(f)[1] name = img[:-4] imgs[name] = PhotoImage(name, file=f, format="gif89") def install(imgdir): _load_imgs(imgdir) style = ttk.Style() style.theme_create("plastik", "default", settings={ ".": { "configure": {"background": colors['frame'], "troughcolor": colors['frame'], "selectbackground": colors['selectbg'], "selectforeground": colors['selectfg'], "fieldbackground": colors['frame'], "font": "TkDefaultFont", "borderwidth": 1}, "map": {"foreground": [("disabled", colors['disabledfg'])]} }, "Vertical.TScrollbar": {"layout": [ ("Vertical.Scrollbar.uparrow", {"side": "top", "sticky": ''}), ("Vertical.Scrollbar.downarrow", {"side": "bottom", "sticky": ''}), ("Vertical.Scrollbar.uparrow", {"side": "bottom", "sticky": ''}), ("Vertical.Scrollbar.trough", {"sticky": "ns", "children": [("Vertical.Scrollbar.thumb", {"expand": 1, "unit": 1, "children": [("Vertical.Scrollbar.grip", {"sticky": ''})] })] })] }, "Horizontal.TScrollbar": {"layout": [ ("Horizontal.Scrollbar.leftarrow", {"side": "left", "sticky": ''}), ("Horizontal.Scrollbar.rightarrow", {"side": "right", "sticky": ''}), ("Horizontal.Scrollbar.leftarrow", {"side": "right", "sticky": ''}), ("Horizontal.Scrollbar.trough", {"sticky": "ew", "children": [("Horizontal.Scrollbar.thumb", {"expand": 1, "unit": 1, "children": [("Horizontal.Scrollbar.grip", {"sticky": ''})] })] })] }, "TButton": { "configure": {"width": 10, "anchor": "center"}, "layout": [ ("Button.button", {"children": [("Button.focus", {"children": [("Button.padding", {"children": [("Button.label", {"side": "left", "expand": 1})] })] })] }) ] }, "Toolbutton": { "configure": {"anchor": "center"}, "layout": [ ("Toolbutton.border", {"children": [("Toolbutton.button", {"children": [("Toolbutton.padding", {"children": [("Toolbutton.label", {"side":"left", "expand":1})] })] })] }) ] }, "TMenubutton": {"layout": [ ("Menubutton.button", {"children": [("Menubutton.indicator", {"side": "right"}), ("Menubutton.focus", {"children": [("Menubutton.padding", {"children": [("Menubutton.label", {"side": "left", "expand": 1})] })] })] })] }, "TNotebook": {"configure": {"tabmargins": [0, 2, 0, 0]}}, "TNotebook.tab": { "configure": {"padding": [6, 2, 6, 2], "expand": [0, 0, 2]}, "map": {"expand": [("selected", [1, 2, 4, 2])]} }, "Treeview": {"configure": {"padding": 0}}, # elements "Button.button": {"element create": ("image", 'button-n', ("pressed", 'button-p'), ("active", 'button-h'), {"border": [4, 10], "padding": 4, "sticky":"ewns"} ) }, "Toolbutton.button": {"element create": ("image", 'tbutton-n', ("selected", 'tbutton-p'), ("pressed", 'tbutton-p'), ("active", 'tbutton-h'), {"border": [4, 9], "padding": 3, "sticky": "news"} ) }, "Checkbutton.indicator": {"element create": ("image", 'check-nu', ('active', 'selected', 'check-hc'), ('pressed', 'selected', 'check-pc'), ('active', 'check-hu'), ("selected", 'check-nc'), {"sticky": ''} ) }, "Radiobutton.indicator": {"element create": ("image", 'radio-nu', ('active', 'selected', 'radio-hc'), ('pressed', 'selected', 'radio-pc'), ('active', 'radio-hu'), ('selected', 'radio-nc'), {"sticky": ''} ) }, "Horizontal.Scrollbar.thumb": {"element create": ("image", 'hsb-n', {"border": 3, "sticky": "ew"}) }, "Horizontal.Scrollbar.grip": {"element create": ("image", 'hsb-g')}, "Horizontal.Scrollbar.trough": {"element create": ("image", 'hsb-t')}, "Vertical.Scrollbar.thumb": {"element create": ("image", 'vsb-n', {"border": 3, "sticky": "ns"}) }, "Vertical.Scrollbar.grip": {"element create": ("image", 'vsb-g')}, "Vertical.Scrollbar.trough": {"element create": ("image", 'vsb-t')}, "Scrollbar.uparrow": {"element create": ("image", 'arrowup-n', ("pressed", 'arrowup-p'), {"sticky": ''}) }, "Scrollbar.downarrow": {"element create": ("image", 'arrowdown-n', ("pressed", 'arrowdown-p'), {'sticky': ''}) }, "Scrollbar.leftarrow": {"element create": ("image", 'arrowleft-n', ("pressed", 'arrowleft-p'), {'sticky': ''}) }, "Scrollbar.rightarrow": {"element create": ("image", 'arrowright-n', ("pressed", 'arrowright-p'), {'sticky': ''}) }, "Horizontal.Scale.slider": {"element create": ("image", 'hslider-n', {'sticky': ''}) }, "Horizontal.Scale.trough": {"element create": ("image", 'hslider-t', {'border': 1, 'padding': 0}) }, "Vertical.Scale.slider": {"element create": ("image", 'vslider-n', {'sticky': ''}) }, "Vertical.Scale.trough": {"element create": ("image", 'vslider-t', {'border': 1, 'padding': 0}) }, "Entry.field": {"element create": ("image", 'entry-n', ("focus", 'entry-f'), {'border': 2, 'padding': [3, 4], 'sticky': 'news'} ) }, "Labelframe.border": {"element create": ("image", 'border', {'border': 4, 'padding': 4, 'sticky': 'news'}) }, "Menubutton.button": {"element create": ("image", 'combo-r', ('active', 'combo-ra'), {'sticky': 'news', 'border': [4, 6, 24, 15], 'padding': [4, 4, 5]} ) }, "Menubutton.indicator": {"element create": ("image", 'arrow-d', {"sticky": "e", "border": [15, 0, 0, 0]}) }, "Combobox.field": {"element create": ("image", 'combo-n', ('readonly', 'active', 'combo-ra'), ('focus', 'active', 'combo-fa'), ('active', 'combo-a'), ('!readonly', 'focus', 'combo-f'), ('readonly', 'combo-r'), {'border': [4, 6, 24, 15], 'padding': [4, 4, 5], 'sticky': 'news'} ) }, "Combobox.downarrow": {"element create": ("image", 'arrow-d', {'sticky': 'e', 'border': [15, 0, 0, 0]}) }, "Notebook.client": {"element create": ("image", 'notebook-c', {'border': 4}) }, "Notebook.tab": {"element create": ("image", 'notebook-tn', ("selected", 'notebook-ts'), ("active", 'notebook-ta'), {'padding': [0, 2, 0, 0], 'border': [4, 10, 4, 10]} ) }, "Progressbar.trough": {"element create": ("image", 'hprogress-t', {'border': 2}) }, "Horizontal.Progressbar.pbar": {"element create": ("image", 'hprogress-b', {'border': [2, 9]}) }, "Vertical.Progressbar.pbar": {"element create": ("image", 'vprogress-b', {'border': [9, 2]}) }, "Treeheading.cell": {"element create": ("image", 'tree-n', ("pressed", 'tree-p'), {'border': [4, 10], 'padding': 4, 'sticky': 'news'} ) } }) style.theme_use("plastik") PK!|!eettk/img/close_pressed.gifnu[GIF89a**ff;;;;;;;;;;;;!Created with GIMP! ,0DJ'! 晅aA ;PK!xUeettk/img/close.gifnu[GIF89a;;;;;;;;;;;;;;;!Created with GIMP! ,0DJ'! 晅aA ;PK!.PPttk/img/close_active.gifnu[GIF89a4! ,0DJ'! 晅aA ;PK!$&$&ttk/ttkcalendar.pyonu[ ^c@s{dZddlZddlZddlZddlZdZdejfdYZdZe dkrwendS(sQ Simple calendar using ttk Treeview together with calendar and datetime classes. iNcCs-|dkrtj|Stj||SdS(N(tNonetcalendart TextCalendartLocaleTextCalendar(tlocaletfwday((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt get_calendar s  tCalendarcBseZejjZejjZddZdZdZdZ dZ dZ dZ dZ dZd Zd Zd Zd Zed ZRS(c KsY|jdtj}|jd|jjj}|jd|jjj}|jdd}|jdd}|jdd}|j||d |_d|_ t j j |||t |||_|j|j|j|j||gtd D]!} |jjd d d d ^q |_|j|jjd|jdS(s WIDGET-SPECIFIC OPTIONS locale, firstweekday, year, month, selectbackground, selectforeground t firstweekdaytyeartmonthRtselectbackgrounds#ecffc4tselectforegrounds#05640eiittendtvaluessN(tpopRtMONDAYtdatetimetnowR R Rt_datet _selectiontttktFramet__init__Rt_calt_Calendar__setup_stylest_Calendar__place_widgetst_Calendar__config_calendart_Calendar__setup_selectiontranget _calendartinsertt_itemst_build_calendartbindt_Calendar__minsize( tselftmastertkwRR R Rtsel_bgtsel_fgt_((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRs$    4 cCs|dkrtd|n]|dkr;||jdTss L.TButtontlefts R.TButtontright(RtStyleR&tlayout(R%tstylet arrow_layout((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__setup_stylesQs c Cs&tj|}tj|ddd|j}tj|ddd|j}tj|dddd|_tjd d d d d d|_|j d|dddddd|j d||jj d|dddddd|j d|dddd|jj d|dddddddS(NR@s L.TButtontcommands R.TButtontwidthitanchortcentertshowR t selectmodetnonetheightitin_tsidettoptpadyitcolumnitrowitpadxi itexpandR3tbothtbottom( RRtButtont _prev_montht _next_monthtLabelt_headertTreeviewRtpacktgrid(R%thframetlbtntrbtn((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__place_widgetsZs!"%c s|jjdj}||jd<|jjddd|jjddd|d dtjtfd |D}x0|D](}|jj |d |d |d dqWdS(NitcolumnstheaderR+tgrey90R RRttagc3s|]}j|VqdS(N(tmeasure(t.0tcol(tfont(s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pys qsRDtminwidthREte( RtformatweekheadertsplitRt tag_configureR ttkFonttFonttmaxRO(R%tcolstmaxwidthRg((Rhs4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__config_calendarjs   cstj|_tj|jd|dddd|_jddd|dd_j dfd |jj d fd |jj d|j dS( NR+t borderwidthithighlightthicknessR3REtwscs jS(N(t place_forget(tevt(tcanvas(s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR;|R s cs jS(N(Rw(Rx(Ry(s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR;}R ( RnRot_fonttTkintertCanvasRR.t create_textR0R#t_pressed(R%R(R)((Rys4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt__setup_selectionvs!cCsN|jjjjd\}}||jd }|jjj||dS(Ntxt+(RR&tgeometryRltindextminsize(R%RxRDRJ((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt __minsizes!c Cs|jj|jj}}|jj||d}|j|jd<|jj||}x~t|j D]m\}}|t |kr||ng}g|D]}|rd|nd^q} |j j |d| qiWdS(NiR0s%02dR R( RR R RtformatmonthnamettitleRYtmonthdayscalendart enumerateR!tlenRR,( R%R R RbtcaltindxR,tweektdaytfmt_week((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR"s")c Cs|\}}}}|jj|}|j}|jd|d||j|j|||dd|j|jd||jd|jd|d|d S( s%Configure canvas for a new selection.RDRJiiR0RKRtyN( RzReR.t configuretcoordsR0R/tplaceR( R%R0tbboxRRRDRJttextwRy((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt_show_selections "c Cs|j|j|j}}}|j|}|j|}| sQ||jkrUdS|j|d}t|sxdS|t|dd}|sdS|j ||} | sdSd|}|||f|_ |j || dS(s"Clicked somewhere in the calendar.NRis%02d( RRtwidgett identify_rowtidentify_columnR!R,RtintRRR( R%RxRRRR,ROt item_valuesR0R((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyR~s"  cCs[|jj|j|jdd|_|j|jj|jjd|_|jdS(s,Updated calendar to show the previous month.tdaysiN(R.RwRt timedeltaRR R R"(R%((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRVs $cCs|jj|jj|jj}}|j|jdtj||dd|_|j|jj|jjd|_|j dS(s'Update calendar to show the next month.RiN( R.RwRR R RRt monthrangeRR"(R%R R ((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRWs  !$cCsF|js dS|jj|jj}}|j||t|jdS(s9Return a datetime representing the current selected date.iN(RRRR R RR(R%R R ((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyt selections N(t__name__t __module__RRRRRR1R7RRRRR$R"RR~RVRWtpropertyR(((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyRs    %       cCsddl}tj}|jdtdtj}|jddddd|jkrxt j }|j d n|j dS( Nis Ttk CalendarRRRiR3RStwintclam( tsysR{tTkRRRtSUNDAYR[tplatformRR>t theme_usetmainloop(RtroottttkcalR@((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyttests    t__main__( t__doc__RR{RnRRRRRR(((s4/usr/lib64/python2.7/Demo/tkinter/ttk/ttkcalendar.pyts      PK!"P P ttk/widget_state.pyonu[ ^c @sdZddlZddddddd d d g Zx eD]Zejd eq;Wd ZdejfdYZdZe dkrendS(s8Sample demo showing widget states and some font styling.iNtactivetdisabledtfocustpressedtselectedt backgroundtreadonlyt alternatetinvalidt!cCs%tttd}|j|dS(Ni(tstatestlentstate(twidgettnostate((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyt reset_state stAppcBs2eZddZddZdZdZRS(cCstjj|dd|jj|tj|_|jjdd}t|j j d|}|j j d||_ d|j krd|j |_ n|d d kr|d nd |_ t ||d d krd nd |_g|_|jdS( Nt borderwidthitTButtontfontsfont configure %s -sizesfont configure %s -familyt s{%s}it-ti(tttktFramet__init__tmasterttitletStyletstyletlookuptstrttktevalt font_familyt fsize_prefixtintt base_fsizetupdate_widgetst_setup_widgets(tselfRtbtn_fonttfsize((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyRs#) icCs4|jjddd|j|j|j|fdS(NRRs%s %s%d(Rt configureR"R#R%(R(textra((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyt _set_font#scCs|j|}|s'dg}d}nGt|j}g|D]}|tkr@|^q@}dt|}x(|jD]}t||j|qxW|j|dS(NRiii( t nametowidgettsettsplitR R R&RR R-(R(R tnewtextt goodstatest font_extrat newstatesR ((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyt _new_state's  %  c Cstj|dd}tj|dddd}|j|jddf|d <|j|jj||j|j d d d d |j dddd d d dd|j d ddddS(NttextsEnter states and watchtcursortxtermtvalidatetkeys%Ws%Ptvalidatecommandtfilltxtpadxitsidetlefttpadytanchortntbothtexpandi( RtButtontEntrytregisterR5RR&tappendR9tpack(R(tbtntentry((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyR'?s  "N(t__name__t __module__tNoneRR-R5R'(((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyRs   cCstd}|jdS(NsWidget State Tester(Rtmainloop(tapp((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pytmainNs t__main__( t__doc__RR R RIRRRRRRM(((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyts  @  PK! w%> > ttk/theme_selector.pycnu[ ^c@sZdZddlZddlZdejfdYZdZedkrVendS(sTtk Theme Selector v2. This is an improvement from the other theme selector (themes_combo.py) since now you can notice theme changes in Ttk Combobox, Ttk Frame, Ttk Label and Ttk Button. iNtAppcBs,eZdZdZdZdZRS(cCsHtjj|ddtj|_tj|d|_|jdS(Nt borderwidthii( tttktFramet__init__tStyletstyletTkintertIntVarttheme_autochanget_setup_widgets(tself((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyR scCs|jj|jjdS(N(Rt theme_uset themes_combotget(R ((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyt _change_themescCs |jjr|jndS(N(R RR(R twidget((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyt_theme_sel_changedsc Cstj|dd}|jj}tj|d|dd|_|jj|d|jjd|jtj |ddd |j }tj |dd d |j }|j d d dd|jj dddddd dd|j dddddd dd|j dddddddd |j}|jddd|jddd|jddd|j dddddddddddS(NttexttThemestvalueststatetreadonlyis<>s Change Themetcommands-Change themes when combobox item is activatedtvariabletipadxitstickytwtrowtcolumnitpadxtewitet columnspanitpadytweighttnsewtrowspan(RtLabelRt theme_namestComboboxR tsettbindRtButtonRt CheckbuttonR tgridtwinfo_toplevelt rowconfiguretcolumnconfigure(R t themes_lbltthemest change_btnttheme_change_checkbtnttop((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyR s&   %"" (t__name__t __module__RRRR (((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyR s  cCs't}|jjd|jdS(NsTheme Selector(Rtmasterttitletmainloop(tapp((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pytmain7s t__main__(t__doc__RRRRR<R6(((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyts   -  PK!aOttk/theme_selector.pynu["""Ttk Theme Selector v2. This is an improvement from the other theme selector (themes_combo.py) since now you can notice theme changes in Ttk Combobox, Ttk Frame, Ttk Label and Ttk Button. """ import Tkinter import ttk class App(ttk.Frame): def __init__(self): ttk.Frame.__init__(self, borderwidth=3) self.style = ttk.Style() # XXX Ideally I wouldn't want to create a Tkinter.IntVar to make # it works with Checkbutton variable option. self.theme_autochange = Tkinter.IntVar(self, 0) self._setup_widgets() def _change_theme(self): self.style.theme_use(self.themes_combo.get()) def _theme_sel_changed(self, widget): if self.theme_autochange.get(): self._change_theme() def _setup_widgets(self): themes_lbl = ttk.Label(self, text="Themes") themes = self.style.theme_names() self.themes_combo = ttk.Combobox(self, values=themes, state="readonly") self.themes_combo.set(themes[0]) self.themes_combo.bind("<>", self._theme_sel_changed) change_btn = ttk.Button(self, text='Change Theme', command=self._change_theme) theme_change_checkbtn = ttk.Checkbutton(self, text="Change themes when combobox item is activated", variable=self.theme_autochange) themes_lbl.grid(ipadx=6, sticky="w") self.themes_combo.grid(row=0, column=1, padx=6, sticky="ew") change_btn.grid(row=0, column=2, padx=6, sticky="e") theme_change_checkbtn.grid(row=1, columnspan=3, sticky="w", pady=6) top = self.winfo_toplevel() top.rowconfigure(0, weight=1) top.columnconfigure(0, weight=1) self.columnconfigure(1, weight=1) self.grid(row=0, column=0, sticky="nsew", columnspan=3, rowspan=2) def main(): app = App() app.master.title("Theme Selector") app.mainloop() if __name__ == "__main__": main() PK!xa##ttk/roundframe.pycnu[ ^c @sdZddlZddlZejZejdddZejdddZejZ e j dd dd%d d d de j ddidd 6fge j dddej ddddZejddej ddddZejddddejeddZejddejddejddejeddd d!d"dZejddddejdd#ejdd$ejdS(&shTtk Frame with rounded corners. Based on an example by Bryan Oakley, found at: http://wiki.tcl.tk/20152iNtframeFocusBordertdatas R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI 5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/ /wD//2gAAGEAABYAAAAAAAC0/AHj5AASEgAAAAA01gBkWACDTAB8AFf43PT3 5IASEnwAAOAYd+PuMBKQTwB8AGgAEGG35RaSEgB8AOj/NOL/ZBL/gwD/fMkc q4sA5UGpEn4AAIg02xBk/0eD/358fx/4iADk5QASEgAAAALnHABkAACDqQB8 AMyINARkZA2DgwB8fBABHL0AAEUAqQAAAIAxKOMAPxIwAAAAAIScAOPxABIS AAAAAIIAnQwA/0IAR3cAACwAAAAAQABAAAAI/wA/CBxIsKDBgwgTKlzIsKFD gxceNnxAsaLFixgzUrzAsWPFCw8kDgy5EeQDkBxPolypsmXKlx1hXnS48UEH CwooMCDAgIJOCjx99gz6k+jQnkWR9lRgYYDJkAk/DlAgIMICZlizat3KtatX rAsiCNDgtCJClQkoFMgqsu3ArBkoZDgA8uDJAwk4bGDmtm9BZgcYzK078m4D Cgf4+l0skNkGCg3oUhR4d4GCDIoZM2ZWQMECyZQvLMggIbPmzQIyfCZ5YcME AwFMn/bLLIKBCRtMHljQQcDV2ZqZTRDQYfWFAwMqUJANvC8zBhUWbDi5YUAB Bsybt2VGoUKH3AcmdP+Im127xOcJih+oXsEDdvOLuQfIMGBD9QwBlsOnzcBD hfrsuVfefgzJR599A+CnH4Hb9fcfgu29x6BIBgKYYH4DTojQc/5ZGGGGGhpU IYIKghgiQRw+GKCEJxZIwXwWlthiQyl6KOCMLsJIIoY4LlQjhDf2mNCI9/Eo 5IYO2sjikX+9eGCRCzL5V5JALillY07GaOSVb1G5ookzEnlhlFx+8OOXZb6V 5Y5kcnlmckGmKaaMaZrpJZxWXjnnlmW++WGdZq5ZXQEetKmnlxPgl6eUYhJq KKOI0imnoNbF2ScFHQJJwW99TsBAAAVYWEAAHEQAZoi1cQDqAAeEV0EACpT/ JqcACgRQAW6uNWCbYKcyyEwGDBgQwa2tTlBBAhYIQMFejC5AgQAWJNDABK3y loEDEjCgV6/aOcYBAwp4kIF6rVkXgAEc8IQZVifCBRQHGqya23HGIpsTBgSU OsFX/PbrVVjpYsCABA4kQCxHu11ogAQUIOAwATpBLDFQFE9sccUYS0wAxD5h 4DACFEggbAHk3jVBA/gtTIHHEADg8sswxyzzzDQDAAEECGAQsgHiTisZResN gLIHBijwLQEYePzx0kw37fTSSjuMr7ZMzfcgYZUZi58DGsTKwbdgayt22GSP bXbYY3MggQIaONDzAJ8R9kFlQheQQAAOWGCAARrwdt23Bn8H7vfggBMueOEG WOBBAAkU0EB9oBGUdXIFZJBABAEEsPjmmnfO+eeeh/55BBEk0Ph/E8Q9meQq bbDABAN00EADFRRQ++2254777rr3jrvjFTTQwQCpz7u6QRut5/oEzA/g/PPQ Ry/99NIz//oGrZpUUEAAOw==t frameBorders R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI 5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/ /wD//2gAAGEAABYAAAAAAAC0/AHj5AASEgAAAAA01gBkWACDTAB8AFf43PT3 5IASEnwAAOAYd+PuMBKQTwB8AGgAEGG35RaSEgB8AOj/NOL/ZBL/gwD/fMkc q4sA5UGpEn4AAIg02xBk/0eD/358fx/4iADk5QASEgAAAALnHABkAACDqQB8 AMyINARkZA2DgwB8fBABHL0AAEUAqQAAAIAxKOMAPxIwAAAAAIScAOPxABIS AAAAAIIAnQwA/0IAR3cAACwAAAAAQABAAAAI/wA/CBxIsKDBgwgTKlzIsKFD gxceNnxAsaLFixgzUrzAsWPFCw8kDgy5EeQDkBxPolypsmXKlx1hXnS48UEH CwooMCDAgIJOCjx99gz6k+jQnkWR9lRgYYDJkAk/DlAgIMICkVgHLoggQIPT ighVJqBQIKvZghkoZDgA8uDJAwk4bDhLd+ABBmvbjnzbgMKBuoA/bKDQgC1F gW8XKMgQOHABBQsMI76wIIOExo0FZIhM8sKGCQYCYA4cwcCEDSYPLOgg4Oro uhMEdOB84cCAChReB2ZQYcGGkxsGFGCgGzCFCh1QH5jQIW3xugwSzD4QvIIH 4s/PUgiQYcCG4BkC5P/ObpaBhwreq18nb3Z79+8Dwo9nL9I8evjWsdOX6D59 fPH71Xeef/kFyB93/sln4EP2Ebjegg31B5+CEDLUIH4PVqiQhOABqKFCF6qn 34cHcfjffCQaFOJtGaZYkIkUuljQigXK+CKCE3po40A0trgjjDru+EGPI/6I Y4co7kikkAMBmaSNSzL5gZNSDjkghkXaaGIBHjwpY4gThJeljFt2WSWYMQpZ 5pguUnClehS4tuMEDARQgH8FBMBBBExGwIGdAxywXAUBKHCZkAIoEEAFp33W QGl47ZgBAwZEwKigE1SQgAUCUDCXiwtQIIAFCTQwgaCrZeCABAzIleIGHDD/ oIAHGUznmXABGMABT4xpmBYBHGgAKGq1ZbppThgAG8EEAW61KwYMSOBAApdy pNp/BkhAAQLcEqCTt+ACJW645I5rLrgEeOsTBtwiQIEElRZg61sTNBBethSw CwEA/Pbr778ABywwABBAgAAG7xpAq6mGUUTdAPZ6YIACsRKAAbvtZqzxxhxn jDG3ybbKFHf36ZVYpuE5oIGhHMTqcqswvyxzzDS/HDMHEiiggQMLDxCZXh8k BnEBCQTggAUGGKCB0ktr0PTTTEfttNRQT22ABR4EkEABDXgnGUEn31ZABglE EEAAWaeN9tpqt832221HEEECW6M3wc+Hga3SBgtMODBABw00UEEBgxdO+OGG J4744oZzXUEDHQxwN7F5G7QRdXxPoPkAnHfu+eeghw665n1vIKhJBQUEADs=t RoundedFrametimagetfocustborderitstickytnsewtTEntryt borderwidthitstyletpaddingi tfilltxtbothtexpandittexttTests cCstjdgS(NR(tframetstate(tevt((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pytgts cCstjdgS(Ns!focus(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyRhRtbgtwhitethighlightthicknesscCstjdgS(NR(tframe2R(R((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyRlRcCstjdgS(Ns!focus(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyRmR(RR(t__doc__tTkintertttktTktroott PhotoImagetimg1timg2tStyleR telement_createtlayoutt configuretFrameRtpackRtEntrytentrytbindtTextRtmainloop(((s3/usr/lib64/python2.7/Demo/tkinter/ttk/roundframe.pyts2    &  $   !PK!^ttk/treeview_multicolumn.pynu["""Demo based on the demo mclist included with tk source distribution.""" import Tkinter import tkFont import ttk tree_columns = ("country", "capital", "currency") tree_data = [ ("Argentina", "Buenos Aires", "ARS"), ("Australia", "Canberra", "AUD"), ("Brazil", "Brazilia", "BRL"), ("Canada", "Ottawa", "CAD"), ("China", "Beijing", "CNY"), ("France", "Paris", "EUR"), ("Germany", "Berlin", "EUR"), ("India", "New Delhi", "INR"), ("Italy", "Rome", "EUR"), ("Japan", "Tokyo", "JPY"), ("Mexico", "Mexico City", "MXN"), ("Russia", "Moscow", "RUB"), ("South Africa", "Pretoria", "ZAR"), ("United Kingdom", "London", "GBP"), ("United States", "Washington, D.C.", "USD") ] def sortby(tree, col, descending): """Sort tree contents when a column is clicked on.""" # grab values to sort data = [(tree.set(child, col), child) for child in tree.get_children('')] # reorder data data.sort(reverse=descending) for indx, item in enumerate(data): tree.move(item[1], '', indx) # switch the heading so that it will sort in the opposite direction tree.heading(col, command=lambda col=col: sortby(tree, col, int(not descending))) class App(object): def __init__(self): self.tree = None self._setup_widgets() self._build_tree() def _setup_widgets(self): msg = ttk.Label(wraplength="4i", justify="left", anchor="n", padding=(10, 2, 10, 6), text=("Ttk is the new Tk themed widget set. One of the widgets it " "includes is a tree widget, which can be configured to " "display multiple columns of informational data without " "displaying the tree itself. This is a simple way to build " "a listbox that has multiple columns. Clicking on the " "heading for a column will sort the data by that column. " "You can also change the width of the columns by dragging " "the boundary between them.")) msg.pack(fill='x') container = ttk.Frame() container.pack(fill='both', expand=True) # XXX Sounds like a good support class would be one for constructing # a treeview with scrollbars. self.tree = ttk.Treeview(columns=tree_columns, show="headings") vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview) hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview) self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set) self.tree.grid(column=0, row=0, sticky='nsew', in_=container) vsb.grid(column=1, row=0, sticky='ns', in_=container) hsb.grid(column=0, row=1, sticky='ew', in_=container) container.grid_columnconfigure(0, weight=1) container.grid_rowconfigure(0, weight=1) def _build_tree(self): for col in tree_columns: self.tree.heading(col, text=col.title(), command=lambda c=col: sortby(self.tree, c, 0)) # XXX tkFont.Font().measure expected args are incorrect according # to the Tk docs self.tree.column(col, width=tkFont.Font().measure(col.title())) for item in tree_data: self.tree.insert('', 'end', values=item) # adjust columns lenghts if necessary for indx, val in enumerate(item): ilen = tkFont.Font().measure(val) if self.tree.column(tree_columns[indx], width=None) < ilen: self.tree.column(tree_columns[indx], width=ilen) def main(): root = Tkinter.Tk() root.wm_title("Multi-Column List") root.wm_iconname("mclist") import plastik_theme try: plastik_theme.install('~/tile-themes/plastik/plastik') except Exception: import warnings warnings.warn("plastik theme being used without images") app = App() root.mainloop() if __name__ == "__main__": main() PK!J"_ ttk/notebook_closebtn.pyonu[ ^c @sdZddlZddlZddlZejZejjejje dZ ej ddejje dZ ej ddejje dZ ej d dejje d ZejZejd d dd8d9ddddejddidd6fgejddidd6didd6dd6didd6dd6didd6dd6fdidd6dd6fgd 6fgd 6fgd 6fgd!Zd"Zejd#d$eeejd#d%eejd&d'd(d'd)dZde_ejed*d+Zejed*d,Zejed*d-Zejed.d/d0d1ejed.d2d0d1ejed.d3d0d1ej d4d5d6d7ej!dS(:saA Ttk Notebook with close buttons. Based on an example by patthoyts, http://paste.tclers.tk/896 iNtimgt img_closetfiles close.giftimg_closeactivesclose_active.giftimg_closepressedsclose_pressed.giftclosetimagetactivetpresseds !disabledtborderitstickyttButtonNotebooksButtonNotebook.clienttnswesButtonNotebook.TabsButtonNotebook.tabsButtonNotebook.paddingttoptsidesButtonNotebook.focussButtonNotebook.labeltleftsButtonNotebook.closetchildrencCst|j|j|j}}}|j||}|jd||f}d|krp|jdg||_ndS(Ns@%d,%dRR(txtytwidgettidentifytindextstatet pressed_index(teventRRRtelemR((s:/usr/lib64/python2.7/Demo/tkinter/ttk/notebook_closebtn.pyt btn_press&s  cCs|j|j|j}}}|jdgs3dS|j||}|jd||f}d|kr|j|kr|j||jdn|j dgd|_dS(NRs@%d,%dRs<>s!pressed( RRRtinstateRRRtforgettevent_generateRtNone(RRRRRR((s:/usr/lib64/python2.7/Demo/tkinter/ttk/notebook_closebtn.pyt btn_release/s t TNotebooksstwidthitheighttstylet backgroundtredtgreentbluettexttRedtpaddingitGreentBluetexpanditfilltboth(RRs !disabledR(Rs !disabledR("t__doc__tostTkintertttktTktroottpathtjointdirnamet__file__timgdirt PhotoImageti1ti2ti3tStyleR$telement_createtlayoutRR t bind_classtTruetNotebooktnbRRtFrametf1tf2tf3taddtpacktmainloop(((s:/usr/lib64/python2.7/Demo/tkinter/ttk/notebook_closebtn.pytsF    !$      <  PK!J"_ ttk/notebook_closebtn.pycnu[ ^c @sdZddlZddlZddlZejZejjejje dZ ej ddejje dZ ej ddejje dZ ej d dejje d ZejZejd d dd8d9ddddejddidd6fgejddidd6didd6dd6didd6dd6didd6dd6fdidd6dd6fgd 6fgd 6fgd 6fgd!Zd"Zejd#d$eeejd#d%eejd&d'd(d'd)dZde_ejed*d+Zejed*d,Zejed*d-Zejed.d/d0d1ejed.d2d0d1ejed.d3d0d1ej d4d5d6d7ej!dS(:saA Ttk Notebook with close buttons. Based on an example by patthoyts, http://paste.tclers.tk/896 iNtimgt img_closetfiles close.giftimg_closeactivesclose_active.giftimg_closepressedsclose_pressed.giftclosetimagetactivetpresseds !disabledtborderitstickyttButtonNotebooksButtonNotebook.clienttnswesButtonNotebook.TabsButtonNotebook.tabsButtonNotebook.paddingttoptsidesButtonNotebook.focussButtonNotebook.labeltleftsButtonNotebook.closetchildrencCst|j|j|j}}}|j||}|jd||f}d|krp|jdg||_ndS(Ns@%d,%dRR(txtytwidgettidentifytindextstatet pressed_index(teventRRRtelemR((s:/usr/lib64/python2.7/Demo/tkinter/ttk/notebook_closebtn.pyt btn_press&s  cCs|j|j|j}}}|jdgs3dS|j||}|jd||f}d|kr|j|kr|j||jdn|j dgd|_dS(NRs@%d,%dRs<>s!pressed( RRRtinstateRRRtforgettevent_generateRtNone(RRRRRR((s:/usr/lib64/python2.7/Demo/tkinter/ttk/notebook_closebtn.pyt btn_release/s t TNotebooksstwidthitheighttstylet backgroundtredtgreentbluettexttRedtpaddingitGreentBluetexpanditfilltboth(RRs !disabledR(Rs !disabledR("t__doc__tostTkintertttktTktroottpathtjointdirnamet__file__timgdirt PhotoImageti1ti2ti3tStyleR$telement_createtlayoutRR t bind_classtTruetNotebooktnbRRtFrametf1tf2tf3taddtpacktmainloop(((s:/usr/lib64/python2.7/Demo/tkinter/ttk/notebook_closebtn.pytsF    !$      <  PK!"P P ttk/widget_state.pycnu[ ^c @sdZddlZddddddd d d g Zx eD]Zejd eq;Wd ZdejfdYZdZe dkrendS(s8Sample demo showing widget states and some font styling.iNtactivetdisabledtfocustpressedtselectedt backgroundtreadonlyt alternatetinvalidt!cCs%tttd}|j|dS(Ni(tstatestlentstate(twidgettnostate((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyt reset_state stAppcBs2eZddZddZdZdZRS(cCstjj|dd|jj|tj|_|jjdd}t|j j d|}|j j d||_ d|j krd|j |_ n|d d kr|d nd |_ t ||d d krd nd |_g|_|jdS( Nt borderwidthitTButtontfontsfont configure %s -sizesfont configure %s -familyt s{%s}it-ti(tttktFramet__init__tmasterttitletStyletstyletlookuptstrttktevalt font_familyt fsize_prefixtintt base_fsizetupdate_widgetst_setup_widgets(tselfRtbtn_fonttfsize((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyRs#) icCs4|jjddd|j|j|j|fdS(NRRs%s %s%d(Rt configureR"R#R%(R(textra((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyt _set_font#scCs|j|}|s'dg}d}nGt|j}g|D]}|tkr@|^q@}dt|}x(|jD]}t||j|qxW|j|dS(NRiii( t nametowidgettsettsplitR R R&RR R-(R(R tnewtextt goodstatest font_extrat newstatesR ((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyt _new_state's  %  c Cstj|dd}tj|dddd}|j|jddf|d <|j|jj||j|j d d d d |j dddd d d dd|j d ddddS(NttextsEnter states and watchtcursortxtermtvalidatetkeys%Ws%Ptvalidatecommandtfilltxtpadxitsidetlefttpadytanchortntbothtexpandi( RtButtontEntrytregisterR5RR&tappendR9tpack(R(tbtntentry((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyR'?s  "N(t__name__t __module__tNoneRR-R5R'(((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyRs   cCstd}|jdS(NsWidget State Tester(Rtmainloop(tapp((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pytmainNs t__main__( t__doc__RR R RIRRRRRRM(((s5/usr/lib64/python2.7/Demo/tkinter/ttk/widget_state.pyts  @  PK!j:^^ttk/plastik_theme.pyonu[ ^c@sdZddlZddlZddlZddlmZdgZidd6dd6d d 6d d 6ZiZd Z dZ dS(ssThis demonstrates good part of the syntax accepted by theme_create. This is a translation of plastik.tcl to python. You will need the images used by the plastik theme to test this. The images (and other tile themes) can be retrived by doing: $ cvs -z3 -d:pserver:anonymous@tktable.cvs.sourceforge.net:/cvsroot/tktable co tile-themes To test this module you should do, for example: import Tkinter import plastik_theme root = Tkinter.Tk() plastik_theme.install(plastik_image_dir) ... Where plastik_image_dir contains the path to the images directory used by the plastik theme, something like: tile-themes/plastik/plastik iN(t PhotoImagetinstalls#efefeftframes#aaaaaat disabledfgs#657a9etselectbgs#fffffftselectfgcCstjj|}tjj|s7td|nxWtjd|D]B}tjj|d}|d }t|d|ddt|id)d6fd?id@idAid'd6dd 6fgd#6fgd#6fgd#6fgd$6dB6iidCdDdCdCgdE6d6dF6iidGdDdGdDgdH6dCdCdDgd 6d6idIddDdJdDgfgd 6d6dK6iidCdH6d6dL6idMdNddidJd/gdS6dJdH6dTd6fdU6d36idMdVdddidJdYgdS6dZdH6d[d6fdU6d96idMd\ddddidd6fdU6da6idMdbddddidd6fdU6dg6idMdhidZdS6d+d6fdU6d,6iddU6d-6iddU6d*6idMdkidZdS6dd6fdU6d6iddU6d"6iddU6d6idMdndidd6fdU6dp6idMdqdidd6fdU6ds6idMdtdidd6fdU6dv6idMdwdidd6fdU6dy6idMdzidd6fdU6d{6idMd|iddS6dCdH6fdU6d}6idMd~idd6fdU6d6idMdiddS6dCdH6fdU6d6idMddidDdS6dZdJgdH6d[d6fdU6d6idMdSidJdS6dJdH6d[d6fdU6d6idMddid[d6dJdGddgdS6dJdJdgdH6fdU6d=6idMdidd6ddCdCdCgdS6fdU6d>6idMddddddidJdGddgdS6dJdJdgdH6d[d6fdU6d6idMdidd6ddCdCdCgdS6fdU6d6idMdidJdS6fdU6d6idMdddidCdDdCdCgdH6dJd/dJd/gdS6fdU6d6idMdidDdS6fdU6d6idMdidDdYgdS6fdU6d6idMdidYdDgdS6fdU6d6idMddidJd/gdS6dJdH6d[d6fdU6d6|jddS(NtplastiktdefaulttsettingsRt backgroundt troughcolorRtselectbackgroundRtselectforegroundtfieldbackgroundt TkDefaultFonttfontit borderwidtht configuretdisabledRt foregroundtmapt.sVertical.Scrollbar.uparrowttoptsidettstickysVertical.Scrollbar.downarrowtbottomsVertical.Scrollbar.troughtnssVertical.Scrollbar.thumbtexpandtunitsVertical.Scrollbar.griptchildrentlayoutsVertical.TScrollbarsHorizontal.Scrollbar.leftarrowtleftsHorizontal.Scrollbar.rightarrowtrightsHorizontal.Scrollbar.troughtewsHorizontal.Scrollbar.thumbsHorizontal.Scrollbar.gripsHorizontal.TScrollbari twidthtcentertanchors Button.buttons Button.focussButton.paddings Button.labeltTButtonsToolbutton.bordersToolbutton.buttonsToolbutton.paddingsToolbutton.labelt ToolbuttonsMenubutton.buttonsMenubutton.indicatorsMenubutton.focussMenubutton.paddingsMenubutton.labelt TMenubuttoniit tabmarginst TNotebookitpaddingtselectedis TNotebook.tabtTreeviewtimagesbutton-ntpressedsbutton-ptactivesbutton-htbordertewnsselement creates tbutton-ns tbutton-ps tbutton-hi itnewsscheck-nuscheck-hcscheck-pcscheck-huscheck-ncsCheckbutton.indicatorsradio-nusradio-hcsradio-pcsradio-husradio-ncsRadiobutton.indicatorshsb-nshsb-gshsb-tsvsb-nsvsb-gsvsb-ts arrowup-ns arrowup-psScrollbar.uparrows arrowdown-ns arrowdown-psScrollbar.downarrows arrowleft-ns arrowleft-psScrollbar.leftarrows arrowright-ns arrowright-psScrollbar.rightarrows hslider-nsHorizontal.Scale.sliders hslider-tsHorizontal.Scale.troughs vslider-nsVertical.Scale.sliders vslider-tsVertical.Scale.troughsentry-ntfocussentry-fs Entry.fieldsLabelframe.borderscombo-rscombo-raiiisarrow-dtescombo-ntreadonlyscombo-fascombo-as !readonlyscombo-fsCombobox.fieldsCombobox.downarrows notebook-csNotebook.clients notebook-tns notebook-tss notebook-tas Notebook.tabs hprogress-tsProgressbar.troughs hprogress-bsHorizontal.Progressbar.pbars vprogress-bsVertical.Progressbar.pbarstree-nstree-psTreeheading.cell(R?sbutton-p(R@sbutton-h(R<s tbutton-p(R?s tbutton-p(R@s tbutton-h(R@R<scheck-hc(R?R<scheck-pc(R@scheck-hu(R<scheck-nc(R@R<sradio-hc(R?R<sradio-pc(R@sradio-hu(R<sradio-nc(R>shsb-g(R>shsb-t(R>svsb-g(R>svsb-t(R?s arrowup-p(R?s arrowdown-p(R?s arrowleft-p(R?s arrowright-p(RDsentry-f(R@scombo-ra(RFR@scombo-ra(RDR@scombo-fa(R@scombo-a(s !readonlyRDscombo-f(RFscombo-r(R<s notebook-ts(R@s notebook-ta(R?stree-p(RtttktStylet theme_createtcolorst theme_use(Rtstyle((s6/usr/lib64/python2.7/Demo/tkinter/ttk/plastik_theme.pyR.s        / /@@@!*'))"" "")).&.4!!-( t__doc__R RRGtTkinterRt__all__RJRRR(((s6/usr/lib64/python2.7/Demo/tkinter/ttk/plastik_theme.pyts      PK! w%> > ttk/theme_selector.pyonu[ ^c@sZdZddlZddlZdejfdYZdZedkrVendS(sTtk Theme Selector v2. This is an improvement from the other theme selector (themes_combo.py) since now you can notice theme changes in Ttk Combobox, Ttk Frame, Ttk Label and Ttk Button. iNtAppcBs,eZdZdZdZdZRS(cCsHtjj|ddtj|_tj|d|_|jdS(Nt borderwidthii( tttktFramet__init__tStyletstyletTkintertIntVarttheme_autochanget_setup_widgets(tself((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyR scCs|jj|jjdS(N(Rt theme_uset themes_combotget(R ((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyt _change_themescCs |jjr|jndS(N(R RR(R twidget((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyt_theme_sel_changedsc Cstj|dd}|jj}tj|d|dd|_|jj|d|jjd|jtj |ddd |j }tj |dd d |j }|j d d dd|jj dddddd dd|j dddddd dd|j dddddddd |j}|jddd|jddd|jddd|j dddddddddddS(NttexttThemestvalueststatetreadonlyis<>s Change Themetcommands-Change themes when combobox item is activatedtvariabletipadxitstickytwtrowtcolumnitpadxtewitet columnspanitpadytweighttnsewtrowspan(RtLabelRt theme_namestComboboxR tsettbindRtButtonRt CheckbuttonR tgridtwinfo_toplevelt rowconfiguretcolumnconfigure(R t themes_lbltthemest change_btnttheme_change_checkbtnttop((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyR s&   %"" (t__name__t __module__RRRR (((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyR s  cCs't}|jjd|jdS(NsTheme Selector(Rtmasterttitletmainloop(tapp((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pytmain7s t__main__(t__doc__RRRRR<R6(((s7/usr/lib64/python2.7/Demo/tkinter/ttk/theme_selector.pyts   -  PK!>ttk/mac_searchentry.pycnu[ ^c @sdZddlZddlZejZdZejddeddZejddedd Zej Z e j d d dd!d dddgdde j dd idd6dd 6didd6didd6fgd6fgd6fge j dddej ddejddddZejddddZejddd dejddd dejdS("s\Mac style search widget Translated from Tcl code by Schelte Bron, http://wiki.tcl.tk/18188 iNs R0lGODlhKgAaAOfnAFdZVllbWFpcWVtdWlxeW11fXF9hXmBiX2ZnZWhpZ2lraGxua25wbXJ0 cXR2c3V3dHZ4dXh6d3x+e31/fH6AfYSGg4eJhoiKh4qMiYuNio2PjHmUqnqVq3yXrZGTkJKU kX+asJSWk32cuJWXlIGcs5aYlX6euZeZloOetZial4SftpqbmIWgt4GhvYahuIKivpudmYei uYOjv5yem4ijuoSkwIWlwYmlu56gnYamwp+hnoenw4unvaCin4ioxJCnuZykrImpxZmlsoaq zI2pv6KkoZGouoqqxpqms4erzaOloo6qwYurx5Kqu5untIiszqSmo5CrwoysyJeqtpOrvJyo tZGsw42typSsvaaopZKtxJWtvp6qt4+uy6epppOuxZCvzKiqp5quuZSvxoyx06mrqJWwx42y 1JKxzpmwwaqsqZaxyI6z1ZqxwqutqpOzz4+01qyuq56yvpizypS00Jm0y5W10Zq1zJa20rCy rpu3zqizwbGzr6C3yZy4z7K0saG4yp250LO1sqK5y5660Z+70qO7zKy4xaC806S8zba4taG9 1KW9zq66x6+7yLi6t6S/1rC8yrm7uLO8xLG9y7q8ubS9xabB2anB07K+zLW+xrO/za7CzrTA zrjAyLXBz77BvbbC0K/G2LjD0bnE0rLK28TGw8bIxcLL07vP28HN28rMycvOyr/T38DU4cnR 2s/RztHT0NLU0cTY5MrW5MvX5dHX2c3Z59bY1dPb5Nbb3dLe7Nvd2t3f3NXh797g3d3j5dnl 9OPl4eTm4+Ln6tzo9uXn5Obo5eDp8efp5uHq8uXq7ejq5+nr6OPs9Ovu6unu8O3v6+vw8+7w 7ezx9O/x7vDy7/Hz8O/19/P18vT38/L3+fb49Pf59vX6/fj69/b7/vn7+Pr8+ff9//v9+vz/ +/7//P////////////////////////////////////////////////////////////////// /////////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJZAD/ACwC AAIAKAAWAAAI/gD/CRz4bwUGCg8eQFjIsGHDBw4iTLAQgqBFgisuePCiyJOpUyBDihRpypMi Lx8qaLhIMIyGFZ5sAUsmjZrNmzhzWpO2DJgtTysqfGDpxoMbW8ekeQsXzty4p1CjRjUXrps3 asJsuclQ4uKKSbamMR3n1JzZs2jRkh1HzuxVXX8y4CDYAwqua+DInVrRwMGJU2kDp31KThy1 XGWGDlxhi1rTPAUICBBAoEAesoIzn6Vm68MKgVAUHftmzhOCBCtQwQKSoABgzZnJdSMmyIPA FbCotdUQAIhNa9B6DPCAGbZac+SowVIMRVe4pwkA4GpqDlwuAAmMZx4nTtfnf1mO5JEDNy46 MHJkxQEDgKC49rPjwC0bqGaZuOoZAKjBPE4NgAzUvYcWOc0QZF91imAnCDHJ5JFAAJN0I2Ba 4iRDUC/gOEVNDwIUcEABCAgAAATUTIgWOMBYRFp80ghiAQIIVAAEAwJIYI2JZnUji0XSYAYO NcsQA8wy0hCTwAASXGOiONFcxAtpTokTHznfiLMNMAkcAMuE43jDC0vLeGOWe2R5o4sn1LgH GzkWsvTPMgEOaA433Ag4TjjMuDkQMNi0tZ12sqWoJ0HATMPNffAZZ6U0wLAyqJ62RGoLLrhI aqmlpzwaEAAh+QQJZAD/ACwAAAAAKgAaAAAI/gD/CRw40JEhQoEC+fGjcOHCMRAjRkxDsKLF f5YcAcID582ZjyBDJhmZZIjJIUySEDHiBMhFghrtdNnRAgSHmzhz6sTZQcSLITx+CHn5bxSk Nz5MCMGy55CjTVCjbuJEtSrVQ3uwqDBRQwrFi476SHHxow8qXcemVbPGtm21t3CnTaP27Jgu VHtuiIjBsuImQkRiiEEFTNo2cOTMKV7MuLE5cN68QUOGSgwKG1EqJqJDY8+rZt8UjxtNunTj cY3DgZOWS46KIFgGjiI0ZIsqaqNNjWjgYMUpx8Adc3v2aosNMAI1DbqyI9WycOb4IAggQEAB A3lQBxet/TG4cMpI/tHwYeSfIzxM0uTKNs7UgAQrYL1akaDA7+3bueVqY4NJlUhIcQLNYx8E AIQ01mwjTQ8DeNAdfouNA8440GBCQxJY3MEGD6p4Y844CQCAizcSgpMLAAlAuJ03qOyQRBR3 nEHEK+BMGKIui4kDDAAIPKiiYuSYSMQQRCDCxhiziPMYBgDkEaEaAGQA3Y+MjUPOLFoMoUUh cKxRC4ngeILiH8Qkk0cCAUzSDZWpzbLEE1EwggcYqWCj2DNADFDAAQUgIAAAEFDDJmPYqNJF F1s4cscTmCDjDTjdSPOHBQggUAEQDAgggTWDPoYMJkFoUdRmddyyjWLeULMMMcAsIw0x4wkM IME1g25zyxpHxFYUHmyIggw4H4ojITnfiLMNMAkcAAub4BQjihRdDGTJHmvc4Qo1wD6Imje6 eILbj+BQ4wqu5Q3ECSJ0FOKKMtv4mBg33Pw4zjbKuBIIE1xYpIkhdQQiyi7OtAucj6dt48wu otQhBRa6VvSJIRwhIkotvgRTzMUYZ6xxMcj4QkspeKDxxRhEmUfIHWjAgQcijEDissuXvCyz zH7Q8YQURxDhUsn/bCInR3AELfTQZBRt9BBJkCGFFVhMwTNBlnBCSCGEIJQQIAklZMXWRBAR RRRWENHwRQEBADs=tsearch1tdatatformats gif -index 0tsearch2s gif -index 1s Search.fieldtimagetfocustborderiiitstickytews Search.entrytnsweis Entry.paddingsEntry.textareatchildrent backgrounds#b2b2b2tstyletwidthitpadxi tpady(RR(t__doc__tTkintertttktTktrootRt PhotoImagets1ts2tStyleR telement_createtlayoutt configuretEntryte1te2tgridtmainloop(((s8/usr/lib64/python2.7/Demo/tkinter/ttk/mac_searchentry.pyts(   )   +PK!Ottk/dirbrowser.pycnu[ ^c @sdZddlZddlZddlZddlZdZdZdZdZdZ ej Z ej dd Z ej dd Zejd d)ddddddZeje d|dkr>|jn |j|j||dS(s"Hide and show scrollbar as needed.iiN(tfloatt grid_removetgridR (tsbartfirsttlast((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pyt autoscroll9s   torienttverticalt horizontaltcolumnsRRR tdisplaycolumnstyscrollcommandcCstt||S(N(R5tvsb(tftl((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pytHR%txscrollcommandcCstt||S(N(R5thsb(R=R>((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pyR?IR%tcommands#0RsDirectory Structuretanchortws File Sizetstretchitwidthids<>stcolumntrowtstickytnsweitnstewtweight(RRR (t__doc__RRtTkintertttkR$R(R,R.R5tTktroott ScrollbarR<RAtTreeviewRtyviewtxviewtheadingRGtbindR1tgrid_columnconfiguretgrid_rowconfiguretmainloop(((s3/usr/lib64/python2.7/Demo/tkinter/ttk/dirbrowser.pyts:            PK!akJ ttk/widget_state.pynu["""Sample demo showing widget states and some font styling.""" import ttk states = ['active', 'disabled', 'focus', 'pressed', 'selected', 'background', 'readonly', 'alternate', 'invalid'] for state in states[:]: states.append("!" + state) def reset_state(widget): nostate = states[len(states) // 2:] widget.state(nostate) class App(ttk.Frame): def __init__(self, title=None): ttk.Frame.__init__(self, borderwidth=6) self.master.title(title) self.style = ttk.Style() # get default font size and family btn_font = self.style.lookup("TButton", "font") fsize = str(self.tk.eval("font configure %s -size" % btn_font)) self.font_family = self.tk.eval("font configure %s -family" % btn_font) if ' ' in self.font_family: self.font_family = '{%s}' % self.font_family self.fsize_prefix = fsize[0] if fsize[0] == '-' else '' self.base_fsize = int(fsize[1 if fsize[0] == '-' else 0:]) # a list to hold all the widgets that will have their states changed self.update_widgets = [] self._setup_widgets() def _set_font(self, extra=0): self.style.configure("TButton", font="%s %s%d" % (self.font_family, self.fsize_prefix, self.base_fsize + extra)) def _new_state(self, widget, newtext): widget = self.nametowidget(widget) if not newtext: goodstates = ["disabled"] font_extra = 0 else: # set widget state according to what has been entered in the entry newstates = set(newtext.split()) # eliminate duplicates # keep only the valid states goodstates = [state for state in newstates if state in states] # define a new font size based on amount of states font_extra = 2 * len(goodstates) # set new widget state for widget in self.update_widgets: reset_state(widget) # remove any previous state from the widget widget.state(goodstates) # update Ttk Button font size self._set_font(font_extra) return 1 def _setup_widgets(self): btn = ttk.Button(self, text='Enter states and watch') entry = ttk.Entry(self, cursor='xterm', validate="key") entry['validatecommand'] = (self.register(self._new_state), '%W', '%P') entry.focus() self.update_widgets.append(btn) entry.validate() entry.pack(fill='x', padx=6) btn.pack(side='left', pady=6, padx=6, anchor='n') self.pack(fill='both', expand=1) def main(): app = App("Widget State Tester") app.mainloop() if __name__ == "__main__": main() PK!qP ttk/dirbrowser.pynu["""A directory browser using Ttk Treeview. Based on the demo found in Tk 8.5 library/demos/browse """ import os import glob import Tkinter import ttk def populate_tree(tree, node): if tree.set(node, "type") != 'directory': return path = tree.set(node, "fullpath") tree.delete(*tree.get_children(node)) parent = tree.parent(node) special_dirs = [] if parent else glob.glob('.') + glob.glob('..') for p in special_dirs + os.listdir(path): ptype = None p = os.path.join(path, p).replace('\\', '/') if os.path.isdir(p): ptype = "directory" elif os.path.isfile(p): ptype = "file" fname = os.path.split(p)[1] id = tree.insert(node, "end", text=fname, values=[p, ptype]) if ptype == 'directory': if fname not in ('.', '..'): tree.insert(id, 0, text="dummy") tree.item(id, text=fname) elif ptype == 'file': size = os.stat(p).st_size tree.set(id, "size", "%d bytes" % size) def populate_roots(tree): dir = os.path.abspath('.').replace('\\', '/') node = tree.insert('', 'end', text=dir, values=[dir, "directory"]) populate_tree(tree, node) def update_tree(event): tree = event.widget populate_tree(tree, tree.focus()) def change_dir(event): tree = event.widget node = tree.focus() if tree.parent(node): path = os.path.abspath(tree.set(node, "fullpath")) if os.path.isdir(path): os.chdir(path) tree.delete(tree.get_children('')) populate_roots(tree) def autoscroll(sbar, first, last): """Hide and show scrollbar as needed.""" first, last = float(first), float(last) if first <= 0 and last >= 1: sbar.grid_remove() else: sbar.grid() sbar.set(first, last) root = Tkinter.Tk() vsb = ttk.Scrollbar(orient="vertical") hsb = ttk.Scrollbar(orient="horizontal") tree = ttk.Treeview(columns=("fullpath", "type", "size"), displaycolumns="size", yscrollcommand=lambda f, l: autoscroll(vsb, f, l), xscrollcommand=lambda f, l:autoscroll(hsb, f, l)) vsb['command'] = tree.yview hsb['command'] = tree.xview tree.heading("#0", text="Directory Structure", anchor='w') tree.heading("size", text="File Size", anchor='w') tree.column("size", stretch=0, width=100) populate_roots(tree) tree.bind('<>', update_tree) tree.bind('', change_dir) # Arrange the tree and its scrollbars in the toplevel tree.grid(column=0, row=0, sticky='nswe') vsb.grid(column=1, row=0, sticky='ns') hsb.grid(column=0, row=1, sticky='ew') root.grid_columnconfigure(0, weight=1) root.grid_rowconfigure(0, weight=1) root.mainloop() PK!j:^^ttk/plastik_theme.pycnu[ ^c@sdZddlZddlZddlZddlmZdgZidd6dd6d d 6d d 6ZiZd Z dZ dS(ssThis demonstrates good part of the syntax accepted by theme_create. This is a translation of plastik.tcl to python. You will need the images used by the plastik theme to test this. The images (and other tile themes) can be retrived by doing: $ cvs -z3 -d:pserver:anonymous@tktable.cvs.sourceforge.net:/cvsroot/tktable co tile-themes To test this module you should do, for example: import Tkinter import plastik_theme root = Tkinter.Tk() plastik_theme.install(plastik_image_dir) ... Where plastik_image_dir contains the path to the images directory used by the plastik theme, something like: tile-themes/plastik/plastik iN(t PhotoImagetinstalls#efefeftframes#aaaaaat disabledfgs#657a9etselectbgs#fffffftselectfgcCstjj|}tjj|s7td|nxWtjd|D]B}tjj|d}|d }t|d|ddt|id)d6fd?id@idAid'd6dd 6fgd#6fgd#6fgd#6fgd$6dB6iidCdDdCdCgdE6d6dF6iidGdDdGdDgdH6dCdCdDgd 6d6idIddDdJdDgfgd 6d6dK6iidCdH6d6dL6idMdNddidJd/gdS6dJdH6dTd6fdU6d36idMdVdddidJdYgdS6dZdH6d[d6fdU6d96idMd\ddddidd6fdU6da6idMdbddddidd6fdU6dg6idMdhidZdS6d+d6fdU6d,6iddU6d-6iddU6d*6idMdkidZdS6dd6fdU6d6iddU6d"6iddU6d6idMdndidd6fdU6dp6idMdqdidd6fdU6ds6idMdtdidd6fdU6dv6idMdwdidd6fdU6dy6idMdzidd6fdU6d{6idMd|iddS6dCdH6fdU6d}6idMd~idd6fdU6d6idMdiddS6dCdH6fdU6d6idMddidDdS6dZdJgdH6d[d6fdU6d6idMdSidJdS6dJdH6d[d6fdU6d6idMddid[d6dJdGddgdS6dJdJdgdH6fdU6d=6idMdidd6ddCdCdCgdS6fdU6d>6idMddddddidJdGddgdS6dJdJdgdH6d[d6fdU6d6idMdidd6ddCdCdCgdS6fdU6d6idMdidJdS6fdU6d6idMdddidCdDdCdCgdH6dJd/dJd/gdS6fdU6d6idMdidDdS6fdU6d6idMdidDdYgdS6fdU6d6idMdidYdDgdS6fdU6d6idMddidJd/gdS6dJdH6d[d6fdU6d6|jddS(NtplastiktdefaulttsettingsRt backgroundt troughcolorRtselectbackgroundRtselectforegroundtfieldbackgroundt TkDefaultFonttfontit borderwidtht configuretdisabledRt foregroundtmapt.sVertical.Scrollbar.uparrowttoptsidettstickysVertical.Scrollbar.downarrowtbottomsVertical.Scrollbar.troughtnssVertical.Scrollbar.thumbtexpandtunitsVertical.Scrollbar.griptchildrentlayoutsVertical.TScrollbarsHorizontal.Scrollbar.leftarrowtleftsHorizontal.Scrollbar.rightarrowtrightsHorizontal.Scrollbar.troughtewsHorizontal.Scrollbar.thumbsHorizontal.Scrollbar.gripsHorizontal.TScrollbari twidthtcentertanchors Button.buttons Button.focussButton.paddings Button.labeltTButtonsToolbutton.bordersToolbutton.buttonsToolbutton.paddingsToolbutton.labelt ToolbuttonsMenubutton.buttonsMenubutton.indicatorsMenubutton.focussMenubutton.paddingsMenubutton.labelt TMenubuttoniit tabmarginst TNotebookitpaddingtselectedis TNotebook.tabtTreeviewtimagesbutton-ntpressedsbutton-ptactivesbutton-htbordertewnsselement creates tbutton-ns tbutton-ps tbutton-hi itnewsscheck-nuscheck-hcscheck-pcscheck-huscheck-ncsCheckbutton.indicatorsradio-nusradio-hcsradio-pcsradio-husradio-ncsRadiobutton.indicatorshsb-nshsb-gshsb-tsvsb-nsvsb-gsvsb-ts arrowup-ns arrowup-psScrollbar.uparrows arrowdown-ns arrowdown-psScrollbar.downarrows arrowleft-ns arrowleft-psScrollbar.leftarrows arrowright-ns arrowright-psScrollbar.rightarrows hslider-nsHorizontal.Scale.sliders hslider-tsHorizontal.Scale.troughs vslider-nsVertical.Scale.sliders vslider-tsVertical.Scale.troughsentry-ntfocussentry-fs Entry.fieldsLabelframe.borderscombo-rscombo-raiiisarrow-dtescombo-ntreadonlyscombo-fascombo-as !readonlyscombo-fsCombobox.fieldsCombobox.downarrows notebook-csNotebook.clients notebook-tns notebook-tss notebook-tas Notebook.tabs hprogress-tsProgressbar.troughs hprogress-bsHorizontal.Progressbar.pbars vprogress-bsVertical.Progressbar.pbarstree-nstree-psTreeheading.cell(R?sbutton-p(R@sbutton-h(R<s tbutton-p(R?s tbutton-p(R@s tbutton-h(R@R<scheck-hc(R?R<scheck-pc(R@scheck-hu(R<scheck-nc(R@R<sradio-hc(R?R<sradio-pc(R@sradio-hu(R<sradio-nc(R>shsb-g(R>shsb-t(R>svsb-g(R>svsb-t(R?s arrowup-p(R?s arrowdown-p(R?s arrowleft-p(R?s arrowright-p(RDsentry-f(R@scombo-ra(RFR@scombo-ra(RDR@scombo-fa(R@scombo-a(s !readonlyRDscombo-f(RFscombo-r(R<s notebook-ts(R@s notebook-ta(R?stree-p(RtttktStylet theme_createtcolorst theme_use(Rtstyle((s6/usr/lib64/python2.7/Demo/tkinter/ttk/plastik_theme.pyR.s        / /@@@!*'))"" "")).&.4!!-( t__doc__R RRGtTkinterRt__all__RJRRR(((s6/usr/lib64/python2.7/Demo/tkinter/ttk/plastik_theme.pyts      PK!ԾREADMEnu[Several collections of example code for Tkinter. See the toplevel README for an explanation of the difference between Tkinter and _tkinter, how to enable the Python Tk interface, and where to get Matt Conway's lifesaver document. Subdirectories: guido my original example set (fairly random collection) matt Matt Conway's examples, to go with his lifesaver document ttk Examples using the ttk module PK!#guido/imageview.pynu[from Tkinter import * import sys def main(): filename = sys.argv[1] root = Tk() img = PhotoImage(file=filename) label = Label(root, image=img) label.pack() root.mainloop() main() PK!^guido/wish.pycnu[ ^c@sddlZddlZejejddddZejddZxer\dZndZyeeZ Wne k rPnXee d Zej ejd d erMej e yejd eZ Wnejk rZd GeGHnXe re GHndZqMqMWdS(iNtDISPLAYtwishtTkitupdatets% s tinfotcompletetevals TclError:(t_tkintertostcreatetenvironttktcalltcmdtpromptt raw_inputtlinetEOFErrort getbooleantrecordtresulttTclErrortmsg(((s//usr/lib64/python2.7/Demo/tkinter/guido/wish.pyts,       PK!MdUUguido/MimeViewer.pycnu[ Afc@soddlZddlTddlTddlmZdd dYZdZdZedkrkendS( iN(t*(t ScrolledTextt MimeViewercBsGeZdZdZdZdZdZdZdZRS(c Cs||_||_t|idd6dd6|_idd6dd6|j_t|ji|d 6|jd 6|_|jjid d 6|j d }t |d}|r"t |ji|d6dd6dd6dd6dd6|_ idd6dd6|jd6|j _|j j d|nNt|jidd6dd6|_ idd6dd6dd6|jd6|j _|j}t|tkr)d|_t |d}|rt |ji|d6dd6dd6dd6dd6|_idd6dd6|j_|jj d|n d|_d|_nt|jidd6dd6|_idd6dd6dd6|j d6|j_g|_xQtt|D]=}t|jd ||df||}|jj|qWd|_d|_dS(!NtraisedtreliefitbditexpandtbothtfillttexttcommandtwtanchorcSs|dko|d dkS(Ntreceivedisx400-((tx((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyttitheightiPtwidthtnonetwrapitaftertendttoptsidetipadyRi tflattlefttipadxtys%s.%d(ttitletmsgtFrametframetpackingt Checkbuttonttoggletbuttontpackt getheadertextt countlinesRthtexttinserttgetbodyttypet StringTypetNonetpadtbtexttpartstrangetlenRtappendt collapsed( tselftparentRRt headertextRtbodytitp((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyt__init__ sn                      cCs|jj|jjdS(N(R!R&R"(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR&GscCs|jjdS(N(R!tdestroy(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR=IscCs|jr|jjndS(N(R5R%tinvoke(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pytshowKs cCs$|jr|jn |jdS(N(R5texplodetcollapse(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR$Ns  cCsd|_x3|j|j|jfD]}|r"|jq"q"W|jrlx!|jD]}|jjqRWn|jjidd6dS(NiiR(R5R)R0R/tforgetR1R!R&(R6tcomptpart((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyRASs  cCsd|_x9|j|j|jfD]}|r"|j|jq"q"W|jrox|jD]}|jqXWn|jjidd6dS(NiiR(R5R)R0R/R&R"R1R!(R6RCRD((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR@\s  ( t__name__t __module__R<R&R=R?R$RAR@(((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR s ;     cCs\d}d}xI||krWtj|d|}|dkr@Pn|d}|d}qW|S(Nis i(tstringtfind(tstrtlimitR:tn((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR(es  cCsBddl}ddl}ddl}|j|jdd\}}x|D] \}}qJWd}d}x:|D]2} | d dkr| d}qmtj| }qmW|j} | j|} |s| j }n| j |} t } | j }t | d||f| }|j|j| jdd|jdS(NiiRtinboxt+s+%s/%d(tsystgetopttmhlibtargvR.RGtatoitMHt openfoldert getcurrentt openmessagetTkttkRR&R?tminsizetmainloop(RNRORPtoptstargstotatmessagetfoldertargtmhtftmtrootRXR((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pytmainos0          t__main__((RGttypestTkinterRRR(RfRE(((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyts   Z PK!X\guido/ManPage.pycnu[ ^c@sddlZddlTddlmZddlmZdZdZejdZejdZejd Z d efd YZ d e fd YZ e Z dZ edkre ndS(iN(t*(t_tkinter(t ScrolledTexts*-Courier-Bold-R-Normal-*-120-*s!*-Courier-Medium-O-Normal-*-120-*s:^ Page [1-9][0-9]*[ ]+\|^.*Last change:.*[1-9][0-9]* s^[ ]* s^[ ]*[Xv!_][Xv!_ ]* tEditableManPagecBsneZd dZdZdZdZeZdZdZ dZ dZ dZ d d Z RS( cKshttj||f||jddd|jddt|jddtd|_d|_dS(NtXt underlineit!tfontt_i( tapplyRt__init__t tag_configtBOLDFONTt ITALICFONTtNonetfptlineno(tselftmastertcnf((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pyR s  cCs |jdkS(N(RR(R((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytbusy%scCs|jr|jndS(N(Rt _endparser(R((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytkill)s cCs-|j||jj|tj|jdS(N(t _startparserttktcreatefilehandlerRtREADABLEt _filehandler(RR((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytasyncparsefile.s cCs4|jj}|s#|jdS|j|dS(N(RtreadlineRt _parseline(RRtmasktnextline((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pyR6s  cCszddlm}|d|d}|j|d}|j|x'|j}|s[Pn|j|qEW|jdS(Ni(tselectgcSs||ggg|dS(Ni((RttoutR!((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytavail@stheight(R!tgetintRRRR(RRR!R#R$R ((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pyt syncparsefile>s  cCs|jrtdn|j||_d|_d|_d|_d|_|d}t |d<|j dt ||ds     PK!kK\\guido/sortvisu.pyonu[ Afc@sdZddlTddlmZmZddlZdZdZdZdddYZ d dd YZ d Z d Z d Z dZdZdZdZdZdZdZdddYZdZedkrendS(sjSorting algorithms visualizer using Tkinter. This module is comprised of three ``components'': - an array visualizer with methods that implement basic sorting operations (compare, swap) as well as methods for ``annotating'' the sorting algorithm (e.g. to show the pivot element); - a number of sorting algorithms (currently quicksort, insertion sort, selection sort and bubble sort, as well as a randomization function), all using the array visualizer for its basic operations and with calls to its annotation methods; - and a ``driver'' class which can be used as a Grail applet or as a stand-alone application. i(t*(tLinet RectangleNi itArraycBseZddZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs||_t|j|_|jjdtt|j|_|jjt|j|_|jjt|j|_ |j jt |jdddd|_ t |jdddd|_ t |jdddd|_ g|_d|_|_|r|j|ndS(Ntfilli(tmastertFrametframetpacktXtLabeltlabeltCanvastcanvastreportRtlefttrighttpivottitemstsizetmaxvaluetsetdata(tselfRtdata((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt__init__"s      cCs|j}g|_x|D]}|jqWt||_t||_|jjd|jdtd|jdt x7t |jD]&}|jj t ||||qW|j d|jdS(NtwidthitheightsSort demo, size %d(RtdeletetlenRtmaxRR tconfigtXGRIDtYGRIDtrangetappendt ArrayItemtreset(RRtolditemstitemti((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR4s   $tnormalcCs ||_dS(N(tspeed(RR)((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytsetspeedCscCs|jjdS(N(Rtdestroy(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR+FsicCs&d|_|jr"|jjndS(Ni(t stop_mainloopt in_mainloopRtquit(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytcancelLs  cCs|jr|jjndS(N(R-RR.(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytstepQs sArray.CancelledcCs|jdkrd}n4|jdkr4|d}n|jdkrLd}n|js|jj|jj||jj}d|_|jj|jj|d|_n|jrd|_|j dt j ndS( Ntfastestitfasti s single-stepiʚ;it Cancelled( R)R,RtupdatetafterR.R-tmainloopt after_canceltmessageRR3(Rtmsecstid((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytwaitWs"           cCs|jS(N(R(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytgetsizejscCszxit|jD]X}|j|}||ko:|knrU|jjddq|jjddqW|jdS(NRtredtorange(R!RRR&Rthide_left_right_pivot(RtfirsttlastR'R&((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytshow_partitionms  cCsHx7t|jD]&}|j|}|jjddqW|jdS(NRR=(R!RRR&RR?(RR'R&((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pythide_partitionvs cCsd|ko|jkns-|jdS|j|j\}}}}|jj|ddf|ddfg|jjdS(Niii'(Rt hide_leftRtpositionRtcoordsRR4(RRtx1ty1tx2ty2((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt show_left|s  *cCsd|ko|jkns-|jdS|j|j\}}}}|jj|ddf|ddff|jjdS(Niii'(Rt hide_rightRRERRFRR4(RRRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt show_rights  *cCs"|j|j|jdS(N(RDRLt hide_pivot(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR?s  cCs|jjddfdS(Ni(ii(ii(RRF(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRDscCs|jjddfdS(Ni(ii(ii(RRF(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRLscCsM|j|j\}}}}|jjd|dfd|dffdS(Niii'(RRERRF(RRRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt show_pivotscCs|jjddfdS(Ni(ii(ii(RRF(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRNscCs`||krdS|j|j|}|j|}|||j|<|j|<|j|dS(N(t countswapRtswapwith(RR'tjR&tother((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytswaps    cCs1|j|j|}|j|}|j|S(N(t countcompareRt compareto(RR'RRR&RS((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytcompares   cCs7d|_d|_|j||j|jdS(Ni(t ncomparestnswapsR8t updatereportRC(Rtmsg((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR$s     cCs|jjd|dS(Nttext(R R(RR[((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR8scCs|jd|_|jdS(Ni(RYRZ(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRPscCs|jd|_|jdS(Ni(RXRZ(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRUscCs-d|j|jf}|jjd|dS(Ns%d cmps, %d swapsR\(RXRYRR(RR\((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRZsN(t__name__t __module__tNoneRRR)R*R+R-R,R/R0R3R;R<RBRCRKRMR?RDRLRORNRTRWR$R8RPRURZ(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR s8                     R#cBsbeZdZdZdZdZdZdZdZdZ dZ d Z RS( c Cs||_||_||_|j\}}}}t|j||||dddddd|_|jjd|j|jjd|j |jjd |j dS( NRR=toutlinetblackRis ss( tarraytindextvalueRERR R&tbindt mouse_downt mouse_movetmouse_up(RRbRcRdRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs   cCs)|j}d|_d|_|jdS(N(R&R_RbR(RR&((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs   cCsA|j|_|j|_|j|_|j|_|jjdS(N(txtlastxtytlastytorigxtorigyR&ttkraise(Rtevent((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRfs     cCsC|jj|j|j|j|j|j|_|j|_dS(N(R&tmoveRiRjRkRl(RRp((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRgs' c Cs|j|j}||jjkr=|jjd}n|dkrRd}n|jj|}|j}|||jj|<|jj|<||_|j\}}}}|jj||f||ff|j |dS(Nii( t nearestindexRiRbR<RRcRER&RFtsetindex( RRpR'RSthereRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRhs   ! "cCst|j|}|sdS|jjdkr7d}n|j}||_|j}t|||}|jjx<|D]4}|jj|d |df|jj dq~WdS(NR1iii2( tstepsRcRbR)REt interpolateR&RoRFR;(RRctnstepstoldptstnewptst trajectorytpts((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRss      cCst|j|j}|sdS|jjdkr:d}n|j}|j}|j|j|_|_|j}|j}|jd}|jd}|jjdd|jjdd|jjj|jjdkrk|jj |d |df|jj |d |df|jjj|jjd||jjd||jj ddSt |||} t |||} |j |j kr|jj |jj n|jj |jj zxztt| D]f} | | } | | } |jj | d | df|jj | d | df|jj dqWWd| d } | d } |jj | d | df|jj | d | df|jjd||jjd|XdS( NR1iRtgreentyellows single-stepii2i(RuRcRbR)RER&RRR4RFR;RvRdRoR!R(RRSRwtmyoldptst otheroldptstmynewptst othernewptstmyfillt otherfillt mytrajectorytothertrajectoryR'tmyptstotherpts((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRQsV              cCs|jd}|jd}t|j|j}|dkrJd}d}n%|dkred}d}n d}}z:|jjd||jjd||jjdWd|jjd||jjd|X|S(NRitwhiteRatgreyi(R&tcmpRdRRbR;(RRSRRtoutcometmyflasht otherflash((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRV-s"       cCsX|jdttd}|t}|jjdt}||jt}||||fS(Nii(RcRtWIDTHRbRR Rd(RRGRIRJRH((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyREBs  cCsttt|tdS(Ni(tinttroundtfloatR(RRi((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRrIs( R]R^RRRfRgRhRsRQRVRERr(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR#s      .  cCs[t||}|dkr)|d}n.|dkrB|d}n|dkrWd}n|S(Niiii (tabs(RttthereRw((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRuOs      cCst|t|kr$tdndgt|}t|g}xmtd|D]\}x@tt|D],}|||||||||||j || fn| dkr.|j | |fq.q.W|jdWd|j XdS(Nt QuicksortiiisInsertion sortisChoosing pivotisPivot at left of partitionisSweep right pointersSweep left pointersEnd of partitions Swap itemssSwap pivot backR( R<R$RBR8R!RWRTROR;RMRKR"RC( RbRtstackR@RAR'RRRRRRtn1tn2((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt quicksortsx             '    '         cCs<x5x.ttttgD]}t|||qWqWdS(N(RRRRR(Rbtalg((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytdemosorts tSortDemocBseZddZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZRS(icCs||_||_d|_t|j|_t||_|jjdtt|j|_ |j jdt dt t|j|_ |j jdt dt t|j ddd|j|_|jjdtt|j ddd|j|_|jjdtt|j ddd|j|_|jjdtt|j dd d|j|_|jjdtd tfd Y}||j||_|jj|d d ddgtddd}|j|kr|j|j|jntt|j |jft ||_!|j!jdtt"|j|_#|j#jdt|j |j#dddd|_$|j$jdtt|j ddd|j%|_&|j&jdtt|j ddd|j'|_(|j(jdtt|j ddd|j)|_*|j*jdtt|j ddd|j+|_,|j,jdtt|j ddd|j-|_.|j.jdtt|j ddd|j/|_0|j0jdt|j0j1dt2t|j ddd|j3|_4|j4jdtdS(NitsideRR\RtcommandsInsertion sortsSelection sorts Bubble sorttMyIntVarcBseZdZdZRS(cSs||_tj||dS(N(tdemotIntVarR(RRR((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs cSs9tj||t|dkr5|jj|ndS(Nt0(RtsettstrRtresize(RRd((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs(R]R^RR(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs iiiiii7R(s single-stepR2R1tStept RandomizetUniformtDistincttDemotCanceltstatetQuit(5RRtbusyRRbRtbotframeRtBOTTOMt botleftframetLEFTtYt botrightframetRIGHTtButtontc_qsorttb_qsortR tc_isorttb_isorttc_ssorttb_ssorttc_bsorttb_bsortRtv_sizeRR!R"tsorttapplyt OptionMenuRtm_sizet StringVartv_speedtm_speedtc_steptb_stept c_randomizet b_randomizet c_uniformt b_uniformt c_distinctt b_distincttc_demotb_demotc_canceltb_cancelRtDISABLEDtc_quittb_quit(RRRRtsizes((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRsv        " "       cCsG|jr|jjdS||_|jjtd|jddS(Ni(RRtbellRRbRR!(Rtnewsize((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR0s    cCs|jtdS(N(trunR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR7scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR:scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR=scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR@scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRCscCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRFscCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRIscCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRLscCs|jr|jjdSd|_|jj|jj|jjdt y||jWnt j k rvnX|jjdt d|_dS(NiRi( RRRRbR*RtgetRRtNORMALRR3R(Rtfunc((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyROs   cCs+|js|jjdS|jjdS(N(RRRRbR/(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR]s  cCsK|js|jjdS|jjd|jjd|jjdS(Ns single-step(RRRRRRbR*R0(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRcs   cCs3|jr|jjn|jj|jjdS(N(RRbR/Rt after_idleR.(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRks (R]R^RRRRRRRRRRRRRR(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs L            cCs6t}t|}|jd|j|jdS(NtWM_DELETE_WINDOW(tTkRtprotocolRR6(trootR((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytmainss  t__main__((((t__doc__tTkinterR RRRRR RRR#RuRvRRRRRRRRRRR](((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyts,       =   PK!%Lguido/brownian2.pycnu[ ^c@sddlTddlZddlZdZdZdZdZdZdZdZ da da d Z d Zd Zed krendS( i(t*Nii,i itrediccst}tjtdt}tjtdt}|j||||||||dt}x_tstjdt }tjdt }y|j |||Wnt k rPqcXdVqcWdS(Ng@tfilli( tRADIUStrandomtgausstWIDTHtSIGMAtHEIGHTt create_ovaltFILLtstoptBUZZtmovetTclErrortNone(tcanvastrtxtytptdxtdy((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pytparticles.  cCs:|jtjt}tjt|dt|dS(Ni(tnextRt expovariatetLAMBDAtroottaftertintR (Rtdt((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pyR "s cCstattdtdt}|jddddd}tjdr`ttjd}nx$t |D]}t t |qmWztj Wdda XdS(NtwidththeightRtbothtexpandii(tTkRtCanvasRRtpacktsystargvRtrangeR RtmainloopR (Rtnpti((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pytmain's  t__main__(tTkinterRR&RRRR RRR R RRRR R,t__name__(((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pyts       PK!+$RRguido/optionmenu.pycnu[ ^c@sddlTeZeZejdeeedddZejd Z eZ e je d e eee fe e Z e jejd S( i(t*tOnetTwotThreetAahtBeetCeetDeetEffiN(RRRRR(tTkintertTktroott StringVartvar1tsett OptionMenutmenu1tpacktCHOICEStvar2tapplyttupletmenu2tmainloop(((s5/usr/lib64/python2.7/Demo/tkinter/guido/optionmenu.pyts       PK!^ui i guido/switch.pyonu[ ^c@sfddlTdd dYZdd dYZdd dYZdZed krbend S(i(t*tAppcBs)eZdddZdZdZRS(cCs|dkr3|dkr$t}q3t|}n||_t||_|jjt|dddt|_|jjdddt i|_ d|_ dS(Nt borderwidthitrelieftexpanditfill( tNonetTktToplevelttoptFramet buttonframetpacktGROOVEt panelframetBOTHtpanelstcurpanel(tselfR tmaster((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyt__init__s      cCst|jd|d||d}|jdtt|j}||}|||f|j|<|jdkr|j |ndS(NttexttcommandcSs |j|S(N(tshow(Rtname((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pytttside( tButtonR R tLEFTR RRRRR(RRtklasstbuttontframetinstance((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pytaddpanels cCsR|j|\}}}|jr/|jjn||_|jdddddS(NRiRtboth(RRt pack_forgetR (RRRR R!((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyRs   N(t__name__t __module__RRR"R(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyRs t LabelPanelcBseZdZRS(cCs&t|dd|_|jjdS(NRs Hello world(tLabeltlabelR (RR ((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR's(R%R&R(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR'&st ButtonPanelcBseZdZRS(cCs&t|dd|_|jjdS(NRsPress me(RRR (RR ((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR,s(R%R&R(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR*+scCs:t}|jdt|jdt|jjdS(NR)R(RR"R'R*R tmainloop(tapp((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pytmain0s t__main__N((((tTkinterRR'R*R-R%(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyts !  PK!-88guido/AttrDialog.pynu[ # The options of a widget are described by the following attributes # of the Pack and Widget dialogs: # # Dialog.current: {name: value} # -- changes during Widget's lifetime # # Dialog.options: {name: (default, klass)} # -- depends on widget class only # # Dialog.classes: {klass: (v0, v1, v2, ...) | 'boolean' | 'other'} # -- totally static, though different between PackDialog and WidgetDialog # (but even that could be unified) from Tkinter import * class Option: varclass = StringVar # May be overridden def __init__(self, dialog, option): self.dialog = dialog self.option = option self.master = dialog.top self.default, self.klass = dialog.options[option] self.var = self.varclass(self.master) self.frame = Frame(self.master) self.frame.pack(fill=X) self.label = Label(self.frame, text=(option + ":")) self.label.pack(side=LEFT) self.update() self.addoption() def refresh(self): self.dialog.refresh() self.update() def update(self): try: self.current = self.dialog.current[self.option] except KeyError: self.current = self.default self.var.set(self.current) def set(self, e=None): # Should be overridden pass class BooleanOption(Option): varclass = BooleanVar def addoption(self): self.button = Checkbutton(self.frame, text='on/off', onvalue=1, offvalue=0, variable=self.var, relief=RAISED, borderwidth=2, command=self.set) self.button.pack(side=RIGHT) class EnumOption(Option): def addoption(self): self.button = Menubutton(self.frame, textvariable=self.var, relief=RAISED, borderwidth=2) self.button.pack(side=RIGHT) self.menu = Menu(self.button) self.button['menu'] = self.menu for v in self.dialog.classes[self.klass]: self.menu.add_radiobutton( label=v, variable=self.var, value=v, command=self.set) class StringOption(Option): def addoption(self): self.entry = Entry(self.frame, textvariable=self.var, width=10, relief=SUNKEN, borderwidth=2) self.entry.pack(side=RIGHT, fill=X, expand=1) self.entry.bind('', self.set) class ReadonlyOption(Option): def addoption(self): self.label = Label(self.frame, textvariable=self.var, anchor=E) self.label.pack(side=RIGHT) class Dialog: def __init__(self, master): self.master = master self.fixclasses() self.refresh() self.top = Toplevel(self.master) self.top.title(self.__class__.__name__) self.top.minsize(1, 1) self.addchoices() def refresh(self): pass # Must override def fixclasses(self): pass # May override def addchoices(self): self.choices = {} list = [] for k, dc in self.options.items(): list.append((k, dc)) list.sort() for k, (d, c) in list: try: cl = self.classes[c] except KeyError: cl = 'unknown' if type(cl) == TupleType: cl = self.enumoption elif cl == 'boolean': cl = self.booleanoption elif cl == 'readonly': cl = self.readonlyoption else: cl = self.stringoption self.choices[k] = cl(self, k) # Must override: options = {} classes = {} # May override: booleanoption = BooleanOption stringoption = StringOption enumoption = EnumOption readonlyoption = ReadonlyOption class PackDialog(Dialog): def __init__(self, widget): self.widget = widget Dialog.__init__(self, widget) def refresh(self): self.current = self.widget.info() self.current['.class'] = self.widget.winfo_class() self.current['.name'] = self.widget._w class packoption: # Mix-in class def set(self, e=None): self.current = self.var.get() try: apply(self.dialog.widget.pack, (), {self.option: self.current}) except TclError, msg: print msg self.refresh() class booleanoption(packoption, BooleanOption): pass class enumoption(packoption, EnumOption): pass class stringoption(packoption, StringOption): pass class readonlyoption(packoption, ReadonlyOption): pass options = { '.class': (None, 'Class'), '.name': (None, 'Name'), 'after': (None, 'Widget'), 'anchor': ('center', 'Anchor'), 'before': (None, 'Widget'), 'expand': ('no', 'Boolean'), 'fill': ('none', 'Fill'), 'in': (None, 'Widget'), 'ipadx': (0, 'Pad'), 'ipady': (0, 'Pad'), 'padx': (0, 'Pad'), 'pady': (0, 'Pad'), 'side': ('top', 'Side'), } classes = { 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER), 'Boolean': 'boolean', 'Class': 'readonly', 'Expand': 'boolean', 'Fill': (NONE, X, Y, BOTH), 'Name': 'readonly', 'Pad': 'pixel', 'Side': (TOP, RIGHT, BOTTOM, LEFT), 'Widget': 'readonly', } class RemotePackDialog(PackDialog): def __init__(self, master, app, widget): self.master = master self.app = app self.widget = widget self.refresh() self.top = Toplevel(self.master) self.top.title(self.app + ' PackDialog') self.top.minsize(1, 1) self.addchoices() def refresh(self): try: words = self.master.tk.splitlist( self.master.send(self.app, 'pack', 'info', self.widget)) except TclError, msg: print msg return dict = {} for i in range(0, len(words), 2): key = words[i][1:] value = words[i+1] dict[key] = value dict['.class'] = self.master.send(self.app, 'winfo', 'class', self.widget) dict['.name'] = self.widget self.current = dict class remotepackoption: # Mix-in class def set(self, e=None): self.current = self.var.get() try: self.dialog.master.send( self.dialog.app, 'pack', 'config', self.dialog.widget, '-'+self.option, self.dialog.master.tk.merge( self.current)) except TclError, msg: print msg self.refresh() class booleanoption(remotepackoption, BooleanOption): pass class enumoption(remotepackoption, EnumOption): pass class stringoption(remotepackoption, StringOption): pass class readonlyoption(remotepackoption, ReadonlyOption): pass class WidgetDialog(Dialog): def __init__(self, widget): self.widget = widget self.klass = widget.winfo_class() Dialog.__init__(self, widget) def fixclasses(self): if self.addclasses.has_key(self.klass): classes = {} for c in (self.classes, self.addclasses[self.klass]): for k in c.keys(): classes[k] = c[k] self.classes = classes def refresh(self): self.configuration = self.widget.config() self.update() self.current['.class'] = self.widget.winfo_class() self.current['.name'] = self.widget._w def update(self): self.current = {} self.options = {} for k, v in self.configuration.items(): if len(v) > 4: self.current[k] = v[4] self.options[k] = v[3], v[2] # default, klass self.options['.class'] = (None, 'Class') self.options['.name'] = (None, 'Name') class widgetoption: # Mix-in class def set(self, e=None): self.current = self.var.get() try: self.dialog.widget[self.option] = self.current except TclError, msg: print msg self.refresh() class booleanoption(widgetoption, BooleanOption): pass class enumoption(widgetoption, EnumOption): pass class stringoption(widgetoption, StringOption): pass class readonlyoption(widgetoption, ReadonlyOption): pass # Universal classes classes = { 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER), 'Aspect': 'integer', 'Background': 'color', 'Bitmap': 'bitmap', 'BorderWidth': 'pixel', 'Class': 'readonly', 'CloseEnough': 'double', 'Command': 'command', 'Confine': 'boolean', 'Cursor': 'cursor', 'CursorWidth': 'pixel', 'DisabledForeground': 'color', 'ExportSelection': 'boolean', 'Font': 'font', 'Foreground': 'color', 'From': 'integer', 'Geometry': 'geometry', 'Height': 'pixel', 'InsertWidth': 'time', 'Justify': (LEFT, CENTER, RIGHT), 'Label': 'string', 'Length': 'pixel', 'MenuName': 'widget', 'Name': 'readonly', 'OffTime': 'time', 'OnTime': 'time', 'Orient': (HORIZONTAL, VERTICAL), 'Pad': 'pixel', 'Relief': (RAISED, SUNKEN, FLAT, RIDGE, GROOVE), 'RepeatDelay': 'time', 'RepeatInterval': 'time', 'ScrollCommand': 'command', 'ScrollIncrement': 'pixel', 'ScrollRegion': 'rectangle', 'ShowValue': 'boolean', 'SetGrid': 'boolean', 'Sliderforeground': 'color', 'SliderLength': 'pixel', 'Text': 'string', 'TickInterval': 'integer', 'To': 'integer', 'Underline': 'index', 'Variable': 'variable', 'Value': 'string', 'Width': 'pixel', 'Wrap': (NONE, CHAR, WORD), } # Classes that (may) differ per widget type _tristate = {'State': (NORMAL, ACTIVE, DISABLED)} _bistate = {'State': (NORMAL, DISABLED)} addclasses = { 'Button': _tristate, 'Radiobutton': _tristate, 'Checkbutton': _tristate, 'Entry': _bistate, 'Text': _bistate, 'Menubutton': _tristate, 'Slider': _bistate, } class RemoteWidgetDialog(WidgetDialog): def __init__(self, master, app, widget): self.app = app self.widget = widget self.klass = master.send(self.app, 'winfo', 'class', self.widget) Dialog.__init__(self, master) def refresh(self): try: items = self.master.tk.splitlist( self.master.send(self.app, self.widget, 'config')) except TclError, msg: print msg return dict = {} for item in items: words = self.master.tk.splitlist(item) key = words[0][1:] value = (key,) + words[1:] dict[key] = value self.configuration = dict self.update() self.current['.class'] = self.klass self.current['.name'] = self.widget class remotewidgetoption: # Mix-in class def set(self, e=None): self.current = self.var.get() try: self.dialog.master.send( self.dialog.app, self.dialog.widget, 'config', '-'+self.option, self.current) except TclError, msg: print msg self.refresh() class booleanoption(remotewidgetoption, BooleanOption): pass class enumoption(remotewidgetoption, EnumOption): pass class stringoption(remotewidgetoption, StringOption): pass class readonlyoption(remotewidgetoption, ReadonlyOption): pass def test(): import sys root = Tk() root.minsize(1, 1) if sys.argv[1:]: remotetest(root, sys.argv[1]) else: frame = Frame(root, name='frame') frame.pack(expand=1, fill=BOTH) button = Button(frame, name='button', text='button') button.pack(expand=1) canvas = Canvas(frame, name='canvas') canvas.pack() fpd = PackDialog(frame) fwd = WidgetDialog(frame) bpd = PackDialog(button) bwd = WidgetDialog(button) cpd = PackDialog(canvas) cwd = WidgetDialog(canvas) root.mainloop() def remotetest(root, app): from listtree import listtree list = listtree(root, app) list.bind('', opendialogs) list.app = app # Pass it on to handler def opendialogs(e): import string list = e.widget sel = list.curselection() for i in sel: item = list.get(i) widget = string.split(item)[0] RemoteWidgetDialog(list, list.app, widget) if widget == '.': continue try: RemotePackDialog(list, list.app, widget) except TclError, msg: print msg test() PK!V guido/rmt.pyonu[ Afc @sddlTddlZeZejZeededdZejde eeZ e jddde e e de Zejd edeee deddd ejd dZejd ede ddejd d dejedcCs<|j}|j}tjddtjt||dS(Nstk_priv(selectMode)tword(RRRRttk_textSelectToR(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytdouble1=s  s cCs<|j}|j}tjddtjt||dS(Nstk_priv(selectMode)tline(RRRRRR(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyttriple1Ds  s cCstjtdtdS(Ns (RtinserttAtInserttinvoke(R((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyt returnkeyKsscCsStjttjtjttjtddkrOtndS(Nis.0(RR!R"t selection_gettyview_pickplacetindexR#(R((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytcontrolvPss cCsHtjdtjdkrDtjdttjtndS(Nt promptEndsinsert - 1 char(RR'tdeleteR"R&(R((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyt backspaceZss s scCstjdt}tjtjdd|rttjkrZtjd|}ntj t|}|rtj t|dnt ntj tdS(NspromptEnd + 1 chartinfotcompletetevals ( RtgetR"t getbooleanttktcalltapptroott winfo_nametsendR!tpromptR&(tcmdtmsg((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyR#is cCs>tjttdtjddtjddddS(Ns: R)sinsert - 1 charRsinsert linestart(RR!R"R3Rttag_add(((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyR7uscCsA|atjddtjd|dtjddddS(NspromptEnd linestartR)t:R(R3RR*R!R:(tappName((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytnewApp~scCstjdtjddtj}t|}|jxR|D]J}ytj|dWntk rsqFXtj d|d|dqFWdS(NR itlasts winfo name .RcSs t|S(N(R=(tname((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytt( t file_m_appstaddR*R4t winfo_interpstlisttsortR6tTclErrort add_command(tnamesR?((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyt fillAppsMenus       t postcommand(1tTkintertsystTkR4R1tFrametRAISEDtmBartpacktXtftBOTHt ScrollbartFLATtstRIGHTtYtTexttsetRtLEFTt tag_configtyviewttitleticonnamet MenubuttontfiletMenutfile_mRBt add_cascadeRHtexitRtbindRR R$R(R+R#R7R=RJt tk_menuBarR5R3tfocustmainloop(((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyts^     '                 PK!,))guido/canvasevents.pycnu[ Afc@sddlTddlmZmZmZdefdYZdddYZdefdYZd dd YZd efd YZd efdYZ de fdYZ dddYZ dZ e dkre ndS(i(t*(tOvaltGroupt CanvasTextRcBseZdddZRS(cCs|jj|j||S(N(tcanvasttag_bindtid(tselftsequencetcommand((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytbind sN(t__name__t __module__tNoneR (((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR stObjectcBsYeZdZdddddZdZdZdZdZd Zd Z RS( sBase class for composite graphical objects. Objects belong to a canvas, and can be moved around on the canvas. They also belong to at most one ``pile'' of objects, and can be transferred between piles (or removed from their pile). Objects have a canonical ``x, y'' position which is moved when the object is moved. Where the object is relative to this position depends on the object; for simple objects, it may be their center. Objects have mouse sensitivity. They can be clicked, dragged and double-clicked. The behavior may actually be determined by the pile they are in. All instance attributes are public since the derived class may need them. itredtobjectcCsJ||_||_||_d|_t|j|_|j||dS(N(RtxtyR tpileRtgroupt createitems(RRRRtfillttext((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyt__init__#s     cCs t|jS(N(tstrR(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyt__str__+sc Cst|j|jd|jd|jd|jdd|dd|_|jj|jt|j|j|jd||_|jj|jdS(Nii RtwidthiR( RRRRt _Object__ovalRtaddtag_withtagRt _Object__text(RRR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR.s + cCsW||kodknr dS|jj|||j||_|j||_dS(Ni(RtmoveRR(Rtdxtdy((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytmoveby7s cCs"|j||j||jdS(N(R"RR(RRR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytmoveto>scCsN|jr%|jj|d|_n||_|jrJ|jj|ndS(N(RtdeleteR tadd(RR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyttransferAs     cCs|jjdS(N(Rttkraise(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR'Is( R R t__doc__RRRR"R#R&R'(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRs    tBottomcBseZdZdZRS(s+An object to serve as the bottom of a pile.c Gs]t|j|jd|jd|jd|jddddd|_|jj|jdS(Nii Rtgraytoutlinet(RRRRt _Bottom__ovalRR(Rtargs((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRQs +(R R R(R(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR)MstPilecBsPeZdZddZdZdZdZdZdZ dZ RS( sA group of graphical objects.cCs~||_||_||_g|_t|j|j|j|_t|jd||_|jj|jj|j dS(Nttag( RRRtobjectsR)tbottomRRRt bindhandlers(RRRRR0((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR\s    cCs0|jjd|j|jjd|jdS(Ns<1>s (RR t clickhandlertdoubleclickhandler(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR3fscCs4|jj||jj|j|j|dS(N(R1tappendRRtposition(RR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR%jscCs'|jj|j|jj|dS(N(RtdtagR1tremove(RR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR$oscCsF|j|jj|}|j|j|d|j|ddS(Nii(R'R1tindexR#RR(RRti((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR7ss cCsdS(N((Rtevent((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR4xscCsdS(N((RR<((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR5{sN( R R R(R RR3R%R$R7R4R5(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR/Xs     t MovingPilecBsAeZdZdZdZeZdZdZdZ RS(cCs=tj||jjd|j|jjd|jdS(Ns s(R/R3RR t motionhandlertreleasehandler(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR3s cCs|jjd}xMtt|jD])}|j|}|jj|kr(Pq(q(Wd|_dS|j||_x|jD]}|j q|W|j |_ |j |_ dS(Ntcurrent(RtgettagstrangetlenR1RR0R tmovethisR'RtlastxRtlasty(RR<ttagsR;to((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR4s   cCsm|js dS|j|j}|j|j}|j|_|j|_x!|jD]}|j||qOWdS(N(RDRRERRFR"(RR<R R!RH((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR>s   cCs-|j}|sdSd|_|j|dS(N(RDR t finishmove(RR<R1((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR?s   cCs"x|D]}|j|qWdS(N(R7(RR1RH((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRIs N( R R R3R RDR4R5R>R?RI(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR=s   tPile1cBs>eZdZdZdZdZdZdZdZRS(i2tp1cCs5||_tj||jj|j|j|jdS(N(tdemoR=RRRRR0(RRL((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRs cCsMy|jd}Wntk r%dSX|j|jtj||dS(Ni(R1t IndexErrorR&totherR=R5(RR<RH((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR5s  cCs |jjS(N(RLtp2(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRNscCs|d}|j}|j|j}}||jd||jd||jd||jdkrx.|D]}|j|qpWntj||dS(Nii(RNRRR&R=RI(RR1RHtpRR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRIs  @ ( R R RRR0RR5RNRI(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRJs   tPile2cBs#eZdZdZdZdZRS(ii2ROcCs |jjS(N(RLRK(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRNs(R R RRR0RN(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRQstDemocBseZdZRS(c Cs||_t|dddddddtdd|_|jjd d d tt||_t||_ t |jd d d d}t |jd dd d}t |jd dd d}|j |j|j |j|j |j dS(NRitheightt backgroundtyellowtrelieft borderwidthitexpandiRRRto1tgreento2s light blueto3( tmastertCanvastSUNKENRtpacktBOTHRJRKRQRORR&(RR]RYR[R\((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRs   (R R R(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRRscCs6t}t|}|jd|j|jdS(NtWM_DELETE_WINDOW(tTkRRtprotocoltquittmainloop(trootRL((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytmains  t__main__N((((tTkinterR^RRRRR)R/R=RJRQRRRhR (((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyts ? '0   PK!)tMIMIguido/AttrDialog.pycnu[ ^c@sddlTdddYZdefdYZdefdYZdefd YZd efd YZd dd YZdefdYZdefdYZdefdYZ de fdYZ dZ dZ dZ e dS(i(t*tOptioncBs5eZeZdZdZdZddZRS(cCs||_||_|j|_|j|\|_|_|j|j|_t |j|_ |j j dt t |j d|d|_|jj dt|j|jdS(Ntfillttextt:tside(tdialogtoptionttoptmastertoptionstdefaulttklasstvarclasstvartFrametframetpacktXtLabeltlabeltLEFTtupdatet addoption(tselfRR((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyt__init__s    cCs|jj|jdS(N(RtrefreshR(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR"s cCsQy|jj|j|_Wntk r9|j|_nX|jj|jdS(N(RtcurrentRtKeyErrorR Rtset(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR&s  cCsdS(N((Rte((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR-sN( t__name__t __module__t StringVarR RRRtNoneR(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs   t BooleanOptioncBseZeZdZRS(cCsYt|jddddddd|jdtd d d |j|_|jjd tdS( NRson/offtonvalueitoffvalueitvariabletrelieft borderwidthitcommandR(t CheckbuttonRRtRAISEDRtbuttonRtRIGHT(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR4s  (RR t BooleanVarR R(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR#0st EnumOptioncBseZdZRS(c Cst|jd|jdtdd|_|jjdtt|j|_|j|jd( tEntryRRtSUNKENtentryRR-RtbindR(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRQs   (RR R(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR8OstReadonlyOptioncBseZdZRS(cCs8t|jd|jdt|_|jjdtdS(NR0tanchorR(RRRtERRR-(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR\s (RR R(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR?ZstDialogcBsPeZdZdZdZdZiZiZeZ e Z e Z eZRS(cCsf||_|j|jt|j|_|jj|jj|jjdd|j dS(Ni( R t fixclassesRtToplevelRttitlet __class__Rtminsizet addchoices(RR ((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRcs   cCsdS(N((R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRltcCsdS(N((R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRCnRIcCsi|_g}x0|jjD]\}}|j||fqW|jx|D]\}\}}y|j|}Wntk rd}nXt|tkr|j }n9|dkr|j }n!|dkr|j }n |j }||||j|    "tRemotePackDialogcBseZdZdZdd dYZdeefdYZdeefdYZdee fd YZ d ee fd YZ RS( cCso||_||_||_|jt|j|_|jj|jd|jjdd|jdS(Ns PackDialogi( R tappR^RRDRRERGRH(RR RR^((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs    cCsy4|jjj|jj|jdd|j}Wntk rO}|GHdSXi}xFtdt|dD],}||d}||d}|||6dd?6dd@6ddA6ddB6d.dC6ddD6ddE6dFdG6dHdI6d.dJ6ddK6e!e"e#fdL6Z$ie%e&e'fdM6Z(ie%e'fdM6Z)ie(dN6e(dO6e(dP6e)dQ6e)dC6e(dR6e)dS6Z*RS(UcCs,||_|j|_tj||dS(N(R^R`R RBR(RR^((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs cCst|jj|jrpi}xF|j|j|jfD]+}x"|jD]}||||(RR>t opendialogsR(RRRRW((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRscCsddl}|j}|j}x|D]}|j|}|j|d}t||j||dkruq(nyt||j|Wq(tk r}|GHq(Xq(WdS(Niit.( RR^t curselectionRctsplitRRRRe(RRRWtselRRR^Rf((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs     N(((tTkinterRR#R/R8R?RBR]RRRRRR(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyts  .67m2   PK!^guido/wish.pyonu[ ^c@sddlZddlZejejddddZejddZxer\dZndZyeeZ Wne k rPnXee d Zej ejd d erMej e yejd eZ Wnejk rZd GeGHnXe re GHndZqMqMWdS(iNtDISPLAYtwishtTkitupdatets% s tinfotcompletetevals TclError:(t_tkintertostcreatetenvironttktcalltcmdtpromptt raw_inputtlinetEOFErrort getbooleantrecordtresulttTclErrortmsg(((s//usr/lib64/python2.7/Demo/tkinter/guido/wish.pyts,       PK! Cxjjguido/paint.pynu[""""Paint program by Dave Michell. Subject: tkinter "paint" example From: Dave Mitchell To: python-list@cwi.nl Date: Fri, 23 Jan 1998 12:18:05 -0500 (EST) Not too long ago (last week maybe?) someone posted a request for an example of a paint program using Tkinter. Try as I might I can't seem to find it in the archive, so i'll just post mine here and hope that the person who requested it sees this! All this does is put up a canvas and draw a smooth black line whenever you have the mouse button down, but hopefully it will be enough to start with.. It would be easy enough to add some options like other shapes or colors... yours, dave mitchell davem@magnet.com """ from Tkinter import * """paint.py: not exactly a paint program.. just a smooth line drawing demo.""" b1 = "up" xold, yold = None, None def main(): root = Tk() drawing_area = Canvas(root) drawing_area.pack() drawing_area.bind("", motion) drawing_area.bind("", b1down) drawing_area.bind("", b1up) root.mainloop() def b1down(event): global b1 b1 = "down" # you only want to draw when the button is down # because "Motion" events happen -all the time- def b1up(event): global b1, xold, yold b1 = "up" xold = None # reset the line when you let go of the button yold = None def motion(event): if b1 == "down": global xold, yold if xold is not None and yold is not None: event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE) # here's where you draw it. smooth. neat. xold = event.x yold = event.y if __name__ == "__main__": main() PK!X\guido/ManPage.pyonu[ ^c@sddlZddlTddlmZddlmZdZdZejdZejdZejd Z d efd YZ d e fd YZ e Z dZ edkre ndS(iN(t*(t_tkinter(t ScrolledTexts*-Courier-Bold-R-Normal-*-120-*s!*-Courier-Medium-O-Normal-*-120-*s:^ Page [1-9][0-9]*[ ]+\|^.*Last change:.*[1-9][0-9]* s^[ ]* s^[ ]*[Xv!_][Xv!_ ]* tEditableManPagecBsneZd dZdZdZdZeZdZdZ dZ dZ dZ d d Z RS( cKshttj||f||jddd|jddt|jddtd|_d|_dS(NtXt underlineit!tfontt_i( tapplyRt__init__t tag_configtBOLDFONTt ITALICFONTtNonetfptlineno(tselftmastertcnf((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pyR s  cCs |jdkS(N(RR(R((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytbusy%scCs|jr|jndS(N(Rt _endparser(R((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytkill)s cCs-|j||jj|tj|jdS(N(t _startparserttktcreatefilehandlerRtREADABLEt _filehandler(RR((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytasyncparsefile.s cCs4|jj}|s#|jdS|j|dS(N(RtreadlineRt _parseline(RRtmasktnextline((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pyR6s  cCszddlm}|d|d}|j|d}|j|x'|j}|s[Pn|j|qEW|jdS(Ni(tselectgcSs||ggg|dS(Ni((RttoutR!((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pytavail@stheight(R!tgetintRRRR(RRR!R#R$R ((s2/usr/lib64/python2.7/Demo/tkinter/guido/ManPage.pyt syncparsefile>s  cCs|jrtdn|j||_d|_d|_d|_d|_|d}t |d<|j dt ||ds     PK!X##guido/tkman.pyonu[ Afc@sddlZddlZddlZddlZddlTddlmZddgZddgZdZx/eD]'Z ej j e roe Z d ZqoqoWdZ x/eD]'Z ej j e re Zd Z qqWe se r\ejjd esd ejdZejjd ene sLd ejdZejjd enejd n[[ dZdddYZdZedS(iN(t*(tManPages/depot/sundry/man/manns/usr/local/man/manns/depot/sundry/man/man3s/usr/local/man/man3iis sgFailed to find mann directory. Please add the correct entry to the MANNDIRLIST at the top of %s script.s%s sgFailed to find man3 directory. Please add the correct entry to the MAN3DIRLIST at the top of %s script.cCsktj|}g}xE|D]=}|dd!dkr|ddkr|j|d qqW|j|S(Niit.t ln123456789(tostlistdirtappendtsort(tmandirtfilestnamestfile((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt listmanpages0s # t SelectionBoxcBseZddZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZRS(cCsg|_t|dd|_|jjdddt|jj|_t|jdd|_|jjdddtt|jdd|_|jjd tdddtt|jdd |_ |j jd t dddtt ||_ t |j dd d d dtdd|_|jjd tt|jdd|_|jjdddtd|j d|j|jjdddtd|j d|j|j|jds s(6tchoicestFrameRtpacktBOTHtmasterRRtLEFTRtRIGHTt StringVart chaptervart MenubuttontRAISEDRtTOPtMenuRtadd_radiobuttontMAN3DIRt newchaptertMANNDIRtListboxtSUNKENR!tButtontentry_cbR$tEntryR%tXR&tNONEt search_cbR't BooleanVartcasevart CheckbuttontFLATR(R)tLabelR*tBOTTOMRRtbindt listbox_cbt entry_tabt search_tabttext_tabt focus_settset(tselfR2((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt__init__;s                    cCs/|jj}g|_|jt|dS(N(R6tgetR.taddlistR (RTR((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyR=s cCs=||jkr/|jj||jjn|jdS(N(R.RRtupdate(RTtchoice((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt addchoicescCs1||jt|j)|jj|jdS(N(R.tlenRRX(RTtlist((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRWs cGs|jdS(N(RX(RTte((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRBscCsQ|jj}|rMt|dkrM|jj|d}|j|ndS(Nii(R!t curselectionR[RVt show_page(RTR]t selectionR((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRNscGs|j|jjdS(N(t search_stringR)RV(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRFscCs|jjdS(N(R)RR(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyROscCs|jjdS(N(R%RR(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRPscCs|jjdS(N(R%RR(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRQscCs|jj}t|t|d|j}|sF|jjn|jjdt d}x9|D]1}||krd}n|jj t |qiW|r|S|jj }|dkr|jjdSdS(NcSs|| |kS(N((Rtkeytn((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyttii( R%RVtfilterR[R.RtbellR!tdeletetAtEndtinserttsize(RTRbtokt exactmatchtitemRc((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt updatelists     cCsF|j}|rB|j||jjdt|jndS(Ni(RoR_R%RhRi(RTR((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRXs   cCs]d|jj|f}tjd|d}|jj||jd<|jj|dS(Ns%s/%s.?snroff -man %s | ul -itrR(R6RVRtpopenRtkillR*t parsefile(RTRR tfp((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyR_s   cCs`|s|jjdGHdS|jjs7tj}nd}y.|r[tj||}ntj|}Wn-tjk r}|jjdG|GHdSX|j j t }t j |t j|d }|j j t}t j |t j|d }|} d} x4|d}||krM| dkr8Pn| }d}d} n|j jd|d|} |j| } | dkrd} tdt|jd} y |j jdttWntk rnX|j jdd || fd || | f|j jt d || f|j jt PqqW| s\|jjndS( NsEmpty search strings Regex error:Riis%d.0 linestarts %d.0 lineendtsels%d.%d(RRgRHRVtret IGNORECASEtNonetcompileterrorRtindextAtInserttstringtatoitfindRiR)tmaxR[tgroupt tag_removet AtSelFirstt AtSelLasttTclErrorttag_addtmark_settyview_pickplace(RTR)tmaptprogtmsgtheretlinenotendt endlinenot wraplinenotfoundtlinetiRc((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRasd              N(t__name__t __module__RxRUR=RZRWRBRNRFRORPRQRoRXR_Ra(((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyR 9s M            cCsWt}t|}tjdr9|jtjdn|jdd|jdS(Ni(tTkR tsystargvR_tminsizetmainloop(troottsb((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pytmains    ((RRR}RvtTkinterRt MANNDIRLISTt MAN3DIRLISTt foundmanndirtdirtpathtexistsR>t foundman3dirR<tstderrtwriteRRtexitR R R(((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pytsD             PK!27O::guido/imageview.pycnu[ ^c@s*ddlTddlZdZedS(i(t*NcCsOtjd}t}td|}t|d|}|j|jdS(Nitfiletimage(tsystargvtTkt PhotoImagetLabeltpacktmainloop(tfilenametroottimgtlabel((s4/usr/lib64/python2.7/Demo/tkinter/guido/imageview.pytmains    (tTkinterRR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/imageview.pyts   PK!YYguido/brownian.pyonu[ ^c@sddlTddlZddlZddlZddlZdZdZdZdZdZ dZ dZ da d Z d ZedS( i(t*Nii,i itredicCst}tjtdt}tjtdt}|j||||||||dt}xvtstjdt }tjdt }tj t }y|j |||Wnt k rPnXtj|qcWdS(Ng@tfilli(tRADIUStrandomtgausstWIDTHtSIGMAtHEIGHTt create_ovaltFILLtstoptBUZZt expovariatetLAMBDAtmovetTclErrorttimetsleep(tcanvastrtxtytptdxtdytdt((s3/usr/lib64/python2.7/Demo/tkinter/guido/brownian.pytparticles.  cCst}t|dtdt}|jddddd}tjdr`ttjd}nx9t|D]+}t j dt d |f}|j qmWz|j WddaXdS( NtwidththeightRtbothtexpandiittargettargs(tTktCanvasRRtpacktsystargvtinttranget threadingtThreadRtstarttmainloopR (trootRtnptitt((s3/usr/lib64/python2.7/Demo/tkinter/guido/brownian.pytmain"s  (tTkinterRR)RR%RRRR RRR R RR1(((s3/usr/lib64/python2.7/Demo/tkinter/guido/brownian.pyts       PK!MdUUguido/MimeViewer.pyonu[ Afc@soddlZddlTddlTddlmZdd dYZdZdZedkrkendS( iN(t*(t ScrolledTextt MimeViewercBsGeZdZdZdZdZdZdZdZRS(c Cs||_||_t|idd6dd6|_idd6dd6|j_t|ji|d 6|jd 6|_|jjid d 6|j d }t |d}|r"t |ji|d6dd6dd6dd6dd6|_ idd6dd6|jd6|j _|j j d|nNt|jidd6dd6|_ idd6dd6dd6|jd6|j _|j}t|tkr)d|_t |d}|rt |ji|d6dd6dd6dd6dd6|_idd6dd6|j_|jj d|n d|_d|_nt|jidd6dd6|_idd6dd6dd6|j d6|j_g|_xQtt|D]=}t|jd ||df||}|jj|qWd|_d|_dS(!NtraisedtreliefitbditexpandtbothtfillttexttcommandtwtanchorcSs|dko|d dkS(Ntreceivedisx400-((tx((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyttitheightiPtwidthtnonetwrapitaftertendttoptsidetipadyRi tflattlefttipadxtys%s.%d(ttitletmsgtFrametframetpackingt Checkbuttonttoggletbuttontpackt getheadertextt countlinesRthtexttinserttgetbodyttypet StringTypetNonetpadtbtexttpartstrangetlenRtappendt collapsed( tselftparentRRt headertextRtbodytitp((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyt__init__ sn                      cCs|jj|jjdS(N(R!R&R"(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR&GscCs|jjdS(N(R!tdestroy(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR=IscCs|jr|jjndS(N(R5R%tinvoke(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pytshowKs cCs$|jr|jn |jdS(N(R5texplodetcollapse(R6((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR$Ns  cCsd|_x3|j|j|jfD]}|r"|jq"q"W|jrlx!|jD]}|jjqRWn|jjidd6dS(NiiR(R5R)R0R/tforgetR1R!R&(R6tcomptpart((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyRASs  cCsd|_x9|j|j|jfD]}|r"|j|jq"q"W|jrox|jD]}|jqXWn|jjidd6dS(NiiR(R5R)R0R/R&R"R1R!(R6RCRD((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR@\s  ( t__name__t __module__R<R&R=R?R$RAR@(((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR s ;     cCs\d}d}xI||krWtj|d|}|dkr@Pn|d}|d}qW|S(Nis i(tstringtfind(tstrtlimitR:tn((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyR(es  cCsBddl}ddl}ddl}|j|jdd\}}x|D] \}}qJWd}d}x:|D]2} | d dkr| d}qmtj| }qmW|j} | j|} |s| j }n| j |} t } | j }t | d||f| }|j|j| jdd|jdS(NiiRtinboxt+s+%s/%d(tsystgetopttmhlibtargvR.RGtatoitMHt openfoldert getcurrentt openmessagetTkttkRR&R?tminsizetmainloop(RNRORPtoptstargstotatmessagetfoldertargtmhtftmtrootRXR((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pytmainos0          t__main__((RGttypestTkinterRRR(RfRE(((s5/usr/lib64/python2.7/Demo/tkinter/guido/MimeViewer.pyts   Z PK!.55guido/svkill.pycnu[ Afc@sddlTedkr"ednddlmZddlmZddlZddlZejdZ de fd YZ d e fd YZ ed kre dd dZejjdejjddejndS(i(t*g@s/This version of svkill requires Tk 4.0 or later(t splitfields(tsplitNtLOGNAMEt BarButtoncBseZddZRS(cKsOttj||f||jdtt|dd|_|j|dss<1>(0RtFrameR R tBOTHtRAISEDR;tXRtfileRt add_commandtquitR"RtIntVarR&trangetlenR!tadd_radiobuttonRRt tk_menuBarR't StringVarR%tLabeltFLATtNWR@tYtWt ScrollbartVERTICALtvscrolltListboxtSUNKENtBROWSER(tyviewtRIGHTtButtontupdatetbindR6R7R8(RRRtnumR@toptiontcol((s1/usr/lib64/python2.7/Demo/tkinter/guido/svkill.pyR ?sv           (RR(s Every (-e)s-e(sNon process group leaders (-d)s-d(sNon leaders with tty (-a)s-a(RRi(s Long (-l)s-li(s Full (-f)s-fi(sFull Long (-f -l)s-l -fi(sSession and group ID (-j)s-ji(sScheduler properties (-c)s-ciN( RRtuserR!RR RR6R7R8RR (((s1/usr/lib64/python2.7/Demo/tkinter/guido/svkill.pyRs"     t__main__R=isTkinter Process Killer (SYSV)i(tTkintert TkVersiont ImportErrortstringRRR#RtenvironRrR RRRRRRR twinfo_toplevelttitletminsizetmainloop(((s1/usr/lib64/python2.7/Demo/tkinter/guido/svkill.pyts      d PK!vguido/canvasevents.pynuȯ#! /usr/bin/python2.7 from Tkinter import * from Canvas import Oval, Group, CanvasText # Fix a bug in Canvas.Group as distributed in Python 1.4. The # distributed bind() method is broken. This is what should be used: class Group(Group): def bind(self, sequence=None, command=None): return self.canvas.tag_bind(self.id, sequence, command) class Object: """Base class for composite graphical objects. Objects belong to a canvas, and can be moved around on the canvas. They also belong to at most one ``pile'' of objects, and can be transferred between piles (or removed from their pile). Objects have a canonical ``x, y'' position which is moved when the object is moved. Where the object is relative to this position depends on the object; for simple objects, it may be their center. Objects have mouse sensitivity. They can be clicked, dragged and double-clicked. The behavior may actually be determined by the pile they are in. All instance attributes are public since the derived class may need them. """ def __init__(self, canvas, x=0, y=0, fill='red', text='object'): self.canvas = canvas self.x = x self.y = y self.pile = None self.group = Group(self.canvas) self.createitems(fill, text) def __str__(self): return str(self.group) def createitems(self, fill, text): self.__oval = Oval(self.canvas, self.x-20, self.y-10, self.x+20, self.y+10, fill=fill, width=3) self.group.addtag_withtag(self.__oval) self.__text = CanvasText(self.canvas, self.x, self.y, text=text) self.group.addtag_withtag(self.__text) def moveby(self, dx, dy): if dx == dy == 0: return self.group.move(dx, dy) self.x = self.x + dx self.y = self.y + dy def moveto(self, x, y): self.moveby(x - self.x, y - self.y) def transfer(self, pile): if self.pile: self.pile.delete(self) self.pile = None self.pile = pile if self.pile: self.pile.add(self) def tkraise(self): self.group.tkraise() class Bottom(Object): """An object to serve as the bottom of a pile.""" def createitems(self, *args): self.__oval = Oval(self.canvas, self.x-20, self.y-10, self.x+20, self.y+10, fill='gray', outline='') self.group.addtag_withtag(self.__oval) class Pile: """A group of graphical objects.""" def __init__(self, canvas, x, y, tag=None): self.canvas = canvas self.x = x self.y = y self.objects = [] self.bottom = Bottom(self.canvas, self.x, self.y) self.group = Group(self.canvas, tag=tag) self.group.addtag_withtag(self.bottom.group) self.bindhandlers() def bindhandlers(self): self.group.bind('<1>', self.clickhandler) self.group.bind('', self.doubleclickhandler) def add(self, object): self.objects.append(object) self.group.addtag_withtag(object.group) self.position(object) def delete(self, object): object.group.dtag(self.group) self.objects.remove(object) def position(self, object): object.tkraise() i = self.objects.index(object) object.moveto(self.x + i*4, self.y + i*8) def clickhandler(self, event): pass def doubleclickhandler(self, event): pass class MovingPile(Pile): def bindhandlers(self): Pile.bindhandlers(self) self.group.bind('', self.motionhandler) self.group.bind('', self.releasehandler) movethis = None def clickhandler(self, event): tags = self.canvas.gettags('current') for i in range(len(self.objects)): o = self.objects[i] if o.group.tag in tags: break else: self.movethis = None return self.movethis = self.objects[i:] for o in self.movethis: o.tkraise() self.lastx = event.x self.lasty = event.y doubleclickhandler = clickhandler def motionhandler(self, event): if not self.movethis: return dx = event.x - self.lastx dy = event.y - self.lasty self.lastx = event.x self.lasty = event.y for o in self.movethis: o.moveby(dx, dy) def releasehandler(self, event): objects = self.movethis if not objects: return self.movethis = None self.finishmove(objects) def finishmove(self, objects): for o in objects: self.position(o) class Pile1(MovingPile): x = 50 y = 50 tag = 'p1' def __init__(self, demo): self.demo = demo MovingPile.__init__(self, self.demo.canvas, self.x, self.y, self.tag) def doubleclickhandler(self, event): try: o = self.objects[-1] except IndexError: return o.transfer(self.other()) MovingPile.doubleclickhandler(self, event) def other(self): return self.demo.p2 def finishmove(self, objects): o = objects[0] p = self.other() x, y = o.x, o.y if (x-p.x)**2 + (y-p.y)**2 < (x-self.x)**2 + (y-self.y)**2: for o in objects: o.transfer(p) else: MovingPile.finishmove(self, objects) class Pile2(Pile1): x = 150 y = 50 tag = 'p2' def other(self): return self.demo.p1 class Demo: def __init__(self, master): self.master = master self.canvas = Canvas(master, width=200, height=200, background='yellow', relief=SUNKEN, borderwidth=2) self.canvas.pack(expand=1, fill=BOTH) self.p1 = Pile1(self) self.p2 = Pile2(self) o1 = Object(self.canvas, fill='red', text='o1') o2 = Object(self.canvas, fill='green', text='o2') o3 = Object(self.canvas, fill='light blue', text='o3') o1.transfer(self.p1) o2.transfer(self.p1) o3.transfer(self.p2) # Main function, run when invoked as a stand-alone Python program. def main(): root = Tk() demo = Demo(root) root.protocol('WM_DELETE_WINDOW', root.quit) root.mainloop() if __name__ == '__main__': main() PK!`xIIguido/hanoi.pyonu[ ^c@sIddlTdZdddYZdZedkrEendS( i(t*cCsX|dkrdSt|d||||||||t|d||||dS(Nii(thanoi(tntatbtctreport((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyRs  tTkhanoicBs&eZddZdZdZRS(cCs||_t|_}t||_}|j|j|d|j|d}}|r|j|d|dd|dd|_nd}|d}|d} | |d|d d} } | || |} } g|_ |j | | | | d d }|j j || | | | } } |j | | | | d d }|j j || | | | } } |j | | | | d d }|j j ||jj |d }| dd}d|}gggg|_ i|_| |d| |d} } | || |} } ||dtd |d }xt|d dD]}|j | | | | d d}||j|<|j d j || || |} } | |d| |d} } |jj |jjdqFWdS(Ntwidththeightitbitmapt foregroundtbluei iitfilltblackiiitredi(RtTkttktCanvastcanvastpacktgetintt create_bitmapR tpegstcreate_rectangletappendtupdatetpegstatetpiecestmaxtrangetafter(tselfRR RRRR tpegwidtht pegheighttpegdisttx1ty1tx2ty2tpt pieceheightt maxpiecewidtht minpiecewidthtdxti((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyt__init__sP  '         cCsxt|jddd|jt|jddd|jt|jddd|jt|jddd|jt|jddd|jt|jddd|jqWdS(Niii(RRR(R ((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pytrunNscCs|j|d|kr tn|j|d=|j|}|j}|j|j|\}}}} xO|j|\} } } } | |krPn|j|dd|jjqiW|j|j|\}}}}||d}x|j|\} } } } | | d}||kr$Pn||krF|j|ddn|j|dd|jjqW| | }||t |j|d}xO|j|\} } } } | |krPn|j|dd|jjqW|j|j |dS(Niiii( Rt RuntimeErrorRRtbboxRtmoveRRtlenR(R R-RRR(Rtax1tay1tax2tay2R$R%R&R'tbx1tby1tbx2tby2t newcentertcenterR)t newbottom((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyRXs@   " "    N(t__name__t __module__tNoneR.R/R(((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyRs 1 cCsddl}ddl}|jdr>|j|jd}nd}|jdr|jd}|ddkr{|d}qd|}nd}t||}|jdS(Niiiiit@(tsyststringtargvtatoiRARR/(RCRDRR th((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pytmains     t__main__N((tTkinterRRRHR?(((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyt s  e  PK!n`  guido/electrons.pynuȯ#! /usr/bin/python2.7 # Simulate "electrons" migrating across the screen. # An optional bitmap file in can be in the background. # # Usage: electrons [n [bitmapfile]] # # n is the number of electrons to animate; default is 30. # # The bitmap file can be any X11 bitmap file (look in # /usr/include/X11/bitmaps for samples); it is displayed as the # background of the animation. Default is no bitmap. from Tkinter import * import random # The graphical interface class Electrons: # Create our objects def __init__(self, n, bitmap = None): self.n = n self.tk = tk = Tk() self.canvas = c = Canvas(tk) c.pack() width, height = tk.getint(c['width']), tk.getint(c['height']) # Add background bitmap if bitmap: self.bitmap = c.create_bitmap(width/2, height/2, bitmap=bitmap, foreground='blue') self.pieces = [] x1, y1, x2, y2 = 10,70,14,74 for i in range(n): p = c.create_oval(x1, y1, x2, y2, fill='red') self.pieces.append(p) y1, y2 = y1 +2, y2 + 2 self.tk.update() def random_move(self, n): c = self.canvas for p in self.pieces: x = random.choice(range(-2,4)) y = random.choice(range(-3,4)) c.move(p, x, y) self.tk.update() # Run -- allow 500 movemens def run(self): try: for i in range(500): self.random_move(self.n) except TclError: try: self.tk.destroy() except TclError: pass # Main program def main(): import sys, string # First argument is number of electrons, default 30 if sys.argv[1:]: n = string.atoi(sys.argv[1]) else: n = 30 # Second argument is bitmap file, default none if sys.argv[2:]: bitmap = sys.argv[2] # Reverse meaning of leading '@' compared to Tk if bitmap[0] == '@': bitmap = bitmap[1:] else: bitmap = '@' + bitmap else: bitmap = None # Create the graphical objects... h = Electrons(n, bitmap) # ...and run! h.run() # Call main when run as script if __name__ == '__main__': main() PK!-ɖ55 guido/mbox.pynuȯ#! /usr/bin/python2.7 # Scan MH folder, display results in window import os import sys import re import getopt import string import mhlib from Tkinter import * from dialog import dialog mailbox = os.environ['HOME'] + '/Mail' def main(): global root, tk, top, mid, bot global folderbox, foldermenu, scanbox, scanmenu, viewer global folder, seq global mh, mhf # Parse command line options folder = 'inbox' seq = 'all' try: opts, args = getopt.getopt(sys.argv[1:], '') except getopt.error, msg: print msg sys.exit(2) for arg in args: if arg[:1] == '+': folder = arg[1:] else: seq = arg # Initialize MH mh = mhlib.MH() mhf = mh.openfolder(folder) # Build widget hierarchy root = Tk() tk = root.tk top = Frame(root) top.pack({'expand': 1, 'fill': 'both'}) # Build right part: folder list right = Frame(top) right.pack({'fill': 'y', 'side': 'right'}) folderbar = Scrollbar(right, {'relief': 'sunken', 'bd': 2}) folderbar.pack({'fill': 'y', 'side': 'right'}) folderbox = Listbox(right, {'exportselection': 0}) folderbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) foldermenu = Menu(root) foldermenu.add('command', {'label': 'Open Folder', 'command': open_folder}) foldermenu.add('separator') foldermenu.add('command', {'label': 'Quit', 'command': 'exit'}) foldermenu.bind('', folder_unpost) folderbox['yscrollcommand'] = (folderbar, 'set') folderbar['command'] = (folderbox, 'yview') folderbox.bind('', open_folder, 1) folderbox.bind('<3>', folder_post) # Build left part: scan list left = Frame(top) left.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) scanbar = Scrollbar(left, {'relief': 'sunken', 'bd': 2}) scanbar.pack({'fill': 'y', 'side': 'right'}) scanbox = Listbox(left, {'font': 'fixed'}) scanbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'}) scanmenu = Menu(root) scanmenu.add('command', {'label': 'Open Message', 'command': open_message}) scanmenu.add('command', {'label': 'Remove Message', 'command': remove_message}) scanmenu.add('command', {'label': 'Refile Message', 'command': refile_message}) scanmenu.add('separator') scanmenu.add('command', {'label': 'Quit', 'command': 'exit'}) scanmenu.bind('', scan_unpost) scanbox['yscrollcommand'] = (scanbar, 'set') scanbar['command'] = (scanbox, 'yview') scanbox.bind('', open_message) scanbox.bind('<3>', scan_post) # Separator between middle and bottom part rule2 = Frame(root, {'bg': 'black'}) rule2.pack({'fill': 'x'}) # Build bottom part: current message bot = Frame(root) bot.pack({'expand': 1, 'fill': 'both'}) # viewer = None # Window manager commands root.minsize(800, 1) # Make window resizable # Fill folderbox with text setfolders() # Fill scanbox with text rescan() # Enter mainloop root.mainloop() def folder_post(e): x, y = e.x_root, e.y_root foldermenu.post(x - 10, y - 10) foldermenu.grab_set() def folder_unpost(e): tk.call('update', 'idletasks') foldermenu.grab_release() foldermenu.unpost() foldermenu.invoke('active') def scan_post(e): x, y = e.x_root, e.y_root scanmenu.post(x - 10, y - 10) scanmenu.grab_set() def scan_unpost(e): tk.call('update', 'idletasks') scanmenu.grab_release() scanmenu.unpost() scanmenu.invoke('active') scanparser = re.compile('^ *([0-9]+)') def open_folder(e=None): global folder, mhf sel = folderbox.curselection() if len(sel) != 1: if len(sel) > 1: msg = "Please open one folder at a time" else: msg = "Please select a folder to open" dialog(root, "Can't Open Folder", msg, "", 0, "OK") return i = sel[0] folder = folderbox.get(i) mhf = mh.openfolder(folder) rescan() def open_message(e=None): global viewer sel = scanbox.curselection() if len(sel) != 1: if len(sel) > 1: msg = "Please open one message at a time" else: msg = "Please select a message to open" dialog(root, "Can't Open Message", msg, "", 0, "OK") return cursor = scanbox['cursor'] scanbox['cursor'] = 'watch' tk.call('update', 'idletasks') i = sel[0] line = scanbox.get(i) if scanparser.match(line) >= 0: num = string.atoi(scanparser.group(1)) m = mhf.openmessage(num) if viewer: viewer.destroy() from MimeViewer import MimeViewer viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m) viewer.pack() viewer.show() scanbox['cursor'] = cursor def interestingheader(header): return header != 'received' def remove_message(e=None): itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Remove", "Please select a message to remove", "", 0, "OK") return todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) mhf.removemessages(todo) rescan() fixfocus(min(todo), itop) lastrefile = '' tofolder = None def refile_message(e=None): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder to refile to" else: msg = "Please select exactly one folder to refile to" dialog(root, "No Folder To Refile", msg, "", 0, "OK") return refileto = folderbox.get(foldersel[0]) todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) if lastrefile != refileto or not tofolder: lastrefile = refileto tofolder = None tofolder = mh.openfolder(lastrefile) mhf.refilemessages(todo, tofolder) rescan() fixfocus(min(todo), itop) def fixfocus(near, itop): n = scanbox.size() for i in range(n): line = scanbox.get(repr(i)) if scanparser.match(line) >= 0: num = string.atoi(scanparser.group(1)) if num >= near: break else: i = 'end' scanbox.select_from(i) scanbox.yview(itop) def setfolders(): folderbox.delete(0, 'end') for fn in mh.listallfolders(): folderbox.insert('end', fn) def rescan(): global viewer if viewer: viewer.destroy() viewer = None scanbox.delete(0, 'end') for line in scanfolder(folder, seq): scanbox.insert('end', line) def scanfolder(folder = 'inbox', sequence = 'all'): return map( lambda line: line[:-1], os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()) main() PK!LLguido/ShellWindow.pynu[import os import sys import string from Tkinter import * from ScrolledText import ScrolledText from Dialog import Dialog import signal BUFSIZE = 512 class ShellWindow(ScrolledText): def __init__(self, master=None, shell=None, **cnf): if not shell: try: shell = os.environ['SHELL'] except KeyError: shell = '/bin/sh' shell = shell + ' -i' args = string.split(shell) shell = args[0] apply(ScrolledText.__init__, (self, master), cnf) self.pos = '1.0' self.bind('', self.inputhandler) self.bind('', self.sigint) self.bind('', self.sigterm) self.bind('', self.sigkill) self.bind('', self.sendeof) self.pid, self.fromchild, self.tochild = spawn(shell, args) self.tk.createfilehandler(self.fromchild, READABLE, self.outputhandler) def outputhandler(self, file, mask): data = os.read(file, BUFSIZE) if not data: self.tk.deletefilehandler(file) pid, sts = os.waitpid(self.pid, 0) print 'pid', pid, 'status', sts self.pid = None detail = sts>>8 cause = sts & 0xff if cause == 0: msg = "exit status %d" % detail else: msg = "killed by signal %d" % (cause & 0x7f) if cause & 0x80: msg = msg + " -- core dumped" Dialog(self.master, text=msg, title="Exit status", bitmap='warning', default=0, strings=('OK',)) return self.insert(END, data) self.pos = self.index("end - 1 char") self.yview_pickplace(END) def inputhandler(self, *args): if not self.pid: self.no_process() return "break" self.insert(END, "\n") line = self.get(self.pos, "end - 1 char") self.pos = self.index(END) os.write(self.tochild, line) return "break" def sendeof(self, *args): if not self.pid: self.no_process() return "break" os.close(self.tochild) return "break" def sendsig(self, sig): if not self.pid: self.no_process() return "break" os.kill(self.pid, sig) return "break" def sigint(self, *args): return self.sendsig(signal.SIGINT) def sigquit(self, *args): return self.sendsig(signal.SIGQUIT) def sigterm(self, *args): return self.sendsig(signal.SIGTERM) def sigkill(self, *args): return self.sendsig(signal.SIGKILL) def no_process(self): Dialog(self.master, text="No active process", title="No process", bitmap='error', default=0, strings=('OK',)) MAXFD = 100 # Max number of file descriptors (os.getdtablesize()???) def spawn(prog, args): p2cread, p2cwrite = os.pipe() c2pread, c2pwrite = os.pipe() pid = os.fork() if pid == 0: # Child for i in 0, 1, 2: try: os.close(i) except os.error: pass if os.dup(p2cread) <> 0: sys.stderr.write('popen2: bad read dup\n') if os.dup(c2pwrite) <> 1: sys.stderr.write('popen2: bad write dup\n') if os.dup(c2pwrite) <> 2: sys.stderr.write('popen2: bad write dup\n') os.closerange(3, MAXFD) try: os.execvp(prog, args) finally: sys.stderr.write('execvp failed\n') os._exit(1) os.close(p2cread) os.close(c2pwrite) return pid, c2pread, p2cwrite def test(): shell = string.join(sys.argv[1:]) root = Tk() root.minsize(1, 1) if shell: w = ShellWindow(root, shell=shell) else: w = ShellWindow(root) w.pack(expand=1, fill=BOTH) w.focus_set() w.tk.mainloop() if __name__ == '__main__': test() PK!j'guido/imagedraw.pynu["""Draw on top of an image""" from Tkinter import * import sys def main(): filename = sys.argv[1] root = Tk() img = PhotoImage(file=filename) w, h = img.width(), img.height() canv = Canvas(root, width=w, height=h) canv.create_image(0, 0, anchor=NW, image=img) canv.pack() canv.bind('', blob) root.mainloop() def blob(event): x, y = event.x, event.y canv = event.widget r = 5 canv.create_oval(x-r, y-r, x+r, y+r, fill='red', outline="") main() PK!&S}E}Eguido/solitaire.pynuȯ#! /usr/bin/python2.7 """Solitaire game, much like the one that comes with MS Windows. Limitations: - No cute graphical images for the playing cards faces or backs. - No scoring or timer. - No undo. - No option to turn 3 cards at a time. - No keyboard shortcuts. - Less fancy animation when you win. - The determination of which stack you drag to is more relaxed. Apology: I'm not much of a card player, so my terminology in these comments may at times be a little unusual. If you have suggestions, please let me know! """ # Imports import math import random from Tkinter import * from Canvas import Rectangle, CanvasText, Group, Window # Fix a bug in Canvas.Group as distributed in Python 1.4. The # distributed bind() method is broken. Rather than asking you to fix # the source, we fix it here by deriving a subclass: class Group(Group): def bind(self, sequence=None, command=None): return self.canvas.tag_bind(self.id, sequence, command) # Constants determining the size and lay-out of cards and stacks. We # work in a "grid" where each card/stack is surrounded by MARGIN # pixels of space on each side, so adjacent stacks are separated by # 2*MARGIN pixels. OFFSET is the offset used for displaying the # face down cards in the row stacks. CARDWIDTH = 100 CARDHEIGHT = 150 MARGIN = 10 XSPACING = CARDWIDTH + 2*MARGIN YSPACING = CARDHEIGHT + 4*MARGIN OFFSET = 5 # The background color, green to look like a playing table. The # standard green is way too bright, and dark green is way to dark, so # we use something in between. (There are a few more colors that # could be customized, but they are less controversial.) BACKGROUND = '#070' # Suits and colors. The values of the symbolic suit names are the # strings used to display them (you change these and VALNAMES to # internationalize the game). The COLOR dictionary maps suit names to # colors (red and black) which must be Tk color names. The keys() of # the COLOR dictionary conveniently provides us with a list of all # suits (in arbitrary order). HEARTS = 'Heart' DIAMONDS = 'Diamond' CLUBS = 'Club' SPADES = 'Spade' RED = 'red' BLACK = 'black' COLOR = {} for s in (HEARTS, DIAMONDS): COLOR[s] = RED for s in (CLUBS, SPADES): COLOR[s] = BLACK ALLSUITS = COLOR.keys() NSUITS = len(ALLSUITS) # Card values are 1-13. We also define symbolic names for the picture # cards. ALLVALUES is a list of all card values. ACE = 1 JACK = 11 QUEEN = 12 KING = 13 ALLVALUES = range(1, 14) # (one more than the highest value) NVALUES = len(ALLVALUES) # VALNAMES is a list that maps a card value to string. It contains a # dummy element at index 0 so it can be indexed directly with the card # value. VALNAMES = ["", "A"] + map(str, range(2, 11)) + ["J", "Q", "K"] # Solitaire constants. The only one I can think of is the number of # row stacks. NROWS = 7 # The rest of the program consists of class definitions. These are # further described in their documentation strings. class Card: """A playing card. A card doesn't record to which stack it belongs; only the stack records this (it turns out that we always know this from the context, and this saves a ``double update'' with potential for inconsistencies). Public methods: moveto(x, y) -- move the card to an absolute position moveby(dx, dy) -- move the card by a relative offset tkraise() -- raise the card to the top of its stack showface(), showback() -- turn the card face up or down & raise it Public read-only instance variables: suit, value, color -- the card's suit, value and color face_shown -- true when the card is shown face up, else false Semi-public read-only instance variables (XXX should be made private): group -- the Canvas.Group representing the card x, y -- the position of the card's top left corner Private instance variables: __back, __rect, __text -- the canvas items making up the card (To show the card face up, the text item is placed in front of rect and the back is placed behind it. To show it face down, this is reversed. The card is created face down.) """ def __init__(self, suit, value, canvas): """Card constructor. Arguments are the card's suit and value, and the canvas widget. The card is created at position (0, 0), with its face down (adding it to a stack will position it according to that stack's rules). """ self.suit = suit self.value = value self.color = COLOR[suit] self.face_shown = 0 self.x = self.y = 0 self.group = Group(canvas) text = "%s %s" % (VALNAMES[value], suit) self.__text = CanvasText(canvas, CARDWIDTH//2, 0, anchor=N, fill=self.color, text=text) self.group.addtag_withtag(self.__text) self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT, outline='black', fill='white') self.group.addtag_withtag(self.__rect) self.__back = Rectangle(canvas, MARGIN, MARGIN, CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN, outline='black', fill='blue') self.group.addtag_withtag(self.__back) def __repr__(self): """Return a string for debug print statements.""" return "Card(%r, %r)" % (self.suit, self.value) def moveto(self, x, y): """Move the card to absolute position (x, y).""" self.moveby(x - self.x, y - self.y) def moveby(self, dx, dy): """Move the card by (dx, dy).""" self.x = self.x + dx self.y = self.y + dy self.group.move(dx, dy) def tkraise(self): """Raise the card above all other objects in its canvas.""" self.group.tkraise() def showface(self): """Turn the card's face up.""" self.tkraise() self.__rect.tkraise() self.__text.tkraise() self.face_shown = 1 def showback(self): """Turn the card's face down.""" self.tkraise() self.__rect.tkraise() self.__back.tkraise() self.face_shown = 0 class Stack: """A generic stack of cards. This is used as a base class for all other stacks (e.g. the deck, the suit stacks, and the row stacks). Public methods: add(card) -- add a card to the stack delete(card) -- delete a card from the stack showtop() -- show the top card (if any) face up deal() -- delete and return the top card, or None if empty Method that subclasses may override: position(card) -- move the card to its proper (x, y) position The default position() method places all cards at the stack's own (x, y) position. userclickhandler(), userdoubleclickhandler() -- called to do subclass specific things on single and double clicks The default user (single) click handler shows the top card face up. The default user double click handler calls the user single click handler. usermovehandler(cards) -- called to complete a subpile move The default user move handler moves all moved cards back to their original position (by calling the position() method). Private methods: clickhandler(event), doubleclickhandler(event), motionhandler(event), releasehandler(event) -- event handlers The default event handlers turn the top card of the stack with its face up on a (single or double) click, and also support moving a subpile around. startmoving(event) -- begin a move operation finishmoving() -- finish a move operation """ def __init__(self, x, y, game=None): """Stack constructor. Arguments are the stack's nominal x and y position (the top left corner of the first card placed in the stack), and the game object (which is used to get the canvas; subclasses use the game object to find other stacks). """ self.x = x self.y = y self.game = game self.cards = [] self.group = Group(self.game.canvas) self.group.bind('<1>', self.clickhandler) self.group.bind('', self.doubleclickhandler) self.group.bind('', self.motionhandler) self.group.bind('', self.releasehandler) self.makebottom() def makebottom(self): pass def __repr__(self): """Return a string for debug print statements.""" return "%s(%d, %d)" % (self.__class__.__name__, self.x, self.y) # Public methods def add(self, card): self.cards.append(card) card.tkraise() self.position(card) self.group.addtag_withtag(card.group) def delete(self, card): self.cards.remove(card) card.group.dtag(self.group) def showtop(self): if self.cards: self.cards[-1].showface() def deal(self): if not self.cards: return None card = self.cards[-1] self.delete(card) return card # Subclass overridable methods def position(self, card): card.moveto(self.x, self.y) def userclickhandler(self): self.showtop() def userdoubleclickhandler(self): self.userclickhandler() def usermovehandler(self, cards): for card in cards: self.position(card) # Event handlers def clickhandler(self, event): self.finishmoving() # In case we lost an event self.userclickhandler() self.startmoving(event) def motionhandler(self, event): self.keepmoving(event) def releasehandler(self, event): self.keepmoving(event) self.finishmoving() def doubleclickhandler(self, event): self.finishmoving() # In case we lost an event self.userdoubleclickhandler() self.startmoving(event) # Move internals moving = None def startmoving(self, event): self.moving = None tags = self.game.canvas.gettags('current') for i in range(len(self.cards)): card = self.cards[i] if card.group.tag in tags: break else: return if not card.face_shown: return self.moving = self.cards[i:] self.lastx = event.x self.lasty = event.y for card in self.moving: card.tkraise() def keepmoving(self, event): if not self.moving: return dx = event.x - self.lastx dy = event.y - self.lasty self.lastx = event.x self.lasty = event.y if dx or dy: for card in self.moving: card.moveby(dx, dy) def finishmoving(self): cards = self.moving self.moving = None if cards: self.usermovehandler(cards) class Deck(Stack): """The deck is a stack with support for shuffling. New methods: fill() -- create the playing cards shuffle() -- shuffle the playing cards A single click moves the top card to the game's open deck and moves it face up; if we're out of cards, it moves the open deck back to the deck. """ def makebottom(self): bottom = Rectangle(self.game.canvas, self.x, self.y, self.x+CARDWIDTH, self.y+CARDHEIGHT, outline='black', fill=BACKGROUND) self.group.addtag_withtag(bottom) def fill(self): for suit in ALLSUITS: for value in ALLVALUES: self.add(Card(suit, value, self.game.canvas)) def shuffle(self): n = len(self.cards) newcards = [] for i in randperm(n): newcards.append(self.cards[i]) self.cards = newcards def userclickhandler(self): opendeck = self.game.opendeck card = self.deal() if not card: while 1: card = opendeck.deal() if not card: break self.add(card) card.showback() else: self.game.opendeck.add(card) card.showface() def randperm(n): """Function returning a random permutation of range(n).""" r = range(n) x = [] while r: i = random.choice(r) x.append(i) r.remove(i) return x class OpenStack(Stack): def acceptable(self, cards): return 0 def usermovehandler(self, cards): card = cards[0] stack = self.game.closeststack(card) if not stack or stack is self or not stack.acceptable(cards): Stack.usermovehandler(self, cards) else: for card in cards: self.delete(card) stack.add(card) self.game.wincheck() def userdoubleclickhandler(self): if not self.cards: return card = self.cards[-1] if not card.face_shown: self.userclickhandler() return for s in self.game.suits: if s.acceptable([card]): self.delete(card) s.add(card) self.game.wincheck() break class SuitStack(OpenStack): def makebottom(self): bottom = Rectangle(self.game.canvas, self.x, self.y, self.x+CARDWIDTH, self.y+CARDHEIGHT, outline='black', fill='') def userclickhandler(self): pass def userdoubleclickhandler(self): pass def acceptable(self, cards): if len(cards) != 1: return 0 card = cards[0] if not self.cards: return card.value == ACE topcard = self.cards[-1] return card.suit == topcard.suit and card.value == topcard.value + 1 class RowStack(OpenStack): def acceptable(self, cards): card = cards[0] if not self.cards: return card.value == KING topcard = self.cards[-1] if not topcard.face_shown: return 0 return card.color != topcard.color and card.value == topcard.value - 1 def position(self, card): y = self.y for c in self.cards: if c == card: break if c.face_shown: y = y + 2*MARGIN else: y = y + OFFSET card.moveto(self.x, y) class Solitaire: def __init__(self, master): self.master = master self.canvas = Canvas(self.master, background=BACKGROUND, highlightthickness=0, width=NROWS*XSPACING, height=3*YSPACING + 20 + MARGIN) self.canvas.pack(fill=BOTH, expand=TRUE) self.dealbutton = Button(self.canvas, text="Deal", highlightthickness=0, background=BACKGROUND, activebackground="green", command=self.deal) Window(self.canvas, MARGIN, 3*YSPACING + 20, window=self.dealbutton, anchor=SW) x = MARGIN y = MARGIN self.deck = Deck(x, y, self) x = x + XSPACING self.opendeck = OpenStack(x, y, self) x = x + XSPACING self.suits = [] for i in range(NSUITS): x = x + XSPACING self.suits.append(SuitStack(x, y, self)) x = MARGIN y = y + YSPACING self.rows = [] for i in range(NROWS): self.rows.append(RowStack(x, y, self)) x = x + XSPACING self.openstacks = [self.opendeck] + self.suits + self.rows self.deck.fill() self.deal() def wincheck(self): for s in self.suits: if len(s.cards) != NVALUES: return self.win() self.deal() def win(self): """Stupid animation when you win.""" cards = [] for s in self.openstacks: cards = cards + s.cards while cards: card = random.choice(cards) cards.remove(card) self.animatedmoveto(card, self.deck) def animatedmoveto(self, card, dest): for i in range(10, 0, -1): dx, dy = (dest.x-card.x)//i, (dest.y-card.y)//i card.moveby(dx, dy) self.master.update_idletasks() def closeststack(self, card): closest = None cdist = 999999999 # Since we only compare distances, # we don't bother to take the square root. for stack in self.openstacks: dist = (stack.x - card.x)**2 + (stack.y - card.y)**2 if dist < cdist: closest = stack cdist = dist return closest def deal(self): self.reset() self.deck.shuffle() for i in range(NROWS): for r in self.rows[i:]: card = self.deck.deal() r.add(card) for r in self.rows: r.showtop() def reset(self): for stack in self.openstacks: while 1: card = stack.deal() if not card: break self.deck.add(card) card.showback() # Main function, run when invoked as a stand-alone Python program. def main(): root = Tk() game = Solitaire(root) root.protocol('WM_DELETE_WINDOW', root.quit) root.mainloop() if __name__ == '__main__': main() PK!"@@guido/kill.pycnu[ Afc@sddlTddlmZddlmZddlZddlZdefdYZdefdYZ e d kre dd d Z e j jd e j jd d e jndS(i(t*(t splitfields(tsplitNt BarButtoncBseZddZRS(cKsOttj||f||jdtt|dd|_|j|dss<1>(,tFrameR R tBOTHtRAISEDRCtXRtfileRt add_commandtquittviewtIntVarRR*trangetlenRtadd_radiobuttonR"t tk_menuBarR+t StringVarR)tLabeltFLATtNWRHt ScrollbartVERTICALR,tListboxtSUNKENR-R1tRIGHTtYtButtontupdatetbindR>R?R@(R RRtnum((s//usr/lib64/python2.7/Demo/tkinter/guido/kill.pyR 2sP    (RRi(Rs-li(Rs-ui(Rs-ji(Rs-si(Rs-mi(Rs-vi(Rs-XiN( RRRR&R"R>R?R@RR (((s//usr/lib64/python2.7/Demo/tkinter/guido/kill.pyRs     t__main__REisTkinter Process Killeri(tTkintertstringRRR'R RRRURRRR&twinfo_toplevelttitletminsizetmainloop(((s//usr/lib64/python2.7/Demo/tkinter/guido/kill.pyts   M PK!^ui i guido/switch.pycnu[ ^c@sfddlTdd dYZdd dYZdd dYZdZed krbend S(i(t*tAppcBs)eZdddZdZdZRS(cCs|dkr3|dkr$t}q3t|}n||_t||_|jjt|dddt|_|jjdddt i|_ d|_ dS(Nt borderwidthitrelieftexpanditfill( tNonetTktToplevelttoptFramet buttonframetpacktGROOVEt panelframetBOTHtpanelstcurpanel(tselfR tmaster((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyt__init__s      cCst|jd|d||d}|jdtt|j}||}|||f|j|<|jdkr|j |ndS(NttexttcommandcSs |j|S(N(tshow(Rtname((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pytttside( tButtonR R tLEFTR RRRRR(RRtklasstbuttontframetinstance((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pytaddpanels cCsR|j|\}}}|jr/|jjn||_|jdddddS(NRiRtboth(RRt pack_forgetR (RRRR R!((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyRs   N(t__name__t __module__RRR"R(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyRs t LabelPanelcBseZdZRS(cCs&t|dd|_|jjdS(NRs Hello world(tLabeltlabelR (RR ((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR's(R%R&R(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR'&st ButtonPanelcBseZdZRS(cCs&t|dd|_|jjdS(NRsPress me(RRR (RR ((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR,s(R%R&R(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyR*+scCs:t}|jdt|jdt|jjdS(NR)R(RR"R'R*R tmainloop(tapp((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pytmain0s t__main__N((((tTkinterRR'R*R-R%(((s1/usr/lib64/python2.7/Demo/tkinter/guido/switch.pyts !  PK!1guido/switch.pynu[# Show how to do switchable panels. from Tkinter import * class App: def __init__(self, top=None, master=None): if top is None: if master is None: top = Tk() else: top = Toplevel(master) self.top = top self.buttonframe = Frame(top) self.buttonframe.pack() self.panelframe = Frame(top, borderwidth=2, relief=GROOVE) self.panelframe.pack(expand=1, fill=BOTH) self.panels = {} self.curpanel = None def addpanel(self, name, klass): button = Button(self.buttonframe, text=name, command=lambda self=self, name=name: self.show(name)) button.pack(side=LEFT) frame = Frame(self.panelframe) instance = klass(frame) self.panels[name] = (button, frame, instance) if self.curpanel is None: self.show(name) def show(self, name): (button, frame, instance) = self.panels[name] if self.curpanel: self.curpanel.pack_forget() self.curpanel = frame frame.pack(expand=1, fill="both") class LabelPanel: def __init__(self, frame): self.label = Label(frame, text="Hello world") self.label.pack() class ButtonPanel: def __init__(self, frame): self.button = Button(frame, text="Press me") self.button.pack() def main(): app = App() app.addpanel("label", LabelPanel) app.addpanel("button", ButtonPanel) app.top.mainloop() if __name__ == '__main__': main() PK!~H+guido/ShellWindow.pyonu[ ^c@sddlZddlZddlZddlTddlmZddlmZddlZdZdefdYZdZ d Z d Z e d kre ndS( iN(t*(t ScrolledText(tDialogit ShellWindowcBsheZd d dZdZdZdZdZdZdZ dZ dZ d Z RS( cKs|s>ytjd}Wntk r0d}nX|d}ntj|}|d}ttj||f|d|_|j d|j |j d|j |j d|j |j d |j |j d |jt||\|_|_|_|jj|jt|jdS( NtSHELLs/bin/shs -iis1.0ss s s s (tostenvirontKeyErrortstringtsplittapplyRt__init__tpostbindt inputhandlertsiginttsigtermtsigkilltsendeoftspawntpidt fromchildttochildttktcreatefilehandlertREADABLEt outputhandler(tselftmastertshelltcnftargs((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR s$     !c Cstj|t}|s|jj|tj|jd\}}dG|GdG|GHd|_|d?}|d@}|dkrd|}n%d|d@}|d @r|d }nt|j d |d d dddddddS|j t ||j d|_ |jt dS(NiRtstatusiisexit status %dskilled by signal %diis -- core dumpedttextttitles Exit statustbitmaptwarningtdefaulttstringstOKs end - 1 char(R'(RtreadtBUFSIZERtdeletefilehandlertwaitpidRtNoneRRtinserttENDtindexR tyview_pickplace( RtfiletmasktdataRtststdetailtcausetmsg((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR#s.        cGse|js|jdS|jtd|j|jd}|jt|_tj|j |dS(Ntbreaks s end - 1 char( Rt no_processR-R.tgetR R/RtwriteR(RRtline((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR=s  cGs+|js|jdStj|jdS(NR8(RR9RtcloseR(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyRGs   cCs.|js|jdStj|j|dS(NR8(RR9Rtkill(Rtsig((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pytsendsigNs   cGs|jtjS(N(R@tsignaltSIGINT(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyRUscGs|jtjS(N(R@RAtSIGQUIT(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pytsigquitXscGs|jtjS(N(R@RAtSIGTERM(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR[scGs|jtjS(N(R@RAtSIGKILL(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR^sc Cs/t|jddddddddd d dS( NR!sNo active processR"s No processR#terrorR%iR&R'(R'(RR(R((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR9as  N( t__name__t __module__R,R RRRR@RRDRRR9(((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR s       idcCs\tj\}}tj\}}tj}|dkr5x6dD].}ytj|WqCtjk rpqCXqCWtj|dkrtjjdntj|dkrtjjdntj|dkrtjjdntj dt ztj ||Wdtjjdtj dXntj|tj||||fS( Niiispopen2: bad read dup spopen2: bad write dup isexecvp failed (iii( RtpipetforkR=RGtduptsyststderrR;t closerangetMAXFDtexecvpt_exit(tprogRtp2creadtp2cwritetc2preadtc2pwriteRti((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyRks.     cCstjtjd}t}|jdd|rJt|d|}n t|}|jdddt|j |j j dS(NiRtexpandtfill( RtjoinRMtargvtTktminsizeRtpacktBOTHt focus_setRtmainloop(Rtroottw((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyttests   t__main__( RRMRtTkinterRRRAR)RRPRReRH(((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyts     ^  PK!Dguido/optionmenu.pynu[# option menu sample (Fredrik Lundh, September 1997) from Tkinter import * root = Tk() # # standard usage var1 = StringVar() var1.set("One") # default selection menu1 = OptionMenu(root, var1, "One", "Two", "Three") menu1.pack() # # initialize from a sequence CHOICES = "Aah", "Bee", "Cee", "Dee", "Eff" var2 = StringVar() var2.set(CHOICES[0]) menu2 = apply(OptionMenu, (root, var2) + tuple(CHOICES)) menu2.pack() root.mainloop() PK!kK\\guido/sortvisu.pycnu[ Afc@sdZddlTddlmZmZddlZdZdZdZdddYZ d dd YZ d Z d Z d Z dZdZdZdZdZdZdZdddYZdZedkrendS(sjSorting algorithms visualizer using Tkinter. This module is comprised of three ``components'': - an array visualizer with methods that implement basic sorting operations (compare, swap) as well as methods for ``annotating'' the sorting algorithm (e.g. to show the pivot element); - a number of sorting algorithms (currently quicksort, insertion sort, selection sort and bubble sort, as well as a randomization function), all using the array visualizer for its basic operations and with calls to its annotation methods; - and a ``driver'' class which can be used as a Grail applet or as a stand-alone application. i(t*(tLinet RectangleNi itArraycBseZddZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs||_t|j|_|jjdtt|j|_|jjt|j|_|jjt|j|_ |j jt |jdddd|_ t |jdddd|_ t |jdddd|_ g|_d|_|_|r|j|ndS(Ntfilli(tmastertFrametframetpacktXtLabeltlabeltCanvastcanvastreportRtlefttrighttpivottitemstsizetmaxvaluetsetdata(tselfRtdata((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt__init__"s      cCs|j}g|_x|D]}|jqWt||_t||_|jjd|jdtd|jdt x7t |jD]&}|jj t ||||qW|j d|jdS(NtwidthitheightsSort demo, size %d(RtdeletetlenRtmaxRR tconfigtXGRIDtYGRIDtrangetappendt ArrayItemtreset(RRtolditemstitemti((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR4s   $tnormalcCs ||_dS(N(tspeed(RR)((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytsetspeedCscCs|jjdS(N(Rtdestroy(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR+FsicCs&d|_|jr"|jjndS(Ni(t stop_mainloopt in_mainloopRtquit(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytcancelLs  cCs|jr|jjndS(N(R-RR.(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytstepQs sArray.CancelledcCs|jdkrd}n4|jdkr4|d}n|jdkrLd}n|js|jj|jj||jj}d|_|jj|jj|d|_n|jrd|_|j dt j ndS( Ntfastestitfasti s single-stepiʚ;it Cancelled( R)R,RtupdatetafterR.R-tmainloopt after_canceltmessageRR3(Rtmsecstid((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytwaitWs"           cCs|jS(N(R(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytgetsizejscCszxit|jD]X}|j|}||ko:|knrU|jjddq|jjddqW|jdS(NRtredtorange(R!RRR&Rthide_left_right_pivot(RtfirsttlastR'R&((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytshow_partitionms  cCsHx7t|jD]&}|j|}|jjddqW|jdS(NRR=(R!RRR&RR?(RR'R&((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pythide_partitionvs cCsd|ko|jkns-|jdS|j|j\}}}}|jj|ddf|ddfg|jjdS(Niii'(Rt hide_leftRtpositionRtcoordsRR4(RRtx1ty1tx2ty2((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt show_left|s  *cCsd|ko|jkns-|jdS|j|j\}}}}|jj|ddf|ddff|jjdS(Niii'(Rt hide_rightRRERRFRR4(RRRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt show_rights  *cCs"|j|j|jdS(N(RDRLt hide_pivot(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR?s  cCs|jjddfdS(Ni(ii(ii(RRF(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRDscCs|jjddfdS(Ni(ii(ii(RRF(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRLscCsM|j|j\}}}}|jjd|dfd|dffdS(Niii'(RRERRF(RRRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt show_pivotscCs|jjddfdS(Ni(ii(ii(RRF(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRNscCs`||krdS|j|j|}|j|}|||j|<|j|<|j|dS(N(t countswapRtswapwith(RR'tjR&tother((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytswaps    cCs1|j|j|}|j|}|j|S(N(t countcompareRt compareto(RR'RRR&RS((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytcompares   cCs7d|_d|_|j||j|jdS(Ni(t ncomparestnswapsR8t updatereportRC(Rtmsg((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR$s     cCs|jjd|dS(Nttext(R R(RR[((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR8scCs|jd|_|jdS(Ni(RYRZ(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRPscCs|jd|_|jdS(Ni(RXRZ(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRUscCs-d|j|jf}|jjd|dS(Ns%d cmps, %d swapsR\(RXRYRR(RR\((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRZsN(t__name__t __module__tNoneRRR)R*R+R-R,R/R0R3R;R<RBRCRKRMR?RDRLRORNRTRWR$R8RPRURZ(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR s8                     R#cBsbeZdZdZdZdZdZdZdZdZ dZ d Z RS( c Cs||_||_||_|j\}}}}t|j||||dddddd|_|jjd|j|jjd|j |jjd |j dS( NRR=toutlinetblackRis ss( tarraytindextvalueRERR R&tbindt mouse_downt mouse_movetmouse_up(RRbRcRdRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs   cCs)|j}d|_d|_|jdS(N(R&R_RbR(RR&((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs   cCsA|j|_|j|_|j|_|j|_|jjdS(N(txtlastxtytlastytorigxtorigyR&ttkraise(Rtevent((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRfs     cCsC|jj|j|j|j|j|j|_|j|_dS(N(R&tmoveRiRjRkRl(RRp((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRgs' c Cs|j|j}||jjkr=|jjd}n|dkrRd}n|jj|}|j}|||jj|<|jj|<||_|j\}}}}|jj||f||ff|j |dS(Nii( t nearestindexRiRbR<RRcRER&RFtsetindex( RRpR'RSthereRGRHRIRJ((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRhs   ! "cCst|j|}|sdS|jjdkr7d}n|j}||_|j}t|||}|jjx<|D]4}|jj|d |df|jj dq~WdS(NR1iii2( tstepsRcRbR)REt interpolateR&RoRFR;(RRctnstepstoldptstnewptst trajectorytpts((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRss      cCst|j|j}|sdS|jjdkr:d}n|j}|j}|j|j|_|_|j}|j}|jd}|jd}|jjdd|jjdd|jjj|jjdkrk|jj |d |df|jj |d |df|jjj|jjd||jjd||jj ddSt |||} t |||} |j |j kr|jj |jj n|jj |jj zxztt| D]f} | | } | | } |jj | d | df|jj | d | df|jj dqWWd| d } | d } |jj | d | df|jj | d | df|jjd||jjd|XdS( NR1iRtgreentyellows single-stepii2i(RuRcRbR)RER&RRR4RFR;RvRdRoR!R(RRSRwtmyoldptst otheroldptstmynewptst othernewptstmyfillt otherfillt mytrajectorytothertrajectoryR'tmyptstotherpts((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRQsV              cCs|jd}|jd}t|j|j}|dkrJd}d}n%|dkred}d}n d}}z:|jjd||jjd||jjdWd|jjd||jjd|X|S(NRitwhiteRatgreyi(R&tcmpRdRRbR;(RRSRRtoutcometmyflasht otherflash((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRV-s"       cCsX|jdttd}|t}|jjdt}||jt}||||fS(Nii(RcRtWIDTHRbRR Rd(RRGRIRJRH((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyREBs  cCsttt|tdS(Ni(tinttroundtfloatR(RRi((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRrIs( R]R^RRRfRgRhRsRQRVRERr(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR#s      .  cCs[t||}|dkr)|d}n.|dkrB|d}n|dkrWd}n|S(Niiii (tabs(RttthereRw((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRuOs      cCst|t|kr$tdndgt|}t|g}xmtd|D]\}x@tt|D],}|||||||||||j || fn| dkr.|j | |fq.q.W|jdWd|j XdS(Nt QuicksortiiisInsertion sortisChoosing pivotisPivot at left of partitionisSweep right pointersSweep left pointersEnd of partitions Swap itemssSwap pivot backR( R<R$RBR8R!RWRTROR;RMRKR"RC( RbRtstackR@RAR'RRRRRRtn1tn2((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyt quicksortsx             '    '         cCs<x5x.ttttgD]}t|||qWqWdS(N(RRRRR(Rbtalg((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytdemosorts tSortDemocBseZddZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZRS(icCs||_||_d|_t|j|_t||_|jjdtt|j|_ |j jdt dt t|j|_ |j jdt dt t|j ddd|j|_|jjdtt|j ddd|j|_|jjdtt|j ddd|j|_|jjdtt|j dd d|j|_|jjdtd tfd Y}||j||_|jj|d d ddgtddd}|j|kr|j|j|jntt|j |jft ||_!|j!jdtt"|j|_#|j#jdt|j |j#dddd|_$|j$jdtt|j ddd|j%|_&|j&jdtt|j ddd|j'|_(|j(jdtt|j ddd|j)|_*|j*jdtt|j ddd|j+|_,|j,jdtt|j ddd|j-|_.|j.jdtt|j ddd|j/|_0|j0jdt|j0j1dt2t|j ddd|j3|_4|j4jdtdS(NitsideRR\RtcommandsInsertion sortsSelection sorts Bubble sorttMyIntVarcBseZdZdZRS(cSs||_tj||dS(N(tdemotIntVarR(RRR((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs cSs9tj||t|dkr5|jj|ndS(Nt0(RtsettstrRtresize(RRd((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs(R]R^RR(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs iiiiii7R(s single-stepR2R1tStept RandomizetUniformtDistincttDemotCanceltstatetQuit(5RRtbusyRRbRtbotframeRtBOTTOMt botleftframetLEFTtYt botrightframetRIGHTtButtontc_qsorttb_qsortR tc_isorttb_isorttc_ssorttb_ssorttc_bsorttb_bsortRtv_sizeRR!R"tsorttapplyt OptionMenuRtm_sizet StringVartv_speedtm_speedtc_steptb_stept c_randomizet b_randomizet c_uniformt b_uniformt c_distinctt b_distincttc_demotb_demotc_canceltb_cancelRtDISABLEDtc_quittb_quit(RRRRtsizes((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRsv        " "       cCsG|jr|jjdS||_|jjtd|jddS(Ni(RRtbellRRbRR!(Rtnewsize((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR0s    cCs|jtdS(N(trunR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR7scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR:scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR=scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR@scCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRCscCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRFscCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRIscCs|jtdS(N(RR(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRLscCs|jr|jjdSd|_|jj|jj|jjdt y||jWnt j k rvnX|jjdt d|_dS(NiRi( RRRRbR*RtgetRRtNORMALRR3R(Rtfunc((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyROs   cCs+|js|jjdS|jjdS(N(RRRRbR/(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyR]s  cCsK|js|jjdS|jjd|jjd|jjdS(Ns single-step(RRRRRRbR*R0(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRcs   cCs3|jr|jjn|jj|jjdS(N(RRbR/Rt after_idleR.(R((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRks (R]R^RRRRRRRRRRRRRR(((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyRs L            cCs6t}t|}|jd|j|jdS(NtWM_DELETE_WINDOW(tTkRtprotocolRR6(trootR((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pytmainss  t__main__((((t__doc__tTkinterR RRRRR RRR#RuRvRRRRRRRRRRR](((s3/usr/lib64/python2.7/Demo/tkinter/guido/sortvisu.pyts,       =   PK!˗*KKguido/hello.pynu[# Display hello, world in a button; clicking it quits the program import sys from Tkinter import * def main(): root = Tk() button = Button(root) button['text'] = 'Hello, world' button['command'] = quit_callback # See below button.pack() root.mainloop() def quit_callback(): sys.exit(0) main() PK!)YzKKguido/sortvisu.pynuȯ#! /usr/bin/python2.7 """Sorting algorithms visualizer using Tkinter. This module is comprised of three ``components'': - an array visualizer with methods that implement basic sorting operations (compare, swap) as well as methods for ``annotating'' the sorting algorithm (e.g. to show the pivot element); - a number of sorting algorithms (currently quicksort, insertion sort, selection sort and bubble sort, as well as a randomization function), all using the array visualizer for its basic operations and with calls to its annotation methods; - and a ``driver'' class which can be used as a Grail applet or as a stand-alone application. """ from Tkinter import * from Canvas import Line, Rectangle import random XGRID = 10 YGRID = 10 WIDTH = 6 class Array: def __init__(self, master, data=None): self.master = master self.frame = Frame(self.master) self.frame.pack(fill=X) self.label = Label(self.frame) self.label.pack() self.canvas = Canvas(self.frame) self.canvas.pack() self.report = Label(self.frame) self.report.pack() self.left = Line(self.canvas, 0, 0, 0, 0) self.right = Line(self.canvas, 0, 0, 0, 0) self.pivot = Line(self.canvas, 0, 0, 0, 0) self.items = [] self.size = self.maxvalue = 0 if data: self.setdata(data) def setdata(self, data): olditems = self.items self.items = [] for item in olditems: item.delete() self.size = len(data) self.maxvalue = max(data) self.canvas.config(width=(self.size+1)*XGRID, height=(self.maxvalue+1)*YGRID) for i in range(self.size): self.items.append(ArrayItem(self, i, data[i])) self.reset("Sort demo, size %d" % self.size) speed = "normal" def setspeed(self, speed): self.speed = speed def destroy(self): self.frame.destroy() in_mainloop = 0 stop_mainloop = 0 def cancel(self): self.stop_mainloop = 1 if self.in_mainloop: self.master.quit() def step(self): if self.in_mainloop: self.master.quit() Cancelled = "Array.Cancelled" # Exception def wait(self, msecs): if self.speed == "fastest": msecs = 0 elif self.speed == "fast": msecs = msecs//10 elif self.speed == "single-step": msecs = 1000000000 if not self.stop_mainloop: self.master.update() id = self.master.after(msecs, self.master.quit) self.in_mainloop = 1 self.master.mainloop() self.master.after_cancel(id) self.in_mainloop = 0 if self.stop_mainloop: self.stop_mainloop = 0 self.message("Cancelled") raise Array.Cancelled def getsize(self): return self.size def show_partition(self, first, last): for i in range(self.size): item = self.items[i] if first <= i < last: item.item.config(fill='red') else: item.item.config(fill='orange') self.hide_left_right_pivot() def hide_partition(self): for i in range(self.size): item = self.items[i] item.item.config(fill='red') self.hide_left_right_pivot() def show_left(self, left): if not 0 <= left < self.size: self.hide_left() return x1, y1, x2, y2 = self.items[left].position() ## top, bot = HIRO self.left.coords([(x1-2, 0), (x1-2, 9999)]) self.master.update() def show_right(self, right): if not 0 <= right < self.size: self.hide_right() return x1, y1, x2, y2 = self.items[right].position() self.right.coords(((x2+2, 0), (x2+2, 9999))) self.master.update() def hide_left_right_pivot(self): self.hide_left() self.hide_right() self.hide_pivot() def hide_left(self): self.left.coords(((0, 0), (0, 0))) def hide_right(self): self.right.coords(((0, 0), (0, 0))) def show_pivot(self, pivot): x1, y1, x2, y2 = self.items[pivot].position() self.pivot.coords(((0, y1-2), (9999, y1-2))) def hide_pivot(self): self.pivot.coords(((0, 0), (0, 0))) def swap(self, i, j): if i == j: return self.countswap() item = self.items[i] other = self.items[j] self.items[i], self.items[j] = other, item item.swapwith(other) def compare(self, i, j): self.countcompare() item = self.items[i] other = self.items[j] return item.compareto(other) def reset(self, msg): self.ncompares = 0 self.nswaps = 0 self.message(msg) self.updatereport() self.hide_partition() def message(self, msg): self.label.config(text=msg) def countswap(self): self.nswaps = self.nswaps + 1 self.updatereport() def countcompare(self): self.ncompares = self.ncompares + 1 self.updatereport() def updatereport(self): text = "%d cmps, %d swaps" % (self.ncompares, self.nswaps) self.report.config(text=text) class ArrayItem: def __init__(self, array, index, value): self.array = array self.index = index self.value = value x1, y1, x2, y2 = self.position() self.item = Rectangle(array.canvas, x1, y1, x2, y2, fill='red', outline='black', width=1) self.item.bind('', self.mouse_down) self.item.bind('', self.mouse_move) self.item.bind('', self.mouse_up) def delete(self): item = self.item self.array = None self.item = None item.delete() def mouse_down(self, event): self.lastx = event.x self.lasty = event.y self.origx = event.x self.origy = event.y self.item.tkraise() def mouse_move(self, event): self.item.move(event.x - self.lastx, event.y - self.lasty) self.lastx = event.x self.lasty = event.y def mouse_up(self, event): i = self.nearestindex(event.x) if i >= self.array.getsize(): i = self.array.getsize() - 1 if i < 0: i = 0 other = self.array.items[i] here = self.index self.array.items[here], self.array.items[i] = other, self self.index = i x1, y1, x2, y2 = self.position() self.item.coords(((x1, y1), (x2, y2))) other.setindex(here) def setindex(self, index): nsteps = steps(self.index, index) if not nsteps: return if self.array.speed == "fastest": nsteps = 0 oldpts = self.position() self.index = index newpts = self.position() trajectory = interpolate(oldpts, newpts, nsteps) self.item.tkraise() for pts in trajectory: self.item.coords((pts[:2], pts[2:])) self.array.wait(50) def swapwith(self, other): nsteps = steps(self.index, other.index) if not nsteps: return if self.array.speed == "fastest": nsteps = 0 myoldpts = self.position() otheroldpts = other.position() self.index, other.index = other.index, self.index mynewpts = self.position() othernewpts = other.position() myfill = self.item['fill'] otherfill = other.item['fill'] self.item.config(fill='green') other.item.config(fill='yellow') self.array.master.update() if self.array.speed == "single-step": self.item.coords((mynewpts[:2], mynewpts[2:])) other.item.coords((othernewpts[:2], othernewpts[2:])) self.array.master.update() self.item.config(fill=myfill) other.item.config(fill=otherfill) self.array.wait(0) return mytrajectory = interpolate(myoldpts, mynewpts, nsteps) othertrajectory = interpolate(otheroldpts, othernewpts, nsteps) if self.value > other.value: self.item.tkraise() other.item.tkraise() else: other.item.tkraise() self.item.tkraise() try: for i in range(len(mytrajectory)): mypts = mytrajectory[i] otherpts = othertrajectory[i] self.item.coords((mypts[:2], mypts[2:])) other.item.coords((otherpts[:2], otherpts[2:])) self.array.wait(50) finally: mypts = mytrajectory[-1] otherpts = othertrajectory[-1] self.item.coords((mypts[:2], mypts[2:])) other.item.coords((otherpts[:2], otherpts[2:])) self.item.config(fill=myfill) other.item.config(fill=otherfill) def compareto(self, other): myfill = self.item['fill'] otherfill = other.item['fill'] outcome = cmp(self.value, other.value) if outcome < 0: myflash = 'white' otherflash = 'black' elif outcome > 0: myflash = 'black' otherflash = 'white' else: myflash = otherflash = 'grey' try: self.item.config(fill=myflash) other.item.config(fill=otherflash) self.array.wait(500) finally: self.item.config(fill=myfill) other.item.config(fill=otherfill) return outcome def position(self): x1 = (self.index+1)*XGRID - WIDTH//2 x2 = x1+WIDTH y2 = (self.array.maxvalue+1)*YGRID y1 = y2 - (self.value)*YGRID return x1, y1, x2, y2 def nearestindex(self, x): return int(round(float(x)/XGRID)) - 1 # Subroutines that don't need an object def steps(here, there): nsteps = abs(here - there) if nsteps <= 3: nsteps = nsteps * 3 elif nsteps <= 5: nsteps = nsteps * 2 elif nsteps > 10: nsteps = 10 return nsteps def interpolate(oldpts, newpts, n): if len(oldpts) != len(newpts): raise ValueError, "can't interpolate arrays of different length" pts = [0]*len(oldpts) res = [tuple(oldpts)] for i in range(1, n): for k in range(len(pts)): pts[k] = oldpts[k] + (newpts[k] - oldpts[k])*i//n res.append(tuple(pts)) res.append(tuple(newpts)) return res # Various (un)sorting algorithms def uniform(array): size = array.getsize() array.setdata([(size+1)//2] * size) array.reset("Uniform data, size %d" % size) def distinct(array): size = array.getsize() array.setdata(range(1, size+1)) array.reset("Distinct data, size %d" % size) def randomize(array): array.reset("Randomizing") n = array.getsize() for i in range(n): j = random.randint(0, n-1) array.swap(i, j) array.message("Randomized") def insertionsort(array): size = array.getsize() array.reset("Insertion sort") for i in range(1, size): j = i-1 while j >= 0: if array.compare(j, j+1) <= 0: break array.swap(j, j+1) j = j-1 array.message("Sorted") def selectionsort(array): size = array.getsize() array.reset("Selection sort") try: for i in range(size): array.show_partition(i, size) for j in range(i+1, size): if array.compare(i, j) > 0: array.swap(i, j) array.message("Sorted") finally: array.hide_partition() def bubblesort(array): size = array.getsize() array.reset("Bubble sort") for i in range(size): for j in range(1, size): if array.compare(j-1, j) > 0: array.swap(j-1, j) array.message("Sorted") def quicksort(array): size = array.getsize() array.reset("Quicksort") try: stack = [(0, size)] while stack: first, last = stack[-1] del stack[-1] array.show_partition(first, last) if last-first < 5: array.message("Insertion sort") for i in range(first+1, last): j = i-1 while j >= first: if array.compare(j, j+1) <= 0: break array.swap(j, j+1) j = j-1 continue array.message("Choosing pivot") j, i, k = first, (first+last)//2, last-1 if array.compare(k, i) < 0: array.swap(k, i) if array.compare(k, j) < 0: array.swap(k, j) if array.compare(j, i) < 0: array.swap(j, i) pivot = j array.show_pivot(pivot) array.message("Pivot at left of partition") array.wait(1000) left = first right = last while 1: array.message("Sweep right pointer") right = right-1 array.show_right(right) while right > first and array.compare(right, pivot) >= 0: right = right-1 array.show_right(right) array.message("Sweep left pointer") left = left+1 array.show_left(left) while left < last and array.compare(left, pivot) <= 0: left = left+1 array.show_left(left) if left > right: array.message("End of partition") break array.message("Swap items") array.swap(left, right) array.message("Swap pivot back") array.swap(pivot, right) n1 = right-first n2 = last-left if n1 > 1: stack.append((first, right)) if n2 > 1: stack.append((left, last)) array.message("Sorted") finally: array.hide_partition() def demosort(array): while 1: for alg in [quicksort, insertionsort, selectionsort, bubblesort]: randomize(array) alg(array) # Sort demo class -- usable as a Grail applet class SortDemo: def __init__(self, master, size=15): self.master = master self.size = size self.busy = 0 self.array = Array(self.master) self.botframe = Frame(master) self.botframe.pack(side=BOTTOM) self.botleftframe = Frame(self.botframe) self.botleftframe.pack(side=LEFT, fill=Y) self.botrightframe = Frame(self.botframe) self.botrightframe.pack(side=RIGHT, fill=Y) self.b_qsort = Button(self.botleftframe, text="Quicksort", command=self.c_qsort) self.b_qsort.pack(fill=X) self.b_isort = Button(self.botleftframe, text="Insertion sort", command=self.c_isort) self.b_isort.pack(fill=X) self.b_ssort = Button(self.botleftframe, text="Selection sort", command=self.c_ssort) self.b_ssort.pack(fill=X) self.b_bsort = Button(self.botleftframe, text="Bubble sort", command=self.c_bsort) self.b_bsort.pack(fill=X) # Terrible hack to overcome limitation of OptionMenu... class MyIntVar(IntVar): def __init__(self, master, demo): self.demo = demo IntVar.__init__(self, master) def set(self, value): IntVar.set(self, value) if str(value) != '0': self.demo.resize(value) self.v_size = MyIntVar(self.master, self) self.v_size.set(size) sizes = [1, 2, 3, 4] + range(5, 55, 5) if self.size not in sizes: sizes.append(self.size) sizes.sort() self.m_size = apply(OptionMenu, (self.botleftframe, self.v_size) + tuple(sizes)) self.m_size.pack(fill=X) self.v_speed = StringVar(self.master) self.v_speed.set("normal") self.m_speed = OptionMenu(self.botleftframe, self.v_speed, "single-step", "normal", "fast", "fastest") self.m_speed.pack(fill=X) self.b_step = Button(self.botleftframe, text="Step", command=self.c_step) self.b_step.pack(fill=X) self.b_randomize = Button(self.botrightframe, text="Randomize", command=self.c_randomize) self.b_randomize.pack(fill=X) self.b_uniform = Button(self.botrightframe, text="Uniform", command=self.c_uniform) self.b_uniform.pack(fill=X) self.b_distinct = Button(self.botrightframe, text="Distinct", command=self.c_distinct) self.b_distinct.pack(fill=X) self.b_demo = Button(self.botrightframe, text="Demo", command=self.c_demo) self.b_demo.pack(fill=X) self.b_cancel = Button(self.botrightframe, text="Cancel", command=self.c_cancel) self.b_cancel.pack(fill=X) self.b_cancel.config(state=DISABLED) self.b_quit = Button(self.botrightframe, text="Quit", command=self.c_quit) self.b_quit.pack(fill=X) def resize(self, newsize): if self.busy: self.master.bell() return self.size = newsize self.array.setdata(range(1, self.size+1)) def c_qsort(self): self.run(quicksort) def c_isort(self): self.run(insertionsort) def c_ssort(self): self.run(selectionsort) def c_bsort(self): self.run(bubblesort) def c_demo(self): self.run(demosort) def c_randomize(self): self.run(randomize) def c_uniform(self): self.run(uniform) def c_distinct(self): self.run(distinct) def run(self, func): if self.busy: self.master.bell() return self.busy = 1 self.array.setspeed(self.v_speed.get()) self.b_cancel.config(state=NORMAL) try: func(self.array) except Array.Cancelled: pass self.b_cancel.config(state=DISABLED) self.busy = 0 def c_cancel(self): if not self.busy: self.master.bell() return self.array.cancel() def c_step(self): if not self.busy: self.master.bell() return self.v_speed.set("single-step") self.array.setspeed("single-step") self.array.step() def c_quit(self): if self.busy: self.array.cancel() self.master.after_idle(self.master.quit) # Main program -- for stand-alone operation outside Grail def main(): root = Tk() demo = SortDemo(root) root.protocol('WM_DELETE_WINDOW', demo.c_quit) root.mainloop() if __name__ == '__main__': main() PK!hguido/imagedraw.pycnu[ ^c@s9dZddlTddlZdZdZedS(sDraw on top of an imagei(t*NcCstjd}t}td|}|j|j}}t|d|d|}|jdddtd||j |j dt |j dS( Nitfiletwidththeightitanchortimages ( tsystargvtTkt PhotoImageRRtCanvast create_imagetNWtpacktbindtblobtmainloop(tfilenametroottimgtwthtcanv((s4/usr/lib64/python2.7/Demo/tkinter/guido/imagedraw.pytmains   c CsX|j|j}}|j}d}|j||||||||dddddS(Nitfilltredtoutlinet(txtytwidgett create_oval(teventRRRtr((s4/usr/lib64/python2.7/Demo/tkinter/guido/imagedraw.pyRs (t__doc__tTkinterRRR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/imagedraw.pyts    PK!Xj|0J|J| guido/ss1.pyonu[ ^c@sdZddlZddlZddlZddlZddlZddlmZdddf\ZZ Z dZ dZ d Z ie e6e e 6e e 6Zid e6d e 6d e 6Zied 6e d 6e d 6Zid e6d e 6de 6ZdZdfdYZdfdYZdfdYZdefdYZdefdYZdefdYZdZdZdZdZddlZd fd!YZd"Z d#Z!e"d$kre!ndS(%sSS1 -- a spreadsheet.iN(texpattLEFTtCENTERtRIGHTcCs |j|S(N(tljust(txtn((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR scCs |j|S(N(tcenter(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCs |j|S(N(trjust(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRstleftRtrighttwtecCs4d}x'|D]}|dk r ||7}q q W|S(Ni(tNone(tseqttotalR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytsums   tSheetcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZRS(cCsOi|_tj|_|jjd}|j|_|j|_t|_dS(Nt__main__(tcellstrexectRExect add_modulet cellvaluetcelltmulticellvalueR(tselftm((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt__init__"s    cCs9|j||}t|dr1|j|jS|SdS(Ntrecalc(tgetcellthasattrRR(RRtyR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR*scCs||kr||}}n||kr8||}}ng}xRt||dD]=}x4t||dD]}|j|j||qlWqRW|S(Ni(trangetappendR(Rtx1ty1tx2ty2RR R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR1s  !cCs|jj||fS(N(Rtget(RRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR<scCs||j||fR!t colnum2nameRR;tlentstrRt iteritemsRRRRAt isinstanceRR't align2action(RR<R=twidththeighttcolwidthtfullRttextt alignmentR Rtseptline((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytdisplaysP &!&!"  ! '  cCsdg}xn|jjD]]\\}}}t|drI|j}ndtj|}|jd|||fqW|jddj|S(Ns txmls%ss% %s ss (RRIRRUtcgitescapeR"tjoin(RtoutRR Rtcellxml((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRUs "  cCs\|j}t|d}|j||rN|jd rN|jdn|jdS(NR s (RUtopentwritetendswithtclose(RtfilenameRPtf((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytsaves   cCs0t|d}t|j||jdS(Ntr(R[t SheetParsert parsefileR^(RR_R`((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytloads(t__name__t __module__RRRRR(R*R-R0R1R+R6R7R8R9R:R>R?RRTRURaRe(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR s,                  2 RccBseZdZdZdZdZdZdZdZeZ dZ dZ d Z d Z d Zd Zd ZdZRS(cCs ||_dS(N(tsheet(RRh((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsAtj}|j|_|j|_|j|_|j|dS(N( Rt ParserCreatet startelementtStartElementHandlert endelementtEndElementHandlertdatatCharacterDataHandlert ParseFile(RR`tparser((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRds     cCsct|d|d}|rVx*|jD]\}}t|||%s(RsttypeRyRft align2xmlRQR(RRw((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRUXs  cCs8d|jkodknr*d|jS|jSdS(Niis %sIiI(Ryt _xml_long(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt_xml_int_s cCs d|jS(Ns%s(Ry(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRescCsdt|jS(Ns%s(treprRy(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt _xml_floathscCsdt|jS(Ns%s(RRy(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt _xml_complexks( RfRgRRRRARURRRR(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyREs      RcBs2eZdedZdZdZdZRS(s%scCs||_||_||_dS(N(RPRRQ(RRPRRQ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRps  cCs|jS(N(RP(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRwscCs|j|jfS(N(RPRQ(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRAzscCs-d}|t|j|jtj|jfS(Ns9%s(RRQRRVRWRP(Rts((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRU}s  (RfRgRRRRARU(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRns  RcBsDeZdedZdZdZdZdZdZRS(s%scCs;||_t|j|_||_||_|jdS(N(tformulat translatet translatedRRQR?(RRRRQ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs    cCs d|_dS(N(R Ry(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR?scCs|jdkry4|jddt|j|jd|_Wqtjd}t|drw|j |_qt ||_qXn|jS(Ns from __future__ import division s__value__ = eval(%s)t __value__iRf( RyR tr_execRRtr_evalR.texc_infoRRfRH(RRtexc((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs:y|j|j}Wnt|j}nX||jfS(N(RRyRHRQ(RRP((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRAs cCsdt|j|j|jfS(Ns,%s(RRQRR(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRUs cCsg}xtjd|jD]}tjd|} | dk r| j\} } t| } t| } || ko|knr|| ko|knrt| || |}qn|j |qWt dj ||j |j S(Ns(\w+)s^([A-Z]+)([1-9][0-9]*)$RB(tretsplitRtmatchR tgroupst colname2numR}tcellnameR"RRXRRQ(RR#R$R%R&R3R4RYtpartRtsxtsyRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR2s   8( RfRgRRR?RRARUR2(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs     c Csg}xtjd|D]}tjd|}|dkrM|j|q|j\}}}}t|}|dkrd||f}n"t|}d||||f}|j|qWdj|S(sTranslate a formula containing fancy cell names to valid Python code. Examples: B4 -> cell(2, 4) B4:Z100 -> cells(2, 4, 26, 100) s(\w+(?::\w+)?)s2^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$s cell(%s, %s)scells(%s, %s, %s, %s)RBN(RRRR R"RRRX( RRYRRR#R$R%R&R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs    cCst|t|S(sETranslate a cell coordinate to a fancy cell name (e.g. (1, 1)->'A1').(RFRH(RR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsI|j}d}x0|D](}|dt|tdd}qW|S(sCTranslate a column name to number (e.g. 'A'->1, 'Z'->26, 'AA'->27).iitAi(tuppertord(RRtc((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs   &cCsJd}x=|rEt|dd\}}t|td|}q W|S(s6Translate a column number to name (e.g. 1->'A', etc.).RBiiR(tdivmodtchrR(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRFs  tSheetGUIcBseZdZddddZdZdZdZdZd Zd Z d Z d Z d Z dZ dZeZdZdZdZdZdZdZdZdZdZdZdZdZRS(s7Beginnings of a GUI for a spreadsheet. TO DO: - clear multiple cells - Insert, clear, remove rows or columns - Show new contents while typing - Scroll bars - Grow grid when window is grown - Proper menus - Undo, redo - Cut, copy and paste - Formatting and alignment s sheet1.xmli icCs*||_t|_tjj|r:|jj|n|jj\}}t||}t||}t j |_ |j j d|jt j |j dddd|_ t j|j |_t j|j ddd |j|_t j|j |_|jjd d d d dd|j jd d|jjd d|jjd dd d dd|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|j||d|_d|_ |j!d d |j"dS(slConstructor. Load the sheet from the filename argument. Set up the Tk widget tree. sSpreadsheet: %sRPtA1tfontt helveticaitboldtSavetcommandtsidetbottomtexpanditfilltbothR R Rssss ssN(RiR(#R_RRhtostpathtisfileReR>R;tTktroottwm_titletLabeltbeacontEntrytentrytButtonRat savebuttontFrametcellgridtpacktbindt return_eventtshift_return_eventt tab_eventtshift_tab_eventt delete_eventt escape_eventtmakegridR t currentxytcornerxyt setcurrenttsync(RR_trowstcolumnsR<R=((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs<     cCsr|j|jkr>|jdk r>|jj|j|jn|jj|j|j|jjdddS(Nitendtbreak( RRR RhR-R*RRtdelete(Rtevent((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR's ! cCs#|j\}}|j||dS(N(Rt load_entry(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR0scCs|jj||}|dkr*d}n1t|trId|j}n|j\}}|jjdd|jj d||jj dddS(NRBt=iR( RhRR RJRRRARRtinserttselection_range(RRR RRPRQ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR4s  c Cs||_||_i|_tj|jdd}|jdddddd|jd|jxt d |d D]}|jj |d d tj|jd t |dd}|jd|dddd ||j|df<||_ d|_ |jd|j|jd|j|jd|j|jd|jqvWxt d |d D]}tj|jd t|dd}|jddd|dd ||jd|fitminsizei@RPtWEs sstsunkentbgtwhitetfgtblackN(RRt gridcellsRRRtgrid_configureRt selectallR!tgrid_columnconfigureRFt _SheetGUI__xt _SheetGUI__yt selectcolumnt extendcolumnRHt selectrowt extendrowtpresstmotiontrelease(RRRRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR@sN   $  $    cCs*|jdd|jtjtjdS(Ni(Rt setcornerR.R/(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRrscCs<|j|\}}|j|d|j|tjdS(Ni(twhichxyRRR.R/(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRvscCsR|j|\}}|dkrN|j|jdd|j|tjndS(Nii(RRRRR.R/(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR{s cCs<|j|\}}|jd||jtj|dS(Ni(RRRR.R/(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsR|j|\}}|dkrN|jd|jd|jtj|ndS(Nii(RRRRR.R/(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCsD|j|\}}|dkr@|dkr@|j||ndS(Ni(RR(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsD|j|\}}|dkr@|dkr@|j||ndS(Ni(RR(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsh|jj|j|j}|dk rdt|tjrdy|j|j fSWqdt k r`qdXndS(Ni(ii( Rtwinfo_containingtx_rootty_rootR RJRRRRtAttributeError(RRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs|jj|jdS(N(RhRaR_(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRascCs|jdk r|jn|jt|||jd<|j|||jj||f|_d|_ |j j |j}|dk rd|ds@         Y )6   C  PK!&Yguido/listtree.pycnu[ ^c@sWddlZddlZddlTdZdZdZedkrSendS(iN(t*cCs?t|dd}|jdddtt||dd|S(Ntnametlisttexpanditfillt.i(tListboxtpacktBOTHt listnodes(tmastertappR((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pytlisttreescCs|j|dd|}|jtd||f|jj|j|dd|}x%|D]}t||||dq]WdS(Ntwinfotclasss%s (%s)tchildreni(tsendtinserttENDttkt splitlistR (RR twidgettleveltklassRtc((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pyR s   cCstjds-tjjdtjdntjd}t}|jddt|dd}|jdddt t ||}|j dS(NisUsage: listtree appname iRtfRR( tsystargvtstderrtwritetexittTktminsizetFrameRRR tmainloop(R RRR((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pytmains   t__main__(RtstringtTkinterR R R#t__name__(((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pyts     PK!KѴQQguido/solitaire.pycnu[ Afc@sCdZddlZddlZddlTddlmZmZmZmZdefdYZdZ dZ d Z e d e Z e d e Z d Zd ZdZdZdZdZdZdZiZxeefD]Zeees s sN( R&R'tgametcardsRRR(R t clickhandlertdoubleclickhandlert motionhandlertreleasehandlert makebottom(RR&R'R>((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR2s    cCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDscCsd|jj|j|jfS(s+Return a string for debug print statements.s %s(%d, %d)(t __class__R R&R'(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR3scCs>|jj||j|j||jj|jdS(N(R?tappendR9tpositionR(R-(Rtcard((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytadd%s  cCs'|jj||jj|jdS(N(R?tremoveR(tdtag(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytdelete+scCs!|jr|jdjndS(Ni(R?R:(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshowtop/s cCs+|js dS|jd}|j||S(Ni(R?RRL(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytdeal3s    cCs|j|j|jdS(N(R5R&R'(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRG<scCs|jdS(N(RM(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytuserclickhandler?scCs|jdS(N(RO(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytuserdoubleclickhandlerBscCs"x|D]}|j|qWdS(N(RG(RR?RH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytusermovehandlerEs cCs%|j|j|j|dS(N(t finishmovingROt startmoving(Rtevent((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR@Ks  cCs|j|dS(N(t keepmoving(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRBPscCs|j||jdS(N(RURR(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRCSs cCs%|j|j|j|dS(N(RRRPRS(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRAWs  cCsd|_|jjjd}xDtt|jD])}|j|}|jj |kr4Pq4q4WdS|j srdS|j||_|j |_ |j |_x|jD]}|jqWdS(Ntcurrent(RtmovingR>RtgettagstrangetlenR?R(ttagR%R&tlastxR'tlastyR9(RRTttagstiRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRS`s     cCs||js dS|j|j}|j|j}|j|_|j|_|sQ|rxx$|jD]}|j||q[WndS(N(RWR&R\R'R]R4(RRTR7R8RH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRUqs    cCs,|j}d|_|r(|j|ndS(N(RWRRQ(RR?((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRR|s  N(R R R<RR2RDR3RIRLRMRNRGRORPRQR@RBRCRARWRSRURR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR=s(-                tDeckcBs2eZdZdZdZdZdZRS(s7The deck is a stack with support for shuffling. New methods: fill() -- create the playing cards shuffle() -- shuffle the playing cards A single click moves the top card to the game's open deck and moves it face up; if we're out of cards, it moves the open deck back to the deck. c CsRt|jj|j|j|jt|jtdddt}|jj |dS(NRRR( RR>RR&R'R*R.t BACKGROUNDR(R-(Rtbottom((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDs   cCsEx>tD]6}x-tD]%}|jt|||jjqWqWdS(N(tALLSUITSt ALLVALUESRIRR>R(RR!R"((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRs  cCsMt|j}g}x(t|D]}|j|j|q"W||_dS(N(RZR?trandpermRF(RtntnewcardsR_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshuffles cCsv|jj}|j}|sUxQ|j}|s7Pn|j||jq!Wn|jjj||jdS(N(R>topendeckRNRIR;R:(RRiRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyROs    (R R R<RDRRhRO(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR`s     cCsLt|}g}x3|rGtj|}|j||j|qW|S(s4Function returning a random permutation of range(n).(RYtrandomtchoiceRFRJ(RftrR&R_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRes   t OpenStackcBs#eZdZdZdZRS(cCsdS(Ni((RR?((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyt acceptablescCs|d}|jj|}| s?||ks?|j| rRtj||n8x(|D] }|j||j|qYW|jjdS(Ni(R>t closeststackRnR=RQRLRItwincheck(RR?RHtstack((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRQs #  cCs|js dS|jd}|js1|jdSxQ|jjD]C}|j|gr>|j||j||jjPq>q>WdS(Ni( R?R%ROR>tsuitsRnRLRIRp(RRHts((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRPs       (R R RnRQRP(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRms  t SuitStackcBs,eZdZdZdZdZRS(c CsBt|jj|j|j|jt|jtdddd}dS(NRRRR(RR>RR&R'R*R.(RRb((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDs  cCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyROscCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRPscCsit|dkrdS|d}|js6|jtkS|jd}|j|jkoh|j|jdkS(Niii(RZR?R"tACER!(RR?RHttopcard((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRns    (R R RDRORPRn(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRts   tRowStackcBseZdZdZRS(cCs`|d}|js |jtkS|jd}|js:dS|j|jko_|j|jdkS(Niii(R?R"tKINGR%R$(RR?RHRv((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRns     cCsh|j}xE|jD]:}||kr)Pn|jrC|dt}q|t}qW|j|j|dS(Ni(R'R?R%R0tOFFSETR5R&(RRHR'tc((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRGs   (R R RnRG(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRws t SolitairecBsGeZdZdZdZdZdZdZdZRS(c Cs||_t|jdtdddttddtdt|_|jjdt d t t |jd d dddtd d d|j |_ t|jtdtdd|j dtt}t}t||||_|t}t||||_|t}g|_x:ttD],}|t}|jjt|||qWt}|t}g|_x:ttD],}|jjt||||t}qoW|jg|j|j|_|jj|j dS(Nt backgroundthighlightthicknessitwidththeightiiRtexpandRtDealtactivebackgroundtgreenR twindowR(tmastertCanvasRatNROWStXSPACINGtYSPACINGR0RtpacktBOTHtTRUEtButtonRNt dealbuttonRtSWR`tdeckRmRiRrRYtNSUITSRFRttrowsRwt openstacksR(RRR&R'R_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR2sD            cCsEx*|jD]}t|jtkr dSq W|j|jdS(N(RrRZR?tNVALUEStwinRN(RRs((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRp=s  cCsgg}x|jD]}||j}qWx9|rbtj|}|j||j||jq*WdS(sStupid animation when you win.N(RR?RjRkRJtanimatedmovetoR(RR?RsRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDs  cCsgx`tdddD]L}|j|j||j|j|}}|j|||jjqWdS(Ni ii(RYR&R'R4Rtupdate_idletasks(RRHtdestR_R7R8((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRNs)cCsed}d}xR|jD]G}|j|jd|j|jd}||kr|}|}qqW|S(Niɚ;i(RRR&R'(RRHtclosesttcdistRqtdist((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRoTs&  cCs|j|jjxHttD]:}x1|j|D]"}|jj}|j|q8Wq$Wx|jD]}|jqlWdS(N( tresetRRhRYRRRNRIRM(RR_RlRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRN`s  cCsOxH|jD]=}x4|j}|s)Pn|jj||jqWq WdS(N(RRNRRIR;(RRqRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRjs ( R R R2RpRRRoRNR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR{ s .   cCs6t}t|}|jd|j|jdS(NtWM_DELETE_WINDOW(tTkR{tprotocoltquittmainloop(trootR>((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytmainvs  t__main__((((1R<tmathRjtTkinterRRRRRR*R.R0RRRyRatHEARTStDIAMONDStCLUBStSPADEStREDtBLACKR#RstkeysRcRZRRutJACKtQUEENRxRYRdRtmaptstrR)RRR=R`ReRmRtRwR{RR (((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytsX   "     /f1 i  PK!sl~~ guido/ss1.pycnu[ ^c@sdZddlZddlZddlZddlZddlZddlmZdddf\ZZ Z dZ dZ d Z ie e6e e 6e e 6Zid e6d e 6d e 6Zied 6e d 6e d 6Zid e6d e 6de 6ZdZdfdYZdfdYZdfdYZdefdYZdefdYZdefdYZdZdZdZdZddlZd fd!YZd"Z d#Z!e"d$kre!ndS(%sSS1 -- a spreadsheet.iN(texpattLEFTtCENTERtRIGHTcCs |j|S(N(tljust(txtn((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR scCs |j|S(N(tcenter(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCs |j|S(N(trjust(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRstleftRtrighttwtecCs4d}x'|D]}|dk r ||7}q q W|S(Ni(tNone(tseqttotalR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytsums   tSheetcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZRS(cCsOi|_tj|_|jjd}|j|_|j|_t|_dS(Nt__main__(tcellstrexectRExect add_modulet cellvaluetcelltmulticellvalueR(tselftm((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt__init__"s    cCs9|j||}t|dr1|j|jS|SdS(Ntrecalc(tgetcellthasattrRR(RRtyR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR*scCs||kr||}}n||kr8||}}ng}xRt||dD]=}x4t||dD]}|j|j||qlWqRW|S(Ni(trangetappendR(Rtx1ty1tx2ty2RR R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR1s  !cCs|jj||fS(N(Rtget(RRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR<scCsJ|dkr|dkstt|ts3t||j||ftlentstrRt iteritemsRRRRDR)R(RRR't align2action(RR?R@twidththeighttcolwidthtfullRttextt alignmentR Rtseptline((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytdisplaysR &!&!"  ! '  cCsdg}xn|jjD]]\\}}}t|drI|j}ndtj|}|jd|||fqW|jddj|S(Ns txmls%ss% %s ss (RRLRRWtcgitescapeR"tjoin(RtoutRR Rtcellxml((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRWs "  cCs\|j}t|d}|j||rN|jd rN|jdn|jdS(NR s (RWtopentwritetendswithtclose(RtfilenameRRtf((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytsaves   cCs0t|d}t|j||jdS(Ntr(R]t SheetParsert parsefileR`(RRaRb((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pytloads(t__name__t __module__RRRRR+R-R0R3R4R.R9R:R;R<R=RARBRRVRWRcRg(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR s,                  2 RecBseZdZdZdZdZdZdZdZeZ dZ dZ d Z d Z d Zd Zd ZdZRS(cCs ||_dS(N(tsheet(RRj((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsAtj}|j|_|j|_|j|_|j|dS(N( Rt ParserCreatet startelementtStartElementHandlert endelementtEndElementHandlertdatatCharacterDataHandlert ParseFile(RRbtparser((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRfs     cCsct|d|d}|rVx*|jD]\}}t|||%s(RuttypeR{Rht align2xmlRSR(RRy((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRWXs  cCs8d|jkodknr*d|jS|jSdS(Niis %sIiI(R{t _xml_long(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt_xml_int_s cCs d|jS(Ns%s(R{(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRescCsdt|jS(Ns%s(treprR{(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt _xml_floathscCsdt|jS(Ns%s(RR{(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt _xml_complexks( RhRiRRRRDRWRRRR(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyREs      RcBs2eZdedZdZdZdZRS(s%scCsUt|ttfst|tttfks6t||_||_||_ dS(N( R)RKtunicodeR(RRRRRRRS(RRRRRS((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRps   cCs|jS(N(RR(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRwscCs|j|jfS(N(RRRS(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRDzscCs-d}|t|j|jtj|jfS(Ns9%s(RRSRRXRYRR(Rts((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRW}s  (RhRiRRRRDRW(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRns  RcBsDeZdedZdZdZdZdZdZRS(s%scCsV|tttfkst||_t|j|_||_||_|j dS(N( RRRR(tformulat translatet translatedRRSRB(RRRRS((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs    cCs d|_dS(N(R R{(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRBscCs|jdkry4|jddt|j|jd|_Wqtjd}t|drw|j |_qt ||_qXn|jS(Ns from __future__ import division s__value__ = eval(%s)t __value__iRh( R{R tr_execRRtr_evalR1texc_infoRRhRK(RRtexc((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs:y|j|j}Wnt|j}nX||jfS(N(RR{RKRS(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRDs cCsdt|j|j|jfS(Ns,%s(RRSRR(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRWs cCsg}xtjd|jD]}tjd|} | dk r| j\} } t| } t| } || ko|knr|| ko|knrt| || |}qn|j |qWt dj ||j |j S(Ns(\w+)s^([A-Z]+)([1-9][0-9]*)$RE(tretsplitRtmatchR tgroupst colname2numRtcellnameR"RRZRRS(RR#R$R%R&R6R7R[tpartRtsxtsyRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR5s   8( RhRiRRRBRRDRWR5(((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs     c Csg}xtjd|D]}tjd|}|dkrM|j|q|j\}}}}t|}|dkrd||f}n"t|}d||||f}|j|qWdj|S(sTranslate a formula containing fancy cell names to valid Python code. Examples: B4 -> cell(2, 4) B4:Z100 -> cells(2, 4, 26, 100) s(\w+(?::\w+)?)s2^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$s cell(%s, %s)scells(%s, %s, %s, %s)REN(RRRR R"RRRZ( RR[RRR#R$R%R&R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs    cCs&|dkstt|t|S(sETranslate a cell coordinate to a fancy cell name (e.g. (1, 1)->'A1').i(R(RIRK(RR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsk|j}d}xR|D]J}d|ko6dknsAt|dt|tdd}qW|S(sCTranslate a column name to number (e.g. 'A'->1, 'Z'->26, 'AA'->27).itAtZii(tupperR(tord(RRtc((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs   "&cCs\|dkstd}x=|rWt|dd\}}t|td|}qW|S(s6Translate a column number to name (e.g. 1->'A', etc.).iREiiR(R(tdivmodtchrR(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRIs  tSheetGUIcBseZdZddddZdZdZdZdZd Zd Z d Z d Z d Z dZ dZeZdZdZdZdZdZdZdZdZdZdZdZdZRS(s7Beginnings of a GUI for a spreadsheet. TO DO: - clear multiple cells - Insert, clear, remove rows or columns - Show new contents while typing - Scroll bars - Grow grid when window is grown - Proper menus - Undo, redo - Cut, copy and paste - Formatting and alignment s sheet1.xmli icCs*||_t|_tjj|r:|jj|n|jj\}}t||}t||}t j |_ |j j d|jt j |j dddd|_ t j|j |_t j|j ddd |j|_t j|j |_|jjd d d d dd|j jd d|jjd d|jjd dd d dd|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|j||d|_d|_ |j!d d |j"dS(slConstructor. Load the sheet from the filename argument. Set up the Tk widget tree. sSpreadsheet: %sRRtA1tfontt helveticaitboldtSavetcommandtsidetbottomtexpanditfilltbothR R Rssss ssN(RiR(#RaRRjtostpathtisfileRgRAR>tTktroottwm_titletLabeltbeacontEntrytentrytButtonRct savebuttontFrametcellgridtpacktbindt return_eventtshift_return_eventt tab_eventtshift_tab_eventt delete_eventt escape_eventtmakegridR t currentxytcornerxyt setcurrenttsync(RRatrowstcolumnsR?R@((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs<     cCsr|j|jkr>|jdk r>|jj|j|jn|jj|j|j|jjdddS(Nitendtbreak( RRR RjR0R-RRtdelete(Rtevent((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR's ! cCs#|j\}}|j||dS(N(Rt load_entry(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR0scCs|jj||}|dkr*d}n1t|trId|j}n|j\}}|jjdd|jj d||jj dddS(NREt=iR( RjRR R)RRRDRRtinserttselection_range(RRR RRRRS((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR4s  c Cs||_||_i|_tj|jdd}|jdddddd|jd|jxt d |d D]}|jj |d d tj|jd t |dd}|jd|dddd ||j|df<||_ d|_ |jd|j|jd|j|jd|j|jd|jqvWxt d |d D]}tj|jd t|dd}|jddd|dd ||jd|fitminsizei@RRtWEs sstsunkentbgtwhitetfgtblackN(RRt gridcellsRRRtgrid_configureRt selectallR!tgrid_columnconfigureRIt _SheetGUI__xt _SheetGUI__yt selectcolumnt extendcolumnRKt selectrowt extendrowtpresstmotiontrelease(RRRRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR@sN   $  $    cCs*|jdd|jtjtjdS(Ni(Rt setcornerR1R2(RR((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRrscCs<|j|\}}|j|d|j|tjdS(Ni(twhichxyRRR1R2(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRvscCsR|j|\}}|dkrN|j|jdd|j|tjndS(Nii(RRRRR1R2(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR{s cCs<|j|\}}|jd||jtj|dS(Ni(RRRR1R2(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsR|j|\}}|dkrN|jd|jd|jtj|ndS(Nii(RRRRR1R2(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCsD|j|\}}|dkr@|dkr@|j||ndS(Ni(RR(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsD|j|\}}|dkr@|dkr@|j||ndS(Ni(RR(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRscCsh|jj|j|j}|dk rdt|tjrdy|j|j fSWqdt k r`qdXndS(Ni(ii( Rtwinfo_containingtx_rootty_rootR R)RRRRtAttributeError(RRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs|jj|jdS(N(RjRcRa(R((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRcscCs|jdk r|jn|jt|||jd<|j|||jj||f|_d|_ |j j |j}|dk rd|d(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs1|j|j\}}|j|d|dS(sCallback for the Tab key.iR(RRR(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs:|j|j\}}|jtd|d|dS(s-Callback for the Tab key with Shift modifier.iR(RRRR>(RRRR ((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs cCs|j\}}|jj}d}|jdrFt|d}nGxDtttt fD]0}y||}Wn qYqYXt |}PqYW|dkr|rt |}n|dkr|j j ||n|j j||||jdS(s+Set the current cell from the entry widget.RiN(RRR'R t startswithRRRRRRRRjR-R+R(RRR RRRtclsR{((s./usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRs$  cCs|jjx|jjD]\\}}}|dks|dkrMqn|jj||}|dkr{d|ds@         Y )6   C  PK!m.,, guido/kill.pynuȯ#! /usr/bin/python2.7 # Tkinter interface to Linux `kill' command. from Tkinter import * from string import splitfields from string import split import commands import os class BarButton(Menubutton): def __init__(self, master=None, **cnf): apply(Menubutton.__init__, (self, master), cnf) self.pack(side=LEFT) self.menu = Menu(self, name='menu') self['menu'] = self.menu class Kill(Frame): # List of (name, option, pid_column) format_list = [('Default', '', 0), ('Long', '-l', 2), ('User', '-u', 1), ('Jobs', '-j', 1), ('Signal', '-s', 1), ('Memory', '-m', 0), ('VM', '-v', 0), ('Hex', '-X', 0)] def kill(self, selected): c = self.format_list[self.format.get()][2] pid = split(selected)[c] os.system('kill -9 ' + pid) self.do_update() def do_update(self): name, option, column = self.format_list[self.format.get()] s = commands.getoutput('ps -w ' + option) list = splitfields(s, '\n') self.header.set(list[0]) del list[0] y = self.frame.vscroll.get()[0] self.frame.list.delete(0, AtEnd()) for line in list: self.frame.list.insert(0, line) self.frame.list.yview(int(y)) def do_motion(self, e): e.widget.select_clear(0, END) e.widget.select_set(e.widget.nearest(e.y)) def do_leave(self, e): e.widget.select_clear(0, END) def do_1(self, e): self.kill(e.widget.get(e.widget.nearest(e.y))) def __init__(self, master=None, **cnf): Frame.__init__(self, master, cnf) self.pack(expand=1, fill=BOTH) self.bar = Frame(self, name='bar', relief=RAISED, borderwidth=2) self.bar.pack(fill=X) self.bar.file = BarButton(self.bar, text='File') self.bar.file.menu.add_command( label='Quit', command=self.quit) self.bar.view = BarButton(self.bar, text='View') self.format = IntVar(self) self.format.set(2) for num in range(len(self.format_list)): self.bar.view.menu.add_radiobutton( label=self.format_list[num][0], command=self.do_update, variable=self.format, value=num) #self.bar.view.menu.add_separator() #XXX ... self.bar.tk_menuBar(self.bar.file, self.bar.view) self.frame = Frame(self, relief=RAISED, borderwidth=2) self.frame.pack(expand=1, fill=BOTH) self.header = StringVar(self) self.frame.label = Label(self.frame, relief=FLAT, anchor=NW, borderwidth=0, textvariable=self.header) self.frame.label.pack(fill=X) self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL) self.frame.list = Listbox(self.frame, relief=SUNKEN, selectbackground='#eed5b7', selectborderwidth=0, yscroll=self.frame.vscroll.set) self.frame.vscroll['command'] = self.frame.list.yview self.frame.vscroll.pack(side=RIGHT, fill=Y) self.frame.list.pack(expand=1, fill=BOTH) self.update = Button(self, text="Update", command=self.do_update) self.update.pack(expand=1, fill=X) self.frame.list.bind('', self.do_motion) self.frame.list.bind('', self.do_leave) self.frame.list.bind('<1>', self.do_1) self.do_update() if __name__ == '__main__': kill = Kill(None, borderwidth=5) kill.winfo_toplevel().title('Tkinter Process Killer') kill.winfo_toplevel().minsize(1, 1) kill.mainloop() PK!+$RRguido/optionmenu.pyonu[ ^c@sddlTeZeZejdeeedddZejd Z eZ e je d e eee fe e Z e jejd S( i(t*tOnetTwotThreetAahtBeetCeetDeetEffiN(RRRRR(tTkintertTktroott StringVartvar1tsett OptionMenutmenu1tpacktCHOICEStvar2tapplyttupletmenu2tmainloop(((s5/usr/lib64/python2.7/Demo/tkinter/guido/optionmenu.pyts       PK!X##guido/tkman.pycnu[ Afc@sddlZddlZddlZddlZddlTddlmZddgZddgZdZx/eD]'Z ej j e roe Z d ZqoqoWdZ x/eD]'Z ej j e re Zd Z qqWe se r\ejjd esd ejdZejjd ene sLd ejdZejjd enejd n[[ dZdddYZdZedS(iN(t*(tManPages/depot/sundry/man/manns/usr/local/man/manns/depot/sundry/man/man3s/usr/local/man/man3iis sgFailed to find mann directory. Please add the correct entry to the MANNDIRLIST at the top of %s script.s%s sgFailed to find man3 directory. Please add the correct entry to the MAN3DIRLIST at the top of %s script.cCsktj|}g}xE|D]=}|dd!dkr|ddkr|j|d qqW|j|S(Niit.t ln123456789(tostlistdirtappendtsort(tmandirtfilestnamestfile((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt listmanpages0s # t SelectionBoxcBseZddZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZRS(cCsg|_t|dd|_|jjdddt|jj|_t|jdd|_|jjdddtt|jdd|_|jjd tdddtt|jdd |_ |j jd t dddtt ||_ t |j dd d d dtdd|_|jjd tt|jdd|_|jjdddtd|j d|j|jjdddtd|j d|j|j|jds s(6tchoicestFrameRtpacktBOTHtmasterRRtLEFTRtRIGHTt StringVart chaptervart MenubuttontRAISEDRtTOPtMenuRtadd_radiobuttontMAN3DIRt newchaptertMANNDIRtListboxtSUNKENR!tButtontentry_cbR$tEntryR%tXR&tNONEt search_cbR't BooleanVartcasevart CheckbuttontFLATR(R)tLabelR*tBOTTOMRRtbindt listbox_cbt entry_tabt search_tabttext_tabt focus_settset(tselfR2((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt__init__;s                    cCs/|jj}g|_|jt|dS(N(R6tgetR.taddlistR (RTR((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyR=s cCs=||jkr/|jj||jjn|jdS(N(R.RRtupdate(RTtchoice((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt addchoicescCs1||jt|j)|jj|jdS(N(R.tlenRRX(RTtlist((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRWs cGs|jdS(N(RX(RTte((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRBscCsQ|jj}|rMt|dkrM|jj|d}|j|ndS(Nii(R!t curselectionR[RVt show_page(RTR]t selectionR((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRNscGs|j|jjdS(N(t search_stringR)RV(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRFscCs|jjdS(N(R)RR(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyROscCs|jjdS(N(R%RR(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRPscCs|jjdS(N(R%RR(RTR]((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRQscCs|jj}t|t|d|j}|sF|jjn|jjdt d}x9|D]1}||krd}n|jj t |qiW|r|S|jj }|dkr|jjdSdS(NcSs|| |kS(N((Rtkeytn((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyttii( R%RVtfilterR[R.RtbellR!tdeletetAtEndtinserttsize(RTRbtokt exactmatchtitemRc((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyt updatelists     cCsF|j}|rB|j||jjdt|jndS(Ni(RoR_R%RhRi(RTR((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRXs   cCs]d|jj|f}tjd|d}|jj||jd<|jj|dS(Ns%s/%s.?snroff -man %s | ul -itrR(R6RVRtpopenRtkillR*t parsefile(RTRR tfp((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyR_s   cCs`|s|jjdGHdS|jjs7tj}nd}y.|r[tj||}ntj|}Wn-tjk r}|jjdG|GHdSX|j j t }t j |t j|d }|j j t}t j |t j|d }|} d} x4|d}||krM| dkr8Pn| }d}d} n|j jd|d|} |j| } | dkrd} tdt|jd} y |j jdttWntk rnX|j jdd || fd || | f|j jt d || f|j jt PqqW| s\|jjndS( NsEmpty search strings Regex error:Riis%d.0 linestarts %d.0 lineendtsels%d.%d(RRgRHRVtret IGNORECASEtNonetcompileterrorRtindextAtInserttstringtatoitfindRiR)tmaxR[tgroupt tag_removet AtSelFirstt AtSelLasttTclErrorttag_addtmark_settyview_pickplace(RTR)tmaptprogtmsgtheretlinenotendt endlinenot wraplinenotfoundtlinetiRc((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyRasd              N(t__name__t __module__RxRUR=RZRWRBRNRFRORPRQRoRXR_Ra(((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pyR 9s M            cCsWt}t|}tjdr9|jtjdn|jdd|jdS(Ni(tTkR tsystargvR_tminsizetmainloop(troottsb((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pytmains    ((RRR}RvtTkinterRt MANNDIRLISTt MAN3DIRLISTt foundmanndirtdirtpathtexistsR>t foundman3dirR<tstderrtwriteRRtexitR R R(((s0/usr/lib64/python2.7/Demo/tkinter/guido/tkman.pytsD             PK! 7E guido/mbox.pycnu[ Afc@s)ddlZddlZddlZddlZddlZddlZddlTddlmZejddZ dZ dZ dZ d Z d Zejd Zdd Zdd ZdZddZdadaddZdZdZdZdddZe dS(iN(t*(tdialogtHOMEs/Mailc Cs#daday#tjtjdd\}}Wn(tjk rY}|GHtjdnXx1|D])}|d dkr|daqa|aqaWtja t j ta t a t jatt atjidd6dd 6tt}|jid d 6d d 6t|id d6dd6}|jid d 6d d 6t|idd6atjidd6dd 6dd 6tt atjdidd6td6tjdtjdidd6dd6tjdt|dftdtsettyscrollcommandtyviews s<3>tfixedtfonts Open MessagesRemove MessagesRefile Messagetblacktbgtxi (*tfoldertseqtgetopttsystargvterrorRtmhlibtMHtmht openfoldertmhftTktrootttktFramettoptpackt ScrollbartListboxt folderboxtMenut foldermenutaddt open_foldertbindt folder_unpostt folder_posttscanboxtscanmenut open_messagetremove_messagetrefile_messaget scan_unpostt scan_posttbottNonetviewertminsizet setfolderstrescantmainloop( toptstargstmsgtargR t folderbarRtscanbartrule2((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pytmains#        "         ""               cCs9|j|j}}tj|d|dtjdS(Ni (tx_rootty_rootR4tposttgrab_set(teRR ((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR9scCs5tjddtjtjtjddS(Ntupdatet idletaskstactive(R,tcallR4t grab_releasetunposttinvoke(RT((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR8s  cCs9|j|j}}tj|d|dtjdS(Ni (RPRQR;RRRS(RTRR ((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR@scCs5tjddtjtjtjddS(NRURVRW(R,RXR;RYRZR[(RT((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR?s  s ^ *([0-9]+)cCstj}t|dkr\t|dkr9d}nd}ttd|ddddS|d}tj|atjta t dS(Nis Please open one folder at a timesPlease select a folder to opensCan't Open FolderRitOK( R2t curselectiontlenRR+tgetRR'R(R)RF(RTtselRJti((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR6s   c Cs9tj}t|dkr\t|dkr9d}nd}ttd|ddddStd}d tdttddddddSg}xT|D]L}tj|}tj|dkrK|jt j tj dqKqKWt j |ttt||dS(NisNo Message To Removes!Please select a message to removeRR\i(R:tnearestR]RR+R_ReRftappendRgRhRiR)tremovemessagesRFtfixfocustmin(RTtitopR`ttodoRaRm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR=s   & Rc Cs]tjd}tj}|s>ttddddddStj}t|dkr|skd}nd}ttd |ddddStj|d}g}xT|D]L}tj|}tj |dkr|j t j tj dqqWt|kst r/|adatjtantj|tttt||dS( NisNo Message To Refiles!Please select a message to refileRR\is#Please select a folder to refile tos-Please select exactly one folder to refile tosNo Folder To Refile(R:RsR]RR+R2R^R_ReRfRtRgRhRit lastrefilettofolderRBR'R(R)trefilemessagesRFRvRw( RTRxR`t folderselRJtrefiletoRyRaRm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR>s4     &cCstj}xot|D][}tjt|}tj|dkrtjtj d}||krtPqtqqWd}tj |tj |dS(Niitend( R:tsizetrangeR_treprReRfRgRhRit select_fromR(tnearRxtnRaRmRn((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRvs    cCs;tjddx$tjD]}tjd|qWdS(NiR(R2tdeleteR'tlistallfolderstinsert(tfn((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRE scCsWtrtjdantjddx'tttD]}tjd|q9WdS(NiR( RCRkRBR:Rt scanfolderRR R(Rm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRFs   RRcCs,tdtjd||fdjS(NcSs|d S(Ni((Rm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pytRs scan +%s %str(tmaptostpopent readlines(Rtsequence((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRs(RR"treR!RgR%tTkinterRtenvirontmailboxROR9R8R@R?tcompileReRBR6R<RrR=RzR{R>RvRERFR(((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyts4        x           PK!E`}eR R guido/electrons.pycnu[ Afc@sLddlTddlZdddYZdZedkrHendS(i(t*Nt ElectronscBs&eZddZdZdZRS(c Cs||_t|_}t||_}|j|j|d|j|d}}|r|j|d|dd|dd|_ng|_ d \}}} } xWt |D]I} |j ||| | d d } |j j | |d| d}} qW|jj dS(Ntwidththeightitbitmapt foregroundtbluei iFiiJtfilltred(i iFiiJ(tntTkttktCanvastcanvastpacktgetintt create_bitmapRtpiecestranget create_ovaltappendtupdate( tselfR RR tcRRtx1ty1tx2ty2titp((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyt__init__s   ' cCsq|j}xT|jD]I}tjtdd}tjtdd}|j|||qW|jjdS(Niii(R RtrandomtchoiceRtmoveR R(RR RRtxty((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyt random_move+s  cCshy+x$tdD]}|j|jqWWn6tk rcy|jjWqdtk r_qdXnXdS(Ni(RR$R tTclErrorR tdestroy(RR((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pytrun4s  N(t__name__t __module__tNoneRR$R'(((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyRs  cCsddl}ddl}|jdr>|j|jd}nd}|jdr|jd}|ddkr{|d}qd|}nd}t||}|jdS(Niiiiit@(tsyststringtargvtatoiR*RR'(R,R-R Rth((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pytmain@s     t__main__((tTkinterRRR1R((((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyts  -  PK!E7guido/listtree.pynu[# List a remote app's widget tree (names and classes only) import sys import string from Tkinter import * def listtree(master, app): list = Listbox(master, name='list') list.pack(expand=1, fill=BOTH) listnodes(list, app, '.', 0) return list def listnodes(list, app, widget, level): klass = list.send(app, 'winfo', 'class', widget) ## i = string.rindex(widget, '.') ## list.insert(END, '%s%s (%s)' % ((level-1)*'. ', widget[i:], klass)) list.insert(END, '%s (%s)' % (widget, klass)) children = list.tk.splitlist( list.send(app, 'winfo', 'children', widget)) for c in children: listnodes(list, app, c, level+1) def main(): if not sys.argv[1:]: sys.stderr.write('Usage: listtree appname\n') sys.exit(2) app = sys.argv[1] tk = Tk() tk.minsize(1, 1) f = Frame(tk, name='f') f.pack(expand=1, fill=BOTH) list = listtree(f, app) tk.mainloop() if __name__ == '__main__': main() PK!.55guido/svkill.pyonu[ Afc@sddlTedkr"ednddlmZddlmZddlZddlZejdZ de fd YZ d e fd YZ ed kre dd dZejjdejjddejndS(i(t*g@s/This version of svkill requires Tk 4.0 or later(t splitfields(tsplitNtLOGNAMEt BarButtoncBseZddZRS(cKsOttj||f||jdtt|dd|_|j|dss<1>(0RtFrameR R tBOTHtRAISEDR;tXRtfileRt add_commandtquitR"RtIntVarR&trangetlenR!tadd_radiobuttonRRt tk_menuBarR't StringVarR%tLabeltFLATtNWR@tYtWt ScrollbartVERTICALtvscrolltListboxtSUNKENtBROWSER(tyviewtRIGHTtButtontupdatetbindR6R7R8(RRRtnumR@toptiontcol((s1/usr/lib64/python2.7/Demo/tkinter/guido/svkill.pyR ?sv           (RR(s Every (-e)s-e(sNon process group leaders (-d)s-d(sNon leaders with tty (-a)s-a(RRi(s Long (-l)s-li(s Full (-f)s-fi(sFull Long (-f -l)s-l -fi(sSession and group ID (-j)s-ji(sScheduler properties (-c)s-ciN( RRtuserR!RR RR6R7R8RR (((s1/usr/lib64/python2.7/Demo/tkinter/guido/svkill.pyRs"     t__main__R=isTkinter Process Killer (SYSV)i(tTkintert TkVersiont ImportErrortstringRRR#RtenvironRrR RRRRRRR twinfo_toplevelttitletminsizetmainloop(((s1/usr/lib64/python2.7/Demo/tkinter/guido/svkill.pyts      d PK!GfGf guido/ss1.pynu["""SS1 -- a spreadsheet.""" import os import re import sys import cgi import rexec from xml.parsers import expat LEFT, CENTER, RIGHT = "LEFT", "CENTER", "RIGHT" def ljust(x, n): return x.ljust(n) def center(x, n): return x.center(n) def rjust(x, n): return x.rjust(n) align2action = {LEFT: ljust, CENTER: center, RIGHT: rjust} align2xml = {LEFT: "left", CENTER: "center", RIGHT: "right"} xml2align = {"left": LEFT, "center": CENTER, "right": RIGHT} align2anchor = {LEFT: "w", CENTER: "center", RIGHT: "e"} def sum(seq): total = 0 for x in seq: if x is not None: total += x return total class Sheet: def __init__(self): self.cells = {} # {(x, y): cell, ...} self.rexec = rexec.RExec() m = self.rexec.add_module('__main__') m.cell = self.cellvalue m.cells = self.multicellvalue m.sum = sum def cellvalue(self, x, y): cell = self.getcell(x, y) if hasattr(cell, 'recalc'): return cell.recalc(self.rexec) else: return cell def multicellvalue(self, x1, y1, x2, y2): if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 seq = [] for y in range(y1, y2+1): for x in range(x1, x2+1): seq.append(self.cellvalue(x, y)) return seq def getcell(self, x, y): return self.cells.get((x, y)) def setcell(self, x, y, cell): assert x > 0 and y > 0 assert isinstance(cell, BaseCell) self.cells[x, y] = cell def clearcell(self, x, y): try: del self.cells[x, y] except KeyError: pass def clearcells(self, x1, y1, x2, y2): for xy in self.selectcells(x1, y1, x2, y2): del self.cells[xy] def clearrows(self, y1, y2): self.clearcells(0, y1, sys.maxint, y2) def clearcolumns(self, x1, x2): self.clearcells(x1, 0, x2, sys.maxint) def selectcells(self, x1, y1, x2, y2): if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 return [(x, y) for x, y in self.cells if x1 <= x <= x2 and y1 <= y <= y2] def movecells(self, x1, y1, x2, y2, dx, dy): if dx == 0 and dy == 0: return if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 assert x1+dx > 0 and y1+dy > 0 new = {} for x, y in self.cells: cell = self.cells[x, y] if hasattr(cell, 'renumber'): cell = cell.renumber(x1, y1, x2, y2, dx, dy) if x1 <= x <= x2 and y1 <= y <= y2: x += dx y += dy new[x, y] = cell self.cells = new def insertrows(self, y, n): assert n > 0 self.movecells(0, y, sys.maxint, sys.maxint, 0, n) def deleterows(self, y1, y2): if y1 > y2: y1, y2 = y2, y1 self.clearrows(y1, y2) self.movecells(0, y2+1, sys.maxint, sys.maxint, 0, y1-y2-1) def insertcolumns(self, x, n): assert n > 0 self.movecells(x, 0, sys.maxint, sys.maxint, n, 0) def deletecolumns(self, x1, x2): if x1 > x2: x1, x2 = x2, x1 self.clearcells(x1, x2) self.movecells(x2+1, 0, sys.maxint, sys.maxint, x1-x2-1, 0) def getsize(self): maxx = maxy = 0 for x, y in self.cells: maxx = max(maxx, x) maxy = max(maxy, y) return maxx, maxy def reset(self): for cell in self.cells.itervalues(): if hasattr(cell, 'reset'): cell.reset() def recalc(self): self.reset() for cell in self.cells.itervalues(): if hasattr(cell, 'recalc'): cell.recalc(self.rexec) def display(self): maxx, maxy = self.getsize() width, height = maxx+1, maxy+1 colwidth = [1] * width full = {} # Add column heading labels in row 0 for x in range(1, width): full[x, 0] = text, alignment = colnum2name(x), RIGHT colwidth[x] = max(colwidth[x], len(text)) # Add row labels in column 0 for y in range(1, height): full[0, y] = text, alignment = str(y), RIGHT colwidth[0] = max(colwidth[0], len(text)) # Add sheet cells in columns with x>0 and y>0 for (x, y), cell in self.cells.iteritems(): if x <= 0 or y <= 0: continue if hasattr(cell, 'recalc'): cell.recalc(self.rexec) if hasattr(cell, 'format'): text, alignment = cell.format() assert isinstance(text, str) assert alignment in (LEFT, CENTER, RIGHT) else: text = str(cell) if isinstance(cell, str): alignment = LEFT else: alignment = RIGHT full[x, y] = (text, alignment) colwidth[x] = max(colwidth[x], len(text)) # Calculate the horizontal separator line (dashes and dots) sep = "" for x in range(width): if sep: sep += "+" sep += "-"*colwidth[x] # Now print The full grid for y in range(height): line = "" for x in range(width): text, alignment = full.get((x, y)) or ("", LEFT) text = align2action[alignment](text, colwidth[x]) if line: line += '|' line += text print line if y == 0: print sep def xml(self): out = [''] for (x, y), cell in self.cells.iteritems(): if hasattr(cell, 'xml'): cellxml = cell.xml() else: cellxml = '%s' % cgi.escape(cell) out.append('\n %s\n' % (y, x, cellxml)) out.append('') return '\n'.join(out) def save(self, filename): text = self.xml() f = open(filename, "w") f.write(text) if text and not text.endswith('\n'): f.write('\n') f.close() def load(self, filename): f = open(filename, 'r') SheetParser(self).parsefile(f) f.close() class SheetParser: def __init__(self, sheet): self.sheet = sheet def parsefile(self, f): parser = expat.ParserCreate() parser.StartElementHandler = self.startelement parser.EndElementHandler = self.endelement parser.CharacterDataHandler = self.data parser.ParseFile(f) def startelement(self, tag, attrs): method = getattr(self, 'start_'+tag, None) if method: for key, value in attrs.iteritems(): attrs[key] = str(value) # XXX Convert Unicode to 8-bit method(attrs) self.texts = [] def data(self, text): text = str(text) # XXX Convert Unicode to 8-bit self.texts.append(text) def endelement(self, tag): method = getattr(self, 'end_'+tag, None) if method: method("".join(self.texts)) def start_cell(self, attrs): self.y = int(attrs.get("row")) self.x = int(attrs.get("col")) def start_value(self, attrs): self.fmt = attrs.get('format') self.alignment = xml2align.get(attrs.get('align')) start_formula = start_value def end_int(self, text): try: self.value = int(text) except: self.value = None def end_long(self, text): try: self.value = long(text) except: self.value = None def end_double(self, text): try: self.value = float(text) except: self.value = None def end_complex(self, text): try: self.value = complex(text) except: self.value = None def end_string(self, text): try: self.value = text except: self.value = None def end_value(self, text): if isinstance(self.value, BaseCell): self.cell = self.value elif isinstance(self.value, str): self.cell = StringCell(self.value, self.fmt or "%s", self.alignment or LEFT) else: self.cell = NumericCell(self.value, self.fmt or "%s", self.alignment or RIGHT) def end_formula(self, text): self.cell = FormulaCell(text, self.fmt or "%s", self.alignment or RIGHT) def end_cell(self, text): self.sheet.setcell(self.x, self.y, self.cell) class BaseCell: __init__ = None # Must provide """Abstract base class for sheet cells. Subclasses may but needn't provide the following APIs: cell.reset() -- prepare for recalculation cell.recalc(rexec) -> value -- recalculate formula cell.format() -> (value, alignment) -- return formatted value cell.xml() -> string -- return XML """ class NumericCell(BaseCell): def __init__(self, value, fmt="%s", alignment=RIGHT): assert isinstance(value, (int, long, float, complex)) assert alignment in (LEFT, CENTER, RIGHT) self.value = value self.fmt = fmt self.alignment = alignment def recalc(self, rexec): return self.value def format(self): try: text = self.fmt % self.value except: text = str(self.value) return text, self.alignment def xml(self): method = getattr(self, '_xml_' + type(self.value).__name__) return '%s' % ( align2xml[self.alignment], self.fmt, method()) def _xml_int(self): if -2**31 <= self.value < 2**31: return '%s' % self.value else: return self._xml_long() def _xml_long(self): return '%s' % self.value def _xml_float(self): return '%s' % repr(self.value) def _xml_complex(self): return '%s' % repr(self.value) class StringCell(BaseCell): def __init__(self, text, fmt="%s", alignment=LEFT): assert isinstance(text, (str, unicode)) assert alignment in (LEFT, CENTER, RIGHT) self.text = text self.fmt = fmt self.alignment = alignment def recalc(self, rexec): return self.text def format(self): return self.text, self.alignment def xml(self): s = '%s' return s % ( align2xml[self.alignment], self.fmt, cgi.escape(self.text)) class FormulaCell(BaseCell): def __init__(self, formula, fmt="%s", alignment=RIGHT): assert alignment in (LEFT, CENTER, RIGHT) self.formula = formula self.translated = translate(self.formula) self.fmt = fmt self.alignment = alignment self.reset() def reset(self): self.value = None def recalc(self, rexec): if self.value is None: try: # A hack to evaluate expressions using true division rexec.r_exec("from __future__ import division\n" + "__value__ = eval(%s)" % repr(self.translated)) self.value = rexec.r_eval("__value__") except: exc = sys.exc_info()[0] if hasattr(exc, "__name__"): self.value = exc.__name__ else: self.value = str(exc) return self.value def format(self): try: text = self.fmt % self.value except: text = str(self.value) return text, self.alignment def xml(self): return '%s' % ( align2xml[self.alignment], self.fmt, self.formula) def renumber(self, x1, y1, x2, y2, dx, dy): out = [] for part in re.split('(\w+)', self.formula): m = re.match('^([A-Z]+)([1-9][0-9]*)$', part) if m is not None: sx, sy = m.groups() x = colname2num(sx) y = int(sy) if x1 <= x <= x2 and y1 <= y <= y2: part = cellname(x+dx, y+dy) out.append(part) return FormulaCell("".join(out), self.fmt, self.alignment) def translate(formula): """Translate a formula containing fancy cell names to valid Python code. Examples: B4 -> cell(2, 4) B4:Z100 -> cells(2, 4, 26, 100) """ out = [] for part in re.split(r"(\w+(?::\w+)?)", formula): m = re.match(r"^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$", part) if m is None: out.append(part) else: x1, y1, x2, y2 = m.groups() x1 = colname2num(x1) if x2 is None: s = "cell(%s, %s)" % (x1, y1) else: x2 = colname2num(x2) s = "cells(%s, %s, %s, %s)" % (x1, y1, x2, y2) out.append(s) return "".join(out) def cellname(x, y): "Translate a cell coordinate to a fancy cell name (e.g. (1, 1)->'A1')." assert x > 0 # Column 0 has an empty name, so can't use that return colnum2name(x) + str(y) def colname2num(s): "Translate a column name to number (e.g. 'A'->1, 'Z'->26, 'AA'->27)." s = s.upper() n = 0 for c in s: assert 'A' <= c <= 'Z' n = n*26 + ord(c) - ord('A') + 1 return n def colnum2name(n): "Translate a column number to name (e.g. 1->'A', etc.)." assert n > 0 s = "" while n: n, m = divmod(n-1, 26) s = chr(m+ord('A')) + s return s import Tkinter as Tk class SheetGUI: """Beginnings of a GUI for a spreadsheet. TO DO: - clear multiple cells - Insert, clear, remove rows or columns - Show new contents while typing - Scroll bars - Grow grid when window is grown - Proper menus - Undo, redo - Cut, copy and paste - Formatting and alignment """ def __init__(self, filename="sheet1.xml", rows=10, columns=5): """Constructor. Load the sheet from the filename argument. Set up the Tk widget tree. """ # Create and load the sheet self.filename = filename self.sheet = Sheet() if os.path.isfile(filename): self.sheet.load(filename) # Calculate the needed grid size maxx, maxy = self.sheet.getsize() rows = max(rows, maxy) columns = max(columns, maxx) # Create the widgets self.root = Tk.Tk() self.root.wm_title("Spreadsheet: %s" % self.filename) self.beacon = Tk.Label(self.root, text="A1", font=('helvetica', 16, 'bold')) self.entry = Tk.Entry(self.root) self.savebutton = Tk.Button(self.root, text="Save", command=self.save) self.cellgrid = Tk.Frame(self.root) # Configure the widget lay-out self.cellgrid.pack(side="bottom", expand=1, fill="both") self.beacon.pack(side="left") self.savebutton.pack(side="right") self.entry.pack(side="left", expand=1, fill="x") # Bind some events self.entry.bind("", self.return_event) self.entry.bind("", self.shift_return_event) self.entry.bind("", self.tab_event) self.entry.bind("", self.shift_tab_event) self.entry.bind("", self.delete_event) self.entry.bind("", self.escape_event) # Now create the cell grid self.makegrid(rows, columns) # Select the top-left cell self.currentxy = None self.cornerxy = None self.setcurrent(1, 1) # Copy the sheet cells to the GUI cells self.sync() def delete_event(self, event): if self.cornerxy != self.currentxy and self.cornerxy is not None: self.sheet.clearcells(*(self.currentxy + self.cornerxy)) else: self.sheet.clearcell(*self.currentxy) self.sync() self.entry.delete(0, 'end') return "break" def escape_event(self, event): x, y = self.currentxy self.load_entry(x, y) def load_entry(self, x, y): cell = self.sheet.getcell(x, y) if cell is None: text = "" elif isinstance(cell, FormulaCell): text = '=' + cell.formula else: text, alignment = cell.format() self.entry.delete(0, 'end') self.entry.insert(0, text) self.entry.selection_range(0, 'end') def makegrid(self, rows, columns): """Helper to create the grid of GUI cells. The edge (x==0 or y==0) is filled with labels; the rest is real cells. """ self.rows = rows self.columns = columns self.gridcells = {} # Create the top left corner cell (which selects all) cell = Tk.Label(self.cellgrid, relief='raised') cell.grid_configure(column=0, row=0, sticky='NSWE') cell.bind("", self.selectall) # Create the top row of labels, and confiure the grid columns for x in range(1, columns+1): self.cellgrid.grid_columnconfigure(x, minsize=64) cell = Tk.Label(self.cellgrid, text=colnum2name(x), relief='raised') cell.grid_configure(column=x, row=0, sticky='WE') self.gridcells[x, 0] = cell cell.__x = x cell.__y = 0 cell.bind("", self.selectcolumn) cell.bind("", self.extendcolumn) cell.bind("", self.extendcolumn) cell.bind("", self.extendcolumn) # Create the leftmost column of labels for y in range(1, rows+1): cell = Tk.Label(self.cellgrid, text=str(y), relief='raised') cell.grid_configure(column=0, row=y, sticky='WE') self.gridcells[0, y] = cell cell.__x = 0 cell.__y = y cell.bind("", self.selectrow) cell.bind("", self.extendrow) cell.bind("", self.extendrow) cell.bind("", self.extendrow) # Create the real cells for x in range(1, columns+1): for y in range(1, rows+1): cell = Tk.Label(self.cellgrid, relief='sunken', bg='white', fg='black') cell.grid_configure(column=x, row=y, sticky='NSWE') self.gridcells[x, y] = cell cell.__x = x cell.__y = y # Bind mouse events cell.bind("", self.press) cell.bind("", self.motion) cell.bind("", self.release) cell.bind("", self.release) def selectall(self, event): self.setcurrent(1, 1) self.setcorner(sys.maxint, sys.maxint) def selectcolumn(self, event): x, y = self.whichxy(event) self.setcurrent(x, 1) self.setcorner(x, sys.maxint) def extendcolumn(self, event): x, y = self.whichxy(event) if x > 0: self.setcurrent(self.currentxy[0], 1) self.setcorner(x, sys.maxint) def selectrow(self, event): x, y = self.whichxy(event) self.setcurrent(1, y) self.setcorner(sys.maxint, y) def extendrow(self, event): x, y = self.whichxy(event) if y > 0: self.setcurrent(1, self.currentxy[1]) self.setcorner(sys.maxint, y) def press(self, event): x, y = self.whichxy(event) if x > 0 and y > 0: self.setcurrent(x, y) def motion(self, event): x, y = self.whichxy(event) if x > 0 and y > 0: self.setcorner(x, y) release = motion def whichxy(self, event): w = self.cellgrid.winfo_containing(event.x_root, event.y_root) if w is not None and isinstance(w, Tk.Label): try: return w.__x, w.__y except AttributeError: pass return 0, 0 def save(self): self.sheet.save(self.filename) def setcurrent(self, x, y): "Make (x, y) the current cell." if self.currentxy is not None: self.change_cell() self.clearfocus() self.beacon['text'] = cellname(x, y) self.load_entry(x, y) self.entry.focus_set() self.currentxy = x, y self.cornerxy = None gridcell = self.gridcells.get(self.currentxy) if gridcell is not None: gridcell['bg'] = 'yellow' def setcorner(self, x, y): if self.currentxy is None or self.currentxy == (x, y): self.setcurrent(x, y) return self.clearfocus() self.cornerxy = x, y x1, y1 = self.currentxy x2, y2 = self.cornerxy or self.currentxy if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 for (x, y), cell in self.gridcells.iteritems(): if x1 <= x <= x2 and y1 <= y <= y2: cell['bg'] = 'lightBlue' gridcell = self.gridcells.get(self.currentxy) if gridcell is not None: gridcell['bg'] = 'yellow' self.setbeacon(x1, y1, x2, y2) def setbeacon(self, x1, y1, x2, y2): if x1 == y1 == 1 and x2 == y2 == sys.maxint: name = ":" elif (x1, x2) == (1, sys.maxint): if y1 == y2: name = "%d" % y1 else: name = "%d:%d" % (y1, y2) elif (y1, y2) == (1, sys.maxint): if x1 == x2: name = "%s" % colnum2name(x1) else: name = "%s:%s" % (colnum2name(x1), colnum2name(x2)) else: name1 = cellname(*self.currentxy) name2 = cellname(*self.cornerxy) name = "%s:%s" % (name1, name2) self.beacon['text'] = name def clearfocus(self): if self.currentxy is not None: x1, y1 = self.currentxy x2, y2 = self.cornerxy or self.currentxy if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 for (x, y), cell in self.gridcells.iteritems(): if x1 <= x <= x2 and y1 <= y <= y2: cell['bg'] = 'white' def return_event(self, event): "Callback for the Return key." self.change_cell() x, y = self.currentxy self.setcurrent(x, y+1) return "break" def shift_return_event(self, event): "Callback for the Return key with Shift modifier." self.change_cell() x, y = self.currentxy self.setcurrent(x, max(1, y-1)) return "break" def tab_event(self, event): "Callback for the Tab key." self.change_cell() x, y = self.currentxy self.setcurrent(x+1, y) return "break" def shift_tab_event(self, event): "Callback for the Tab key with Shift modifier." self.change_cell() x, y = self.currentxy self.setcurrent(max(1, x-1), y) return "break" def change_cell(self): "Set the current cell from the entry widget." x, y = self.currentxy text = self.entry.get() cell = None if text.startswith('='): cell = FormulaCell(text[1:]) else: for cls in int, long, float, complex: try: value = cls(text) except: continue else: cell = NumericCell(value) break if cell is None and text: cell = StringCell(text) if cell is None: self.sheet.clearcell(x, y) else: self.sheet.setcell(x, y, cell) self.sync() def sync(self): "Fill the GUI cells from the sheet cells." self.sheet.recalc() for (x, y), gridcell in self.gridcells.iteritems(): if x == 0 or y == 0: continue cell = self.sheet.getcell(x, y) if cell is None: gridcell['text'] = "" else: if hasattr(cell, 'format'): text, alignment = cell.format() else: text, alignment = str(cell), LEFT gridcell['text'] = text gridcell['anchor'] = align2anchor[alignment] def test_basic(): "Basic non-gui self-test." import os a = Sheet() for x in range(1, 11): for y in range(1, 11): if x == 1: cell = NumericCell(y) elif y == 1: cell = NumericCell(x) else: c1 = cellname(x, 1) c2 = cellname(1, y) formula = "%s*%s" % (c1, c2) cell = FormulaCell(formula) a.setcell(x, y, cell) ## if os.path.isfile("sheet1.xml"): ## print "Loading from sheet1.xml" ## a.load("sheet1.xml") a.display() a.save("sheet1.xml") def test_gui(): "GUI test." if sys.argv[1:]: filename = sys.argv[1] else: filename = "sheet1.xml" g = SheetGUI(filename) g.root.mainloop() if __name__ == '__main__': #test_basic() test_gui() PK!k>'guido/hello.pyonu[ ^c@s3ddlZddlTdZdZedS(iN(t*cCsAt}t|}d|ds    PK!o o guido/dialog.pycnu[ Afc@sKddlTddlZdZdZdZedkrGendS(i(t*NcGst|dd}|j||jdt|dtdd}|jdtdtt|dtdd}|jdtdtt |dd d |d d } | jdt d ddtdddd|rt |d|} | jdt ddddnt } g} d} x|D]}t|d |d| | d}| j|| |krt|dtdd}|jdt d ddddd|j|jd|dt ddddddddn.|jdt d ddddddddd| d} q!W|dkrA|jd| || |dn|j}|j|j|j| |j|r|jn| jS(Ntclass_tDialogtrelieft borderwidthitsidetfilltwidtht3ittexttfonts$-Adobe-Times-Medium-R-Normal-*-180-*texpandtpadxt3mtpadytbitmapitcommandcSs |j|S(N(tset(tvti((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyt(tt2mtin_tipadxtipadyt1mscSs|j|j|fS(N(tflashR(tetbRR((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyR:s (tToplevelttitleticonnametFrametRAISEDtpacktTOPtBOTHtBOTTOMtMessagetRIGHTtLabeltLEFTtIntVartButtontappendtSUNKENtlifttbindt focus_gettgrab_sett focus_settwaitvartdestroytget(tmasterRR RtdefaulttargstwttoptbottmsgtbmtvartbuttonsRtbutRtbdtoldFocus((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pytdialog sN   (  !  "         c CsRttddddd}dG|GHttddd d d d d }dG|GHdS(NsNot Respondings=The file server isn't responding right now; I'll keep trying.RitOKspressed buttons File ModifiedswFile "tcl.h" has been modified since the last time it was saved. Do you want to save it before exiting the application?twarningis Save FilesDiscard ChangessReturn To Editor(RDt mainWidget(R((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pytgoLs    cCs}ddl}tatjtttdddt}|jttddd|j}|jdt tj dS(NiR sPress Here To StartRtExitR( tsysR!RGtPacktconfigR,RHR#texitR%tmainloop(RJtstarttendit((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyttestas    t__main__(tTkinterRJRDRHRQt__name__(((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyts   A  PK!,))guido/canvasevents.pyonu[ Afc@sddlTddlmZmZmZdefdYZdddYZdefdYZd dd YZd efd YZd efdYZ de fdYZ dddYZ dZ e dkre ndS(i(t*(tOvaltGroupt CanvasTextRcBseZdddZRS(cCs|jj|j||S(N(tcanvasttag_bindtid(tselftsequencetcommand((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytbind sN(t__name__t __module__tNoneR (((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR stObjectcBsYeZdZdddddZdZdZdZdZd Zd Z RS( sBase class for composite graphical objects. Objects belong to a canvas, and can be moved around on the canvas. They also belong to at most one ``pile'' of objects, and can be transferred between piles (or removed from their pile). Objects have a canonical ``x, y'' position which is moved when the object is moved. Where the object is relative to this position depends on the object; for simple objects, it may be their center. Objects have mouse sensitivity. They can be clicked, dragged and double-clicked. The behavior may actually be determined by the pile they are in. All instance attributes are public since the derived class may need them. itredtobjectcCsJ||_||_||_d|_t|j|_|j||dS(N(RtxtyR tpileRtgroupt createitems(RRRRtfillttext((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyt__init__#s     cCs t|jS(N(tstrR(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyt__str__+sc Cst|j|jd|jd|jd|jdd|dd|_|jj|jt|j|j|jd||_|jj|jdS(Nii RtwidthiR( RRRRt _Object__ovalRtaddtag_withtagRt _Object__text(RRR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR.s + cCsW||kodknr dS|jj|||j||_|j||_dS(Ni(RtmoveRR(Rtdxtdy((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytmoveby7s cCs"|j||j||jdS(N(R"RR(RRR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytmoveto>scCsN|jr%|jj|d|_n||_|jrJ|jj|ndS(N(RtdeleteR tadd(RR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyttransferAs     cCs|jjdS(N(Rttkraise(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR'Is( R R t__doc__RRRR"R#R&R'(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRs    tBottomcBseZdZdZRS(s+An object to serve as the bottom of a pile.c Gs]t|j|jd|jd|jd|jddddd|_|jj|jdS(Nii Rtgraytoutlinet(RRRRt _Bottom__ovalRR(Rtargs((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRQs +(R R R(R(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR)MstPilecBsPeZdZddZdZdZdZdZdZ dZ RS( sA group of graphical objects.cCs~||_||_||_g|_t|j|j|j|_t|jd||_|jj|jj|j dS(Nttag( RRRtobjectsR)tbottomRRRt bindhandlers(RRRRR0((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR\s    cCs0|jjd|j|jjd|jdS(Ns<1>s (RR t clickhandlertdoubleclickhandler(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR3fscCs4|jj||jj|j|j|dS(N(R1tappendRRtposition(RR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR%jscCs'|jj|j|jj|dS(N(RtdtagR1tremove(RR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR$oscCsF|j|jj|}|j|j|d|j|ddS(Nii(R'R1tindexR#RR(RRti((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR7ss cCsdS(N((Rtevent((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR4xscCsdS(N((RR<((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR5{sN( R R R(R RR3R%R$R7R4R5(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR/Xs     t MovingPilecBsAeZdZdZdZeZdZdZdZ RS(cCs=tj||jjd|j|jjd|jdS(Ns s(R/R3RR t motionhandlertreleasehandler(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR3s cCs|jjd}xMtt|jD])}|j|}|jj|kr(Pq(q(Wd|_dS|j||_x|jD]}|j q|W|j |_ |j |_ dS(Ntcurrent(RtgettagstrangetlenR1RR0R tmovethisR'RtlastxRtlasty(RR<ttagsR;to((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR4s   cCsm|js dS|j|j}|j|j}|j|_|j|_x!|jD]}|j||qOWdS(N(RDRRERRFR"(RR<R R!RH((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR>s   cCs-|j}|sdSd|_|j|dS(N(RDR t finishmove(RR<R1((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR?s   cCs"x|D]}|j|qWdS(N(R7(RR1RH((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRIs N( R R R3R RDR4R5R>R?RI(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR=s   tPile1cBs>eZdZdZdZdZdZdZdZRS(i2tp1cCs5||_tj||jj|j|j|jdS(N(tdemoR=RRRRR0(RRL((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRs cCsMy|jd}Wntk r%dSX|j|jtj||dS(Ni(R1t IndexErrorR&totherR=R5(RR<RH((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyR5s  cCs |jjS(N(RLtp2(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRNscCs|d}|j}|j|j}}||jd||jd||jd||jdkrx.|D]}|j|qpWntj||dS(Nii(RNRRR&R=RI(RR1RHtpRR((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRIs  @ ( R R RRR0RR5RNRI(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRJs   tPile2cBs#eZdZdZdZdZRS(ii2ROcCs |jjS(N(RLRK(R((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRNs(R R RRR0RN(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRQstDemocBseZdZRS(c Cs||_t|dddddddtdd|_|jjd d d tt||_t||_ t |jd d d d}t |jd dd d}t |jd dd d}|j |j|j |j|j |j dS(NRitheightt backgroundtyellowtrelieft borderwidthitexpandiRRRto1tgreento2s light blueto3( tmastertCanvastSUNKENRtpacktBOTHRJRKRQRORR&(RR]RYR[R\((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRs   (R R R(((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyRRscCs6t}t|}|jd|j|jdS(NtWM_DELETE_WINDOW(tTkRRtprotocoltquittmainloop(trootRL((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pytmains  t__main__N((((tTkinterR^RRRRR)R/R=RJRQRRRhR (((s7/usr/lib64/python2.7/Demo/tkinter/guido/canvasevents.pyts ? '0   PK!qfXXguido/newmenubardemo.pycnu[ Afc@sFdZddlTdddYZdZedkrBendS( s.Play with the new Tk 8.0 toplevel menu option.i(t*tAppcBseZdZRS(cCsu||_t|j|_t|j|_|jjdd|jjdd|jjdd|jj|jjddd|jjt|j|_|jjdd|jjdd|jjdd t|jd d |_|jjdd |jj dd d|j|jj ddd|j|jj ddd|jt d|j|_ dS(NtlabeltNewsOpen...tClosetQuittcommandtCuttCopytPastetnamethelpsAbout...tFiletmenutEdittHelp( tmastertMenutmenubartfilemenut add_commandt add_separatortquitteditmenuthelpmenut add_cascadetToplevelttop(tselfR((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pyt__init__ s$  (t__name__t __module__R(((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pyRscCs-t}|jt|}|jdS(N(tTktwithdrawRtmainloop(troottapp((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pytmain(s   t__main__N((t__doc__tTkinterRR%R(((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pyts  !  PK! 7E guido/mbox.pyonu[ Afc@s)ddlZddlZddlZddlZddlZddlZddlTddlmZejddZ dZ dZ dZ d Z d Zejd Zdd Zdd ZdZddZdadaddZdZdZdZdddZe dS(iN(t*(tdialogtHOMEs/Mailc Cs#daday#tjtjdd\}}Wn(tjk rY}|GHtjdnXx1|D])}|d dkr|daqa|aqaWtja t j ta t a t jatt atjidd6dd 6tt}|jid d 6d d 6t|id d6dd6}|jid d 6d d 6t|idd6atjidd6dd 6dd 6tt atjdidd6td6tjdtjdidd6dd6tjdt|dftdtsettyscrollcommandtyviews s<3>tfixedtfonts Open MessagesRemove MessagesRefile Messagetblacktbgtxi (*tfoldertseqtgetopttsystargvterrorRtmhlibtMHtmht openfoldertmhftTktrootttktFramettoptpackt ScrollbartListboxt folderboxtMenut foldermenutaddt open_foldertbindt folder_unpostt folder_posttscanboxtscanmenut open_messagetremove_messagetrefile_messaget scan_unpostt scan_posttbottNonetviewertminsizet setfolderstrescantmainloop( toptstargstmsgtargR t folderbarRtscanbartrule2((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pytmains#        "         ""               cCs9|j|j}}tj|d|dtjdS(Ni (tx_rootty_rootR4tposttgrab_set(teRR ((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR9scCs5tjddtjtjtjddS(Ntupdatet idletaskstactive(R,tcallR4t grab_releasetunposttinvoke(RT((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR8s  cCs9|j|j}}tj|d|dtjdS(Ni (RPRQR;RRRS(RTRR ((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR@scCs5tjddtjtjtjddS(NRURVRW(R,RXR;RYRZR[(RT((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR?s  s ^ *([0-9]+)cCstj}t|dkr\t|dkr9d}nd}ttd|ddddS|d}tj|atjta t dS(Nis Please open one folder at a timesPlease select a folder to opensCan't Open FolderRitOK( R2t curselectiontlenRR+tgetRR'R(R)RF(RTtselRJti((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR6s   c Cs9tj}t|dkr\t|dkr9d}nd}ttd|ddddStd}d tdttddddddSg}xT|D]L}tj|}tj|dkrK|jt j tj dqKqKWt j |ttt||dS(NisNo Message To Removes!Please select a message to removeRR\i(R:tnearestR]RR+R_ReRftappendRgRhRiR)tremovemessagesRFtfixfocustmin(RTtitopR`ttodoRaRm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR=s   & Rc Cs]tjd}tj}|s>ttddddddStj}t|dkr|skd}nd}ttd |ddddStj|d}g}xT|D]L}tj|}tj |dkr|j t j tj dqqWt|kst r/|adatjtantj|tttt||dS( NisNo Message To Refiles!Please select a message to refileRR\is#Please select a folder to refile tos-Please select exactly one folder to refile tosNo Folder To Refile(R:RsR]RR+R2R^R_ReRfRtRgRhRit lastrefilettofolderRBR'R(R)trefilemessagesRFRvRw( RTRxR`t folderselRJtrefiletoRyRaRm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyR>s4     &cCstj}xot|D][}tjt|}tj|dkrtjtj d}||krtPqtqqWd}tj |tj |dS(Niitend( R:tsizetrangeR_treprReRfRgRhRit select_fromR(tnearRxtnRaRmRn((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRvs    cCs;tjddx$tjD]}tjd|qWdS(NiR(R2tdeleteR'tlistallfolderstinsert(tfn((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRE scCsWtrtjdantjddx'tttD]}tjd|q9WdS(NiR( RCRkRBR:Rt scanfolderRR R(Rm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRFs   RRcCs,tdtjd||fdjS(NcSs|d S(Ni((Rm((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pytRs scan +%s %str(tmaptostpopent readlines(Rtsequence((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyRs(RR"treR!RgR%tTkinterRtenvirontmailboxROR9R8R@R?tcompileReRBR6R<RrR=RzR{R>RvRERFR(((s//usr/lib64/python2.7/Demo/tkinter/guido/mbox.pyts4        x           PK!|Dguido/paint.pycnu[ ^c@s`dZddlTdad \aadZdZdZdZ e dkr\end S( sA"Paint program by Dave Michell. Subject: tkinter "paint" example From: Dave Mitchell To: python-list@cwi.nl Date: Fri, 23 Jan 1998 12:18:05 -0500 (EST) Not too long ago (last week maybe?) someone posted a request for an example of a paint program using Tkinter. Try as I might I can't seem to find it in the archive, so i'll just post mine here and hope that the person who requested it sees this! All this does is put up a canvas and draw a smooth black line whenever you have the mouse button down, but hopefully it will be enough to start with.. It would be easy enough to add some options like other shapes or colors... yours, dave mitchell davem@magnet.com i(t*tupcCs]t}t|}|j|jdt|jdt|jdt|jdS(Nsss(tTktCanvastpacktbindtmotiontb1downtb1uptmainloop(troott drawing_area((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pytmains   cCs dadS(Ntdown(tb1(tevent((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyR'scCsdadadadS(NR(RtNonetxoldtyold(R((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyR,scCsetdkratdk rLtdk rL|jjtt|j|jdtn|ja|jandS(NR tsmooth( RRRRtwidgett create_linetxtytTRUE(R((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyR2s  ( t__main__N(NN( t__doc__tTkinterRRRRR RRRt__name__(((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyts     PK!', self.do_motion) self.frame.list.bind('', self.do_leave) self.frame.list.bind('<1>', self.do_1) self.do_update() if __name__ == '__main__': kill = Kill(None, borderwidth=5) kill.winfo_toplevel().title('Tkinter Process Killer (SYSV)') kill.winfo_toplevel().minsize(1, 1) kill.mainloop() PK!YYguido/brownian.pycnu[ ^c@sddlTddlZddlZddlZddlZdZdZdZdZdZ dZ dZ da d Z d ZedS( i(t*Nii,i itredicCst}tjtdt}tjtdt}|j||||||||dt}xvtstjdt }tjdt }tj t }y|j |||Wnt k rPnXtj|qcWdS(Ng@tfilli(tRADIUStrandomtgausstWIDTHtSIGMAtHEIGHTt create_ovaltFILLtstoptBUZZt expovariatetLAMBDAtmovetTclErrorttimetsleep(tcanvastrtxtytptdxtdytdt((s3/usr/lib64/python2.7/Demo/tkinter/guido/brownian.pytparticles.  cCst}t|dtdt}|jddddd}tjdr`ttjd}nx9t|D]+}t j dt d |f}|j qmWz|j WddaXdS( NtwidththeightRtbothtexpandiittargettargs(tTktCanvasRRtpacktsystargvtinttranget threadingtThreadRtstarttmainloopR (trootRtnptitt((s3/usr/lib64/python2.7/Demo/tkinter/guido/brownian.pytmain"s  (tTkinterRR)RR%RRRR RRR R RR1(((s3/usr/lib64/python2.7/Demo/tkinter/guido/brownian.pyts       PK!&Yguido/listtree.pyonu[ ^c@sWddlZddlZddlTdZdZdZedkrSendS(iN(t*cCs?t|dd}|jdddtt||dd|S(Ntnametlisttexpanditfillt.i(tListboxtpacktBOTHt listnodes(tmastertappR((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pytlisttreescCs|j|dd|}|jtd||f|jj|j|dd|}x%|D]}t||||dq]WdS(Ntwinfotclasss%s (%s)tchildreni(tsendtinserttENDttkt splitlistR (RR twidgettleveltklassRtc((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pyR s   cCstjds-tjjdtjdntjd}t}|jddt|dd}|jdddt t ||}|j dS(NisUsage: listtree appname iRtfRR( tsystargvtstderrtwritetexittTktminsizetFrameRRR tmainloop(R RRR((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pytmains   t__main__(RtstringtTkinterR R R#t__name__(((s3/usr/lib64/python2.7/Demo/tkinter/guido/listtree.pyts     PK!/ Ŕccguido/brownian2.pynu[# Brownian motion -- an example of a NON multi-threaded Tkinter program ;) # By Michele Simoniato, inspired by brownian.py from Tkinter import * import random import sys WIDTH = 400 HEIGHT = 300 SIGMA = 10 BUZZ = 2 RADIUS = 2 LAMBDA = 10 FILL = 'red' stop = 0 # Set when main loop exits root = None # main window def particle(canvas): # particle = iterator over the moves r = RADIUS x = random.gauss(WIDTH/2.0, SIGMA) y = random.gauss(HEIGHT/2.0, SIGMA) p = canvas.create_oval(x-r, y-r, x+r, y+r, fill=FILL) while not stop: dx = random.gauss(0, BUZZ) dy = random.gauss(0, BUZZ) try: canvas.move(p, dx, dy) except TclError: break else: yield None def move(particle): # move the particle at random time particle.next() dt = random.expovariate(LAMBDA) root.after(int(dt*1000), move, particle) def main(): global root, stop root = Tk() canvas = Canvas(root, width=WIDTH, height=HEIGHT) canvas.pack(fill='both', expand=1) np = 30 if sys.argv[1:]: np = int(sys.argv[1]) for i in range(np): # start the dance move(particle(canvas)) try: root.mainloop() finally: stop = 1 if __name__ == '__main__': main() PK!%Lguido/brownian2.pyonu[ ^c@sddlTddlZddlZdZdZdZdZdZdZdZ da da d Z d Zd Zed krendS( i(t*Nii,i itrediccst}tjtdt}tjtdt}|j||||||||dt}x_tstjdt }tjdt }y|j |||Wnt k rPqcXdVqcWdS(Ng@tfilli( tRADIUStrandomtgausstWIDTHtSIGMAtHEIGHTt create_ovaltFILLtstoptBUZZtmovetTclErrortNone(tcanvastrtxtytptdxtdy((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pytparticles.  cCs:|jtjt}tjt|dt|dS(Ni(tnextRt expovariatetLAMBDAtroottaftertintR (Rtdt((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pyR "s cCstattdtdt}|jddddd}tjdr`ttjd}nx$t |D]}t t |qmWztj Wdda XdS(NtwidththeightRtbothtexpandii(tTkRtCanvasRRtpacktsystargvRtrangeR RtmainloopR (Rtnpti((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pytmain's  t__main__(tTkinterRR&RRRR RRR R RRRR R,t__name__(((s4/usr/lib64/python2.7/Demo/tkinter/guido/brownian2.pyts       PK!ե))guido/hanoi.pynu[# Animated Towers of Hanoi using Tk with optional bitmap file in # background. # # Usage: tkhanoi [n [bitmapfile]] # # n is the number of pieces to animate; default is 4, maximum 15. # # The bitmap file can be any X11 bitmap file (look in # /usr/include/X11/bitmaps for samples); it is displayed as the # background of the animation. Default is no bitmap. # This uses Steen Lumholt's Tk interface from Tkinter import * # Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c # as temporary. For each move, call report() def hanoi(n, a, b, c, report): if n <= 0: return hanoi(n-1, a, c, b, report) report(n, a, b) hanoi(n-1, c, b, a, report) # The graphical interface class Tkhanoi: # Create our objects def __init__(self, n, bitmap = None): self.n = n self.tk = tk = Tk() self.canvas = c = Canvas(tk) c.pack() width, height = tk.getint(c['width']), tk.getint(c['height']) # Add background bitmap if bitmap: self.bitmap = c.create_bitmap(width//2, height//2, bitmap=bitmap, foreground='blue') # Generate pegs pegwidth = 10 pegheight = height//2 pegdist = width//3 x1, y1 = (pegdist-pegwidth)//2, height*1//3 x2, y2 = x1+pegwidth, y1+pegheight self.pegs = [] p = c.create_rectangle(x1, y1, x2, y2, fill='black') self.pegs.append(p) x1, x2 = x1+pegdist, x2+pegdist p = c.create_rectangle(x1, y1, x2, y2, fill='black') self.pegs.append(p) x1, x2 = x1+pegdist, x2+pegdist p = c.create_rectangle(x1, y1, x2, y2, fill='black') self.pegs.append(p) self.tk.update() # Generate pieces pieceheight = pegheight//16 maxpiecewidth = pegdist*2//3 minpiecewidth = 2*pegwidth self.pegstate = [[], [], []] self.pieces = {} x1, y1 = (pegdist-maxpiecewidth)//2, y2-pieceheight-2 x2, y2 = x1+maxpiecewidth, y1+pieceheight dx = (maxpiecewidth-minpiecewidth) // (2*max(1, n-1)) for i in range(n, 0, -1): p = c.create_rectangle(x1, y1, x2, y2, fill='red') self.pieces[i] = p self.pegstate[0].append(i) x1, x2 = x1 + dx, x2-dx y1, y2 = y1 - pieceheight-2, y2-pieceheight-2 self.tk.update() self.tk.after(25) # Run -- never returns def run(self): while 1: hanoi(self.n, 0, 1, 2, self.report) hanoi(self.n, 1, 2, 0, self.report) hanoi(self.n, 2, 0, 1, self.report) hanoi(self.n, 0, 2, 1, self.report) hanoi(self.n, 2, 1, 0, self.report) hanoi(self.n, 1, 0, 2, self.report) # Reporting callback for the actual hanoi function def report(self, i, a, b): if self.pegstate[a][-1] != i: raise RuntimeError # Assertion del self.pegstate[a][-1] p = self.pieces[i] c = self.canvas # Lift the piece above peg a ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a]) while 1: x1, y1, x2, y2 = c.bbox(p) if y2 < ay1: break c.move(p, 0, -1) self.tk.update() # Move it towards peg b bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) newcenter = (bx1+bx2)//2 while 1: x1, y1, x2, y2 = c.bbox(p) center = (x1+x2)//2 if center == newcenter: break if center > newcenter: c.move(p, -1, 0) else: c.move(p, 1, 0) self.tk.update() # Move it down on top of the previous piece pieceheight = y2-y1 newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2 while 1: x1, y1, x2, y2 = c.bbox(p) if y2 >= newbottom: break c.move(p, 0, 1) self.tk.update() # Update peg state self.pegstate[b].append(i) # Main program def main(): import sys, string # First argument is number of pegs, default 4 if sys.argv[1:]: n = string.atoi(sys.argv[1]) else: n = 4 # Second argument is bitmap file, default none if sys.argv[2:]: bitmap = sys.argv[2] # Reverse meaning of leading '@' compared to Tk if bitmap[0] == '@': bitmap = bitmap[1:] else: bitmap = '@' + bitmap else: bitmap = None # Create the graphical objects... h = Tkhanoi(n, bitmap) # ...and run! h.run() # Call main when run as script if __name__ == '__main__': main() PK!o o guido/dialog.pyonu[ Afc@sKddlTddlZdZdZdZedkrGendS(i(t*NcGst|dd}|j||jdt|dtdd}|jdtdtt|dtdd}|jdtdtt |dd d |d d } | jdt d ddtdddd|rt |d|} | jdt ddddnt } g} d} x|D]}t|d |d| | d}| j|| |krt|dtdd}|jdt d ddddd|j|jd|dt ddddddddn.|jdt d ddddddddd| d} q!W|dkrA|jd| || |dn|j}|j|j|j| |j|r|jn| jS(Ntclass_tDialogtrelieft borderwidthitsidetfilltwidtht3ittexttfonts$-Adobe-Times-Medium-R-Normal-*-180-*texpandtpadxt3mtpadytbitmapitcommandcSs |j|S(N(tset(tvti((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyt(tt2mtin_tipadxtipadyt1mscSs|j|j|fS(N(tflashR(tetbRR((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyR:s (tToplevelttitleticonnametFrametRAISEDtpacktTOPtBOTHtBOTTOMtMessagetRIGHTtLabeltLEFTtIntVartButtontappendtSUNKENtlifttbindt focus_gettgrab_sett focus_settwaitvartdestroytget(tmasterRR RtdefaulttargstwttoptbottmsgtbmtvartbuttonsRtbutRtbdtoldFocus((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pytdialog sN   (  !  "         c CsRttddddd}dG|GHttddd d d d d }dG|GHdS(NsNot Respondings=The file server isn't responding right now; I'll keep trying.RitOKspressed buttons File ModifiedswFile "tcl.h" has been modified since the last time it was saved. Do you want to save it before exiting the application?twarningis Save FilesDiscard ChangessReturn To Editor(RDt mainWidget(R((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pytgoLs    cCs}ddl}tatjtttdddt}|jttddd|j}|jdt tj dS(NiR sPress Here To StartRtExitR( tsysR!RGtPacktconfigR,RHR#texitR%tmainloop(RJtstarttendit((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyttestas    t__main__(tTkinterRJRDRHRQt__name__(((s1/usr/lib64/python2.7/Demo/tkinter/guido/dialog.pyts   A  PK!| guido/MimeViewer.pynuȯ#! /usr/bin/python2.7 # View a single MIME multipart message. # Display each part as a box. import string from types import * from Tkinter import * from ScrolledText import ScrolledText class MimeViewer: def __init__(self, parent, title, msg): self.title = title self.msg = msg self.frame = Frame(parent, {'relief': 'raised', 'bd': 2}) self.frame.packing = {'expand': 0, 'fill': 'both'} self.button = Checkbutton(self.frame, {'text': title, 'command': self.toggle}) self.button.pack({'anchor': 'w'}) headertext = msg.getheadertext( lambda x: x != 'received' and x[:5] != 'x400-') height = countlines(headertext, 4) if height: self.htext = ScrolledText(self.frame, {'height': height, 'width': 80, 'wrap': 'none', 'relief': 'raised', 'bd': 2}) self.htext.packing = {'expand': 1, 'fill': 'both', 'after': self.button} self.htext.insert('end', headertext) else: self.htext = Frame(self.frame, {'relief': 'raised', 'bd': 2}) self.htext.packing = {'side': 'top', 'ipady': 2, 'fill': 'x', 'after': self.button} body = msg.getbody() if type(body) == StringType: self.pad = None height = countlines(body, 10) if height: self.btext = ScrolledText(self.frame, {'height': height, 'width': 80, 'wrap': 'none', 'relief': 'raised', 'bd': 2}) self.btext.packing = {'expand': 1, 'fill': 'both'} self.btext.insert('end', body) else: self.btext = None self.parts = None else: self.pad = Frame(self.frame, {'relief': 'flat', 'bd': 2}) self.pad.packing = {'side': 'left', 'ipadx': 10, 'fill': 'y', 'after': self.htext} self.parts = [] for i in range(len(body)): p = MimeViewer(self.frame, '%s.%d' % (title, i+1), body[i]) self.parts.append(p) self.btext = None self.collapsed = 1 def pack(self): self.frame.pack(self.frame.packing) def destroy(self): self.frame.destroy() def show(self): if self.collapsed: self.button.invoke() def toggle(self): if self.collapsed: self.explode() else: self.collapse() def collapse(self): self.collapsed = 1 for comp in self.htext, self.btext, self.pad: if comp: comp.forget() if self.parts: for part in self.parts: part.frame.forget() self.frame.pack({'expand': 0}) def explode(self): self.collapsed = 0 for comp in self.htext, self.btext, self.pad: if comp: comp.pack(comp.packing) if self.parts: for part in self.parts: part.pack() self.frame.pack({'expand': 1}) def countlines(str, limit): i = 0 n = 0 while n < limit: i = string.find(str, '\n', i) if i < 0: break n = n+1 i = i+1 return n def main(): import sys import getopt import mhlib opts, args = getopt.getopt(sys.argv[1:], '') for o, a in opts: pass message = None folder = 'inbox' for arg in args: if arg[:1] == '+': folder = arg[1:] else: message = string.atoi(arg) mh = mhlib.MH() f = mh.openfolder(folder) if not message: message = f.getcurrent() m = f.openmessage(message) root = Tk() tk = root.tk top = MimeViewer(root, '+%s/%d' % (folder, message), m) top.pack() top.show() root.minsize(1, 1) tk.mainloop() if __name__ == '__main__': main() PK!|Dguido/paint.pyonu[ ^c@s`dZddlTdad \aadZdZdZdZ e dkr\end S( sA"Paint program by Dave Michell. Subject: tkinter "paint" example From: Dave Mitchell To: python-list@cwi.nl Date: Fri, 23 Jan 1998 12:18:05 -0500 (EST) Not too long ago (last week maybe?) someone posted a request for an example of a paint program using Tkinter. Try as I might I can't seem to find it in the archive, so i'll just post mine here and hope that the person who requested it sees this! All this does is put up a canvas and draw a smooth black line whenever you have the mouse button down, but hopefully it will be enough to start with.. It would be easy enough to add some options like other shapes or colors... yours, dave mitchell davem@magnet.com i(t*tupcCs]t}t|}|j|jdt|jdt|jdt|jdS(Nsss(tTktCanvastpacktbindtmotiontb1downtb1uptmainloop(troott drawing_area((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pytmains   cCs dadS(Ntdown(tb1(tevent((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyR'scCsdadadadS(NR(RtNonetxoldtyold(R((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyR,scCsetdkratdk rLtdk rL|jjtt|j|jdtn|ja|jandS(NR tsmooth( RRRRtwidgett create_linetxtytTRUE(R((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyR2s  ( t__main__N(NN( t__doc__tTkinterRRRRR RRRt__name__(((s0/usr/lib64/python2.7/Demo/tkinter/guido/paint.pyts     PK!(Vguido/ManPage.pynu[# Widget to display a man page import re from Tkinter import * from Tkinter import _tkinter from ScrolledText import ScrolledText # XXX These fonts may have to be changed to match your system BOLDFONT = '*-Courier-Bold-R-Normal-*-120-*' ITALICFONT = '*-Courier-Medium-O-Normal-*-120-*' # XXX Recognizing footers is system dependent # (This one works for IRIX 5.2 and Solaris 2.2) footerprog = re.compile( '^ Page [1-9][0-9]*[ \t]+\|^.*Last change:.*[1-9][0-9]*\n') emptyprog = re.compile('^[ \t]*\n') ulprog = re.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n') # Basic Man Page class -- does not disable editing class EditableManPage(ScrolledText): # Initialize instance def __init__(self, master=None, **cnf): # Initialize base class apply(ScrolledText.__init__, (self, master), cnf) # Define tags for formatting styles self.tag_config('X', underline=1) self.tag_config('!', font=BOLDFONT) self.tag_config('_', font=ITALICFONT) # Set state to idle self.fp = None self.lineno = 0 # Test whether we are busy parsing a file def busy(self): return self.fp != None # Ensure we're not busy def kill(self): if self.busy(): self._endparser() # Parse a file, in the background def asyncparsefile(self, fp): self._startparser(fp) self.tk.createfilehandler(fp, _tkinter.READABLE, self._filehandler) parsefile = asyncparsefile # Alias # I/O handler used by background parsing def _filehandler(self, fp, mask): nextline = self.fp.readline() if not nextline: self._endparser() return self._parseline(nextline) # Parse a file, now (cannot be aborted) def syncparsefile(self, fp): from select import select def avail(fp=fp, tout=0.0, select=select): return select([fp], [], [], tout)[0] height = self.getint(self['height']) self._startparser(fp) while 1: nextline = fp.readline() if not nextline: break self._parseline(nextline) self._endparser() # Initialize parsing from a particular file -- must not be busy def _startparser(self, fp): if self.busy(): raise RuntimeError, 'startparser: still busy' fp.fileno() # Test for file-ness self.fp = fp self.lineno = 0 self.ok = 0 self.empty = 0 self.buffer = None savestate = self['state'] self['state'] = NORMAL self.delete('1.0', END) self['state'] = savestate # End parsing -- must be busy, need not be at EOF def _endparser(self): if not self.busy(): raise RuntimeError, 'endparser: not busy' if self.buffer: self._parseline('') try: self.tk.deletefilehandler(self.fp) except TclError, msg: pass self.fp.close() self.fp = None del self.ok, self.empty, self.buffer # Parse a single line def _parseline(self, nextline): if not self.buffer: # Save this line -- we need one line read-ahead self.buffer = nextline return if emptyprog.match(self.buffer) >= 0: # Buffered line was empty -- set a flag self.empty = 1 self.buffer = nextline return textline = self.buffer if ulprog.match(nextline) >= 0: # Next line is properties for buffered line propline = nextline self.buffer = None else: # Next line is read-ahead propline = None self.buffer = nextline if not self.ok: # First non blank line after footer must be header # -- skip that too self.ok = 1 self.empty = 0 return if footerprog.match(textline) >= 0: # Footer -- start skipping until next non-blank line self.ok = 0 self.empty = 0 return savestate = self['state'] self['state'] = NORMAL if TkVersion >= 4.0: self.mark_set('insert', 'end-1c') else: self.mark_set('insert', END) if self.empty: # One or more previous lines were empty # -- insert one blank line in the text self._insert_prop('\n') self.lineno = self.lineno + 1 self.empty = 0 if not propline: # No properties self._insert_prop(textline) else: # Search for properties p = '' j = 0 for i in range(min(len(propline), len(textline))): if propline[i] != p: if j < i: self._insert_prop(textline[j:i], p) j = i p = propline[i] self._insert_prop(textline[j:]) self.lineno = self.lineno + 1 self['state'] = savestate # Insert a string at the end, with at most one property (tag) def _insert_prop(self, str, prop = ' '): here = self.index(AtInsert()) self.insert(AtInsert(), str) if TkVersion <= 4.0: tags = self.tag_names(here) for tag in tags: self.tag_remove(tag, here, AtInsert()) if prop != ' ': self.tag_add(prop, here, AtInsert()) # Readonly Man Page class -- disables editing, otherwise the same class ReadonlyManPage(EditableManPage): # Initialize instance def __init__(self, master=None, **cnf): cnf['state'] = DISABLED apply(EditableManPage.__init__, (self, master), cnf) # Alias ManPage = ReadonlyManPage # Test program. # usage: ManPage [manpage]; or ManPage [-f] file # -f means that the file is nroff -man output run through ul -i def test(): import os import sys # XXX This directory may be different on your system MANDIR = '/usr/local/man/mann' DEFAULTPAGE = 'Tcl' formatted = 0 if sys.argv[1:] and sys.argv[1] == '-f': formatted = 1 del sys.argv[1] if sys.argv[1:]: name = sys.argv[1] else: name = DEFAULTPAGE if not formatted: if name[-2:-1] != '.': name = name + '.n' name = os.path.join(MANDIR, name) root = Tk() root.minsize(1, 1) manpage = ManPage(root, relief=SUNKEN, borderwidth=2) manpage.pack(expand=1, fill=BOTH) if formatted: fp = open(name, 'r') else: fp = os.popen('nroff -man %s | ul -i' % name, 'r') manpage.parsefile(fp) root.mainloop() # Run the test program when called as a script if __name__ == '__main__': test() PK!`xIIguido/hanoi.pycnu[ ^c@sIddlTdZdddYZdZedkrEendS( i(t*cCsX|dkrdSt|d||||||||t|d||||dS(Nii(thanoi(tntatbtctreport((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyRs  tTkhanoicBs&eZddZdZdZRS(cCs||_t|_}t||_}|j|j|d|j|d}}|r|j|d|dd|dd|_nd}|d}|d} | |d|d d} } | || |} } g|_ |j | | | | d d }|j j || | | | } } |j | | | | d d }|j j || | | | } } |j | | | | d d }|j j ||jj |d }| dd}d|}gggg|_ i|_| |d| |d} } | || |} } ||dtd |d }xt|d dD]}|j | | | | d d}||j|<|j d j || || |} } | |d| |d} } |jj |jjdqFWdS(Ntwidththeightitbitmapt foregroundtbluei iitfilltblackiiitredi(RtTkttktCanvastcanvastpacktgetintt create_bitmapR tpegstcreate_rectangletappendtupdatetpegstatetpiecestmaxtrangetafter(tselfRR RRRR tpegwidtht pegheighttpegdisttx1ty1tx2ty2tpt pieceheightt maxpiecewidtht minpiecewidthtdxti((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyt__init__sP  '         cCsxt|jddd|jt|jddd|jt|jddd|jt|jddd|jt|jddd|jt|jddd|jqWdS(Niii(RRR(R ((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pytrunNscCs|j|d|kr tn|j|d=|j|}|j}|j|j|\}}}} xO|j|\} } } } | |krPn|j|dd|jjqiW|j|j|\}}}}||d}x|j|\} } } } | | d}||kr$Pn||krF|j|ddn|j|dd|jjqW| | }||t |j|d}xO|j|\} } } } | |krPn|j|dd|jjqW|j|j |dS(Niiii( Rt RuntimeErrorRRtbboxRtmoveRRtlenR(R R-RRR(Rtax1tay1tax2tay2R$R%R&R'tbx1tby1tbx2tby2t newcentertcenterR)t newbottom((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyRXs@   " "    N(t__name__t __module__tNoneR.R/R(((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyRs 1 cCsddl}ddl}|jdr>|j|jd}nd}|jdr|jd}|ddkr{|d}qd|}nd}t||}|jdS(Niiiiit@(tsyststringtargvtatoiRARR/(RCRDRR th((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pytmains     t__main__N((tTkinterRRRHR?(((s0/usr/lib64/python2.7/Demo/tkinter/guido/hanoi.pyt s  e  PK!k>'guido/hello.pycnu[ ^c@s3ddlZddlTdZdZedS(iN(t*cCsAt}t|}d|ds    PK!`&CCguido/brownian.pynu[# Brownian motion -- an example of a multi-threaded Tkinter program. from Tkinter import * import random import threading import time import sys WIDTH = 400 HEIGHT = 300 SIGMA = 10 BUZZ = 2 RADIUS = 2 LAMBDA = 10 FILL = 'red' stop = 0 # Set when main loop exits def particle(canvas): r = RADIUS x = random.gauss(WIDTH/2.0, SIGMA) y = random.gauss(HEIGHT/2.0, SIGMA) p = canvas.create_oval(x-r, y-r, x+r, y+r, fill=FILL) while not stop: dx = random.gauss(0, BUZZ) dy = random.gauss(0, BUZZ) dt = random.expovariate(LAMBDA) try: canvas.move(p, dx, dy) except TclError: break time.sleep(dt) def main(): global stop root = Tk() canvas = Canvas(root, width=WIDTH, height=HEIGHT) canvas.pack(fill='both', expand=1) np = 30 if sys.argv[1:]: np = int(sys.argv[1]) for i in range(np): t = threading.Thread(target=particle, args=(canvas,)) t.start() try: root.mainloop() finally: stop = 1 main() PK!Ṁ guido/dialog.pynuȯ#! /usr/bin/python2.7 # A Python function that generates dialog boxes with a text message, # optional bitmap, and any number of buttons. # Cf. Ousterhout, Tcl and the Tk Toolkit, Figs. 27.2-3, pp. 269-270. from Tkinter import * import sys def dialog(master, title, text, bitmap, default, *args): # 1. Create the top-level window and divide it into top # and bottom parts. w = Toplevel(master, class_='Dialog') w.title(title) w.iconname('Dialog') top = Frame(w, relief=RAISED, borderwidth=1) top.pack(side=TOP, fill=BOTH) bot = Frame(w, relief=RAISED, borderwidth=1) bot.pack(side=BOTTOM, fill=BOTH) # 2. Fill the top part with the bitmap and message. msg = Message(top, width='3i', text=text, font='-Adobe-Times-Medium-R-Normal-*-180-*') msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m') if bitmap: bm = Label(top, bitmap=bitmap) bm.pack(side=LEFT, padx='3m', pady='3m') # 3. Create a row of buttons at the bottom of the dialog. var = IntVar() buttons = [] i = 0 for but in args: b = Button(bot, text=but, command=lambda v=var,i=i: v.set(i)) buttons.append(b) if i == default: bd = Frame(bot, relief=SUNKEN, borderwidth=1) bd.pack(side=LEFT, expand=1, padx='3m', pady='2m') b.lift() b.pack (in_=bd, side=LEFT, padx='2m', pady='2m', ipadx='2m', ipady='1m') else: b.pack (side=LEFT, expand=1, padx='3m', pady='3m', ipadx='2m', ipady='1m') i = i+1 # 4. Set up a binding for , if there's a default, # set a grab, and claim the focus too. if default >= 0: w.bind('', lambda e, b=buttons[default], v=var, i=default: (b.flash(), v.set(i))) oldFocus = w.focus_get() w.grab_set() w.focus_set() # 5. Wait for the user to respond, then restore the focus # and return the index of the selected button. w.waitvar(var) w.destroy() if oldFocus: oldFocus.focus_set() return var.get() # The rest is the test program. def go(): i = dialog(mainWidget, 'Not Responding', "The file server isn't responding right now; " "I'll keep trying.", '', -1, 'OK') print 'pressed button', i i = dialog(mainWidget, 'File Modified', 'File "tcl.h" has been modified since ' 'the last time it was saved. ' 'Do you want to save it before exiting the application?', 'warning', 0, 'Save File', 'Discard Changes', 'Return To Editor') print 'pressed button', i def test(): import sys global mainWidget mainWidget = Frame() Pack.config(mainWidget) start = Button(mainWidget, text='Press Here To Start', command=go) start.pack() endit = Button(mainWidget, text="Exit", command=sys.exit) endit.pack(fill=BOTH) mainWidget.mainloop() if __name__ == '__main__': test() PK!hguido/imagedraw.pyonu[ ^c@s9dZddlTddlZdZdZedS(sDraw on top of an imagei(t*NcCstjd}t}td|}|j|j}}t|d|d|}|jdddtd||j |j dt |j dS( Nitfiletwidththeightitanchortimages ( tsystargvtTkt PhotoImageRRtCanvast create_imagetNWtpacktbindtblobtmainloop(tfilenametroottimgtwthtcanv((s4/usr/lib64/python2.7/Demo/tkinter/guido/imagedraw.pytmains   c CsX|j|j}}|j}d}|j||||||||dddddS(Nitfilltredtoutlinet(txtytwidgett create_oval(teventRRRtr((s4/usr/lib64/python2.7/Demo/tkinter/guido/imagedraw.pyRs (t__doc__tTkinterRRR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/imagedraw.pyts    PK!)tMIMIguido/AttrDialog.pyonu[ ^c@sddlTdddYZdefdYZdefdYZdefd YZd efd YZd dd YZdefdYZdefdYZdefdYZ de fdYZ dZ dZ dZ e dS(i(t*tOptioncBs5eZeZdZdZdZddZRS(cCs||_||_|j|_|j|\|_|_|j|j|_t |j|_ |j j dt t |j d|d|_|jj dt|j|jdS(Ntfillttextt:tside(tdialogtoptionttoptmastertoptionstdefaulttklasstvarclasstvartFrametframetpacktXtLabeltlabeltLEFTtupdatet addoption(tselfRR((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyt__init__s    cCs|jj|jdS(N(RtrefreshR(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR"s cCsQy|jj|j|_Wntk r9|j|_nX|jj|jdS(N(RtcurrentRtKeyErrorR Rtset(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR&s  cCsdS(N((Rte((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR-sN( t__name__t __module__t StringVarR RRRtNoneR(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs   t BooleanOptioncBseZeZdZRS(cCsYt|jddddddd|jdtd d d |j|_|jjd tdS( NRson/offtonvalueitoffvalueitvariabletrelieft borderwidthitcommandR(t CheckbuttonRRtRAISEDRtbuttonRtRIGHT(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR4s  (RR t BooleanVarR R(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR#0st EnumOptioncBseZdZRS(c Cst|jd|jdtdd|_|jjdtt|j|_|j|jd( tEntryRRtSUNKENtentryRR-RtbindR(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRQs   (RR R(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR8OstReadonlyOptioncBseZdZRS(cCs8t|jd|jdt|_|jjdtdS(NR0tanchorR(RRRtERRR-(R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR\s (RR R(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyR?ZstDialogcBsPeZdZdZdZdZiZiZeZ e Z e Z eZRS(cCsf||_|j|jt|j|_|jj|jj|jjdd|j dS(Ni( R t fixclassesRtToplevelRttitlet __class__Rtminsizet addchoices(RR ((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRcs   cCsdS(N((R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRltcCsdS(N((R((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRCnRIcCsi|_g}x0|jjD]\}}|j||fqW|jx|D]\}\}}y|j|}Wntk rd}nXt|tkr|j }n9|dkr|j }n!|dkr|j }n |j }||||j|    "tRemotePackDialogcBseZdZdZdd dYZdeefdYZdeefdYZdee fd YZ d ee fd YZ RS( cCso||_||_||_|jt|j|_|jj|jd|jjdd|jdS(Ns PackDialogi( R tappR^RRDRRERGRH(RR RR^((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs    cCsy4|jjj|jj|jdd|j}Wntk rO}|GHdSXi}xFtdt|dD],}||d}||d}|||6dd?6dd@6ddA6ddB6d.dC6ddD6ddE6dFdG6dHdI6d.dJ6ddK6e!e"e#fdL6Z$ie%e&e'fdM6Z(ie%e'fdM6Z)ie(dN6e(dO6e(dP6e)dQ6e)dC6e(dR6e)dS6Z*RS(UcCs,||_|j|_tj||dS(N(R^R`R RBR(RR^((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs cCst|jj|jrpi}xF|j|j|jfD]+}x"|jD]}||||(RR>t opendialogsR(RRRRW((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRscCsddl}|j}|j}x|D]}|j|}|j|d}t||j||dkruq(nyt||j|Wq(tk r}|GHq(Xq(WdS(Niit.( RR^t curselectionRctsplitRRRRe(RRRWtselRRR^Rf((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyRs     N(((tTkinterRR#R/R8R?RBR]RRRRRR(((s5/usr/lib64/python2.7/Demo/tkinter/guido/AttrDialog.pyts  .67m2   PK!.Voo guido/wish.pynu[# This is about all it requires to write a wish shell in Python! import _tkinter import os tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1) tk.call('update') cmd = '' while 1: if cmd: prompt = '' else: prompt = '% ' try: line = raw_input(prompt) except EOFError: break cmd = cmd + (line + '\n') if tk.getboolean(tk.call('info', 'complete', cmd)): tk.record(line) try: result = tk.call('eval', cmd) except _tkinter.TclError, msg: print 'TclError:', msg else: if result: print result cmd = '' PK!E`}eR R guido/electrons.pyonu[ Afc@sLddlTddlZdddYZdZedkrHendS(i(t*Nt ElectronscBs&eZddZdZdZRS(c Cs||_t|_}t||_}|j|j|d|j|d}}|r|j|d|dd|dd|_ng|_ d \}}} } xWt |D]I} |j ||| | d d } |j j | |d| d}} qW|jj dS(Ntwidththeightitbitmapt foregroundtbluei iFiiJtfilltred(i iFiiJ(tntTkttktCanvastcanvastpacktgetintt create_bitmapRtpiecestranget create_ovaltappendtupdate( tselfR RR tcRRtx1ty1tx2ty2titp((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyt__init__s   ' cCsq|j}xT|jD]I}tjtdd}tjtdd}|j|||qW|jjdS(Niii(R RtrandomtchoiceRtmoveR R(RR RRtxty((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyt random_move+s  cCshy+x$tdD]}|j|jqWWn6tk rcy|jjWqdtk r_qdXnXdS(Ni(RR$R tTclErrorR tdestroy(RR((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pytrun4s  N(t__name__t __module__tNoneRR$R'(((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyRs  cCsddl}ddl}|jdr>|j|jd}nd}|jdr|jd}|ddkr{|d}qd|}nd}t||}|jdS(Niiiiit@(tsyststringtargvtatoiR*RR'(R,R-R Rth((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pytmain@s     t__main__((tTkinterRRR1R((((s4/usr/lib64/python2.7/Demo/tkinter/guido/electrons.pyts  -  PK!qfXXguido/newmenubardemo.pyonu[ Afc@sFdZddlTdddYZdZedkrBendS( s.Play with the new Tk 8.0 toplevel menu option.i(t*tAppcBseZdZRS(cCsu||_t|j|_t|j|_|jjdd|jjdd|jjdd|jj|jjddd|jjt|j|_|jjdd|jjdd|jjdd t|jd d |_|jjdd |jj dd d|j|jj ddd|j|jj ddd|jt d|j|_ dS(NtlabeltNewsOpen...tClosetQuittcommandtCuttCopytPastetnamethelpsAbout...tFiletmenutEdittHelp( tmastertMenutmenubartfilemenut add_commandt add_separatortquitteditmenuthelpmenut add_cascadetToplevelttop(tselfR((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pyt__init__ s$  (t__name__t __module__R(((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pyRscCs-t}|jt|}|jdS(N(tTktwithdrawRtmainloop(troottapp((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pytmain(s   t__main__N((t__doc__tTkinterRR%R(((s9/usr/lib64/python2.7/Demo/tkinter/guido/newmenubardemo.pyts  !  PK!V guido/rmt.pycnu[ Afc @sddlTddlZeZejZeededdZejde eeZ e jddde e e de Zejd edeee deddd ejd dZejd ede ddejd d dejedcCs<|j}|j}tjddtjt||dS(Nstk_priv(selectMode)tword(RRRRttk_textSelectToR(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytdouble1=s  s cCs<|j}|j}tjddtjt||dS(Nstk_priv(selectMode)tline(RRRRRR(RRR((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyttriple1Ds  s cCstjtdtdS(Ns (RtinserttAtInserttinvoke(R((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyt returnkeyKsscCsStjttjtjttjtddkrOtndS(Nis.0(RR!R"t selection_gettyview_pickplacetindexR#(R((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytcontrolvPss cCsHtjdtjdkrDtjdttjtndS(Nt promptEndsinsert - 1 char(RR'tdeleteR"R&(R((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyt backspaceZss s scCstjdt}tjtjdd|rttjkrZtjd|}ntj t|}|rtj t|dnt ntj tdS(NspromptEnd + 1 chartinfotcompletetevals ( RtgetR"t getbooleanttktcalltapptroott winfo_nametsendR!tpromptR&(tcmdtmsg((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyR#is cCs>tjttdtjddtjddddS(Ns: R)sinsert - 1 charRsinsert linestart(RR!R"R3Rttag_add(((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyR7uscCsA|atjddtjd|dtjddddS(NspromptEnd linestartR)t:R(R3RR*R!R:(tappName((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytnewApp~scCstjdtjddtj}t|}|jxR|D]J}ytj|dWntk rsqFXtj d|d|dqFWdS(NR itlasts winfo name .RcSs t|S(N(R=(tname((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pytt( t file_m_appstaddR*R4t winfo_interpstlisttsortR6tTclErrort add_command(tnamesR?((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyt fillAppsMenus       t postcommand(1tTkintertsystTkR4R1tFrametRAISEDtmBartpacktXtftBOTHt ScrollbartFLATtstRIGHTtYtTexttsetRtLEFTt tag_configtyviewttitleticonnamet MenubuttontfiletMenutfile_mRBt add_cascadeRHtexitRtbindRR R$R(R+R#R7R=RJt tk_menuBarR5R3tfocustmainloop(((s./usr/lib64/python2.7/Demo/tkinter/guido/rmt.pyts^     '                 PK!KѴQQguido/solitaire.pyonu[ Afc@sCdZddlZddlZddlTddlmZmZmZmZdefdYZdZ dZ d Z e d e Z e d e Z d Zd ZdZdZdZdZdZdZiZxeefD]Zeees s sN( R&R'tgametcardsRRR(R t clickhandlertdoubleclickhandlert motionhandlertreleasehandlert makebottom(RR&R'R>((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR2s    cCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDscCsd|jj|j|jfS(s+Return a string for debug print statements.s %s(%d, %d)(t __class__R R&R'(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR3scCs>|jj||j|j||jj|jdS(N(R?tappendR9tpositionR(R-(Rtcard((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytadd%s  cCs'|jj||jj|jdS(N(R?tremoveR(tdtag(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytdelete+scCs!|jr|jdjndS(Ni(R?R:(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshowtop/s cCs+|js dS|jd}|j||S(Ni(R?RRL(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytdeal3s    cCs|j|j|jdS(N(R5R&R'(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRG<scCs|jdS(N(RM(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytuserclickhandler?scCs|jdS(N(RO(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytuserdoubleclickhandlerBscCs"x|D]}|j|qWdS(N(RG(RR?RH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytusermovehandlerEs cCs%|j|j|j|dS(N(t finishmovingROt startmoving(Rtevent((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR@Ks  cCs|j|dS(N(t keepmoving(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRBPscCs|j||jdS(N(RURR(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRCSs cCs%|j|j|j|dS(N(RRRPRS(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRAWs  cCsd|_|jjjd}xDtt|jD])}|j|}|jj |kr4Pq4q4WdS|j srdS|j||_|j |_ |j |_x|jD]}|jqWdS(Ntcurrent(RtmovingR>RtgettagstrangetlenR?R(ttagR%R&tlastxR'tlastyR9(RRTttagstiRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRS`s     cCs||js dS|j|j}|j|j}|j|_|j|_|sQ|rxx$|jD]}|j||q[WndS(N(RWR&R\R'R]R4(RRTR7R8RH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRUqs    cCs,|j}d|_|r(|j|ndS(N(RWRRQ(RR?((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRR|s  N(R R R<RR2RDR3RIRLRMRNRGRORPRQR@RBRCRARWRSRURR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR=s(-                tDeckcBs2eZdZdZdZdZdZRS(s7The deck is a stack with support for shuffling. New methods: fill() -- create the playing cards shuffle() -- shuffle the playing cards A single click moves the top card to the game's open deck and moves it face up; if we're out of cards, it moves the open deck back to the deck. c CsRt|jj|j|j|jt|jtdddt}|jj |dS(NRRR( RR>RR&R'R*R.t BACKGROUNDR(R-(Rtbottom((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDs   cCsEx>tD]6}x-tD]%}|jt|||jjqWqWdS(N(tALLSUITSt ALLVALUESRIRR>R(RR!R"((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRs  cCsMt|j}g}x(t|D]}|j|j|q"W||_dS(N(RZR?trandpermRF(RtntnewcardsR_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshuffles cCsv|jj}|j}|sUxQ|j}|s7Pn|j||jq!Wn|jjj||jdS(N(R>topendeckRNRIR;R:(RRiRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyROs    (R R R<RDRRhRO(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR`s     cCsLt|}g}x3|rGtj|}|j||j|qW|S(s4Function returning a random permutation of range(n).(RYtrandomtchoiceRFRJ(RftrR&R_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRes   t OpenStackcBs#eZdZdZdZRS(cCsdS(Ni((RR?((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyt acceptablescCs|d}|jj|}| s?||ks?|j| rRtj||n8x(|D] }|j||j|qYW|jjdS(Ni(R>t closeststackRnR=RQRLRItwincheck(RR?RHtstack((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRQs #  cCs|js dS|jd}|js1|jdSxQ|jjD]C}|j|gr>|j||j||jjPq>q>WdS(Ni( R?R%ROR>tsuitsRnRLRIRp(RRHts((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRPs       (R R RnRQRP(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRms  t SuitStackcBs,eZdZdZdZdZRS(c CsBt|jj|j|j|jt|jtdddd}dS(NRRRR(RR>RR&R'R*R.(RRb((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDs  cCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyROscCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRPscCsit|dkrdS|d}|js6|jtkS|jd}|j|jkoh|j|jdkS(Niii(RZR?R"tACER!(RR?RHttopcard((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRns    (R R RDRORPRn(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRts   tRowStackcBseZdZdZRS(cCs`|d}|js |jtkS|jd}|js:dS|j|jko_|j|jdkS(Niii(R?R"tKINGR%R$(RR?RHRv((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRns     cCsh|j}xE|jD]:}||kr)Pn|jrC|dt}q|t}qW|j|j|dS(Ni(R'R?R%R0tOFFSETR5R&(RRHR'tc((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRGs   (R R RnRG(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRws t SolitairecBsGeZdZdZdZdZdZdZdZRS(c Cs||_t|jdtdddttddtdt|_|jjdt d t t |jd d dddtd d d|j |_ t|jtdtdd|j dtt}t}t||||_|t}t||||_|t}g|_x:ttD],}|t}|jjt|||qWt}|t}g|_x:ttD],}|jjt||||t}qoW|jg|j|j|_|jj|j dS(Nt backgroundthighlightthicknessitwidththeightiiRtexpandRtDealtactivebackgroundtgreenR twindowR(tmastertCanvasRatNROWStXSPACINGtYSPACINGR0RtpacktBOTHtTRUEtButtonRNt dealbuttonRtSWR`tdeckRmRiRrRYtNSUITSRFRttrowsRwt openstacksR(RRR&R'R_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR2sD            cCsEx*|jD]}t|jtkr dSq W|j|jdS(N(RrRZR?tNVALUEStwinRN(RRs((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRp=s  cCsgg}x|jD]}||j}qWx9|rbtj|}|j||j||jq*WdS(sStupid animation when you win.N(RR?RjRkRJtanimatedmovetoR(RR?RsRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDs  cCsgx`tdddD]L}|j|j||j|j|}}|j|||jjqWdS(Ni ii(RYR&R'R4Rtupdate_idletasks(RRHtdestR_R7R8((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRNs)cCsed}d}xR|jD]G}|j|jd|j|jd}||kr|}|}qqW|S(Niɚ;i(RRR&R'(RRHtclosesttcdistRqtdist((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRoTs&  cCs|j|jjxHttD]:}x1|j|D]"}|jj}|j|q8Wq$Wx|jD]}|jqlWdS(N( tresetRRhRYRRRNRIRM(RR_RlRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRN`s  cCsOxH|jD]=}x4|j}|s)Pn|jj||jqWq WdS(N(RRNRRIR;(RRqRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRjs ( R R R2RpRRRoRNR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR{ s .   cCs6t}t|}|jd|j|jdS(NtWM_DELETE_WINDOW(tTkR{tprotocoltquittmainloop(trootR>((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytmainvs  t__main__((((1R<tmathRjtTkinterRRRRRR*R.R0RRRyRatHEARTStDIAMONDStCLUBStSPADEStREDtBLACKR#RstkeysRcRZRRutJACKtQUEENRxRYRdRtmaptstrR)RRR=R`ReRmRtRwR{RR (((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytsX   "     /f1 i  PK!aAguido/newmenubardemo.pynuȯ#! /usr/bin/python2.7 """Play with the new Tk 8.0 toplevel menu option.""" from Tkinter import * class App: def __init__(self, master): self.master = master self.menubar = Menu(self.master) self.filemenu = Menu(self.menubar) self.filemenu.add_command(label="New") self.filemenu.add_command(label="Open...") self.filemenu.add_command(label="Close") self.filemenu.add_separator() self.filemenu.add_command(label="Quit", command=self.master.quit) self.editmenu = Menu(self.menubar) self.editmenu.add_command(label="Cut") self.editmenu.add_command(label="Copy") self.editmenu.add_command(label="Paste") self.helpmenu = Menu(self.menubar, name='help') self.helpmenu.add_command(label="About...") self.menubar.add_cascade(label="File", menu=self.filemenu) self.menubar.add_cascade(label="Edit", menu=self.editmenu) self.menubar.add_cascade(label="Help", menu=self.helpmenu) self.top = Toplevel(menu=self.menubar) # Rest of app goes here... def main(): root = Tk() root.withdraw() app = App(root) root.mainloop() if __name__ == '__main__': main() PK!I guido/rmt.pynuȯ#! /usr/bin/python2.7 # A Python program implementing rmt, an application for remotely # controlling other Tk applications. # Cf. Ousterhout, Tcl and the Tk Toolkit, Figs. 27.5-8, pp. 273-276. # Note that because of forward references in the original, we # sometimes delay bindings until after the corresponding procedure is # defined. We also introduce names for some unnamed code blocks in # the original because of restrictions on lambda forms in Python. # XXX This should be written in a more Python-like style!!! from Tkinter import * import sys # 1. Create basic application structure: menu bar on top of # text widget, scrollbar on right. root = Tk() tk = root.tk mBar = Frame(root, relief=RAISED, borderwidth=2) mBar.pack(fill=X) f = Frame(root) f.pack(expand=1, fill=BOTH) s = Scrollbar(f, relief=FLAT) s.pack(side=RIGHT, fill=Y) t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1) t.pack(side=LEFT, fill=BOTH, expand=1) t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*') s['command'] = t.yview root.title('Tk Remote Controller') root.iconname('Tk Remote') # 2. Create menu button and menus. file = Menubutton(mBar, text='File', underline=0) file.pack(side=LEFT) file_m = Menu(file) file['menu'] = file_m file_m_apps = Menu(file_m, tearoff=0) file_m.add_cascade(label='Select Application', underline=0, menu=file_m_apps) file_m.add_command(label='Quit', underline=0, command=sys.exit) # 3. Create bindings for text widget to allow commands to be # entered and information to be selected. New characters # can only be added at the end of the text (can't ever move # insertion point). def single1(e): x = e.x y = e.y t.setvar('tk_priv(selectMode)', 'char') t.mark_set('anchor', At(x, y)) # Should focus W t.bind('<1>', single1) def double1(e): x = e.x y = e.y t.setvar('tk_priv(selectMode)', 'word') t.tk_textSelectTo(At(x, y)) t.bind('', double1) def triple1(e): x = e.x y = e.y t.setvar('tk_priv(selectMode)', 'line') t.tk_textSelectTo(At(x, y)) t.bind('', triple1) def returnkey(e): t.insert(AtInsert(), '\n') invoke() t.bind('', returnkey) def controlv(e): t.insert(AtInsert(), t.selection_get()) t.yview_pickplace(AtInsert()) if t.index(AtInsert())[-2:] == '.0': invoke() t.bind('', controlv) # 4. Procedure to backspace over one character, as long as # the character isn't part of the prompt. def backspace(e): if t.index('promptEnd') != t.index('insert - 1 char'): t.delete('insert - 1 char', AtInsert()) t.yview_pickplace(AtInsert()) t.bind('', backspace) t.bind('', backspace) t.bind('', backspace) # 5. Procedure that's invoked when return is typed: if # there's not yet a complete command (e.g. braces are open) # then do nothing. Otherwise, execute command (locally or # remotely), output the result or error message, and issue # a new prompt. def invoke(): cmd = t.get('promptEnd + 1 char', AtInsert()) if t.getboolean(tk.call('info', 'complete', cmd)): # XXX if app == root.winfo_name(): msg = tk.call('eval', cmd) # XXX else: msg = t.send(app, cmd) if msg: t.insert(AtInsert(), msg + '\n') prompt() t.yview_pickplace(AtInsert()) def prompt(): t.insert(AtInsert(), app + ': ') t.mark_set('promptEnd', 'insert - 1 char') t.tag_add('bold', 'insert linestart', 'promptEnd') # 6. Procedure to select a new application. Also changes # the prompt on the current command line to reflect the new # name. def newApp(appName): global app app = appName t.delete('promptEnd linestart', 'promptEnd') t.insert('promptEnd', appName + ':') t.tag_add('bold', 'promptEnd linestart', 'promptEnd') def fillAppsMenu(): file_m_apps.add('command') file_m_apps.delete(0, 'last') names = root.winfo_interps() names = list(names) names.sort() for name in names: try: root.send(name, 'winfo name .') except TclError: # Inoperative window -- ignore it pass else: file_m_apps.add_command( label=name, command=lambda name=name: newApp(name)) file_m_apps['postcommand'] = fillAppsMenu mBar.tk_menuBar(file) # 7. Miscellaneous initialization. app = root.winfo_name() prompt() t.focus() root.mainloop() PK!27O::guido/imageview.pyonu[ ^c@s*ddlTddlZdZedS(i(t*NcCsOtjd}t}td|}t|d|}|j|jdS(Nitfiletimage(tsystargvtTkt PhotoImagetLabeltpacktmainloop(tfilenametroottimgtlabel((s4/usr/lib64/python2.7/Demo/tkinter/guido/imageview.pytmains    (tTkinterRR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/imageview.pyts   PK!"@@guido/kill.pyonu[ Afc@sddlTddlmZddlmZddlZddlZdefdYZdefdYZ e d kre dd d Z e j jd e j jd d e jndS(i(t*(t splitfields(tsplitNt BarButtoncBseZddZRS(cKsOttj||f||jdtt|dd|_|j|dss<1>(,tFrameR R tBOTHtRAISEDRCtXRtfileRt add_commandtquittviewtIntVarRR*trangetlenRtadd_radiobuttonR"t tk_menuBarR+t StringVarR)tLabeltFLATtNWRHt ScrollbartVERTICALR,tListboxtSUNKENR-R1tRIGHTtYtButtontupdatetbindR>R?R@(R RRtnum((s//usr/lib64/python2.7/Demo/tkinter/guido/kill.pyR 2sP    (RRi(Rs-li(Rs-ui(Rs-ji(Rs-si(Rs-mi(Rs-vi(Rs-XiN( RRRR&R"R>R?R@RR (((s//usr/lib64/python2.7/Demo/tkinter/guido/kill.pyRs     t__main__REisTkinter Process Killeri(tTkintertstringRRR'R RRRURRRR&twinfo_toplevelttitletminsizetmainloop(((s//usr/lib64/python2.7/Demo/tkinter/guido/kill.pyts   M PK!.,#,#guido/tkman.pynuȯ#! /usr/bin/python2.7 # Tk man page browser -- currently only shows the Tcl/Tk man pages import sys import os import string import re from Tkinter import * from ManPage import ManPage MANNDIRLIST = ['/depot/sundry/man/mann','/usr/local/man/mann'] MAN3DIRLIST = ['/depot/sundry/man/man3','/usr/local/man/man3'] foundmanndir = 0 for dir in MANNDIRLIST: if os.path.exists(dir): MANNDIR = dir foundmanndir = 1 foundman3dir = 0 for dir in MAN3DIRLIST: if os.path.exists(dir): MAN3DIR = dir foundman3dir = 1 if not foundmanndir or not foundman3dir: sys.stderr.write('\n') if not foundmanndir: msg = """\ Failed to find mann directory. Please add the correct entry to the MANNDIRLIST at the top of %s script.""" % \ sys.argv[0] sys.stderr.write("%s\n\n" % msg) if not foundman3dir: msg = """\ Failed to find man3 directory. Please add the correct entry to the MAN3DIRLIST at the top of %s script.""" % \ sys.argv[0] sys.stderr.write("%s\n\n" % msg) sys.exit(1) del foundmanndir del foundman3dir def listmanpages(mandir): files = os.listdir(mandir) names = [] for file in files: if file[-2:-1] == '.' and (file[-1] in 'ln123456789'): names.append(file[:-2]) names.sort() return names class SelectionBox: def __init__(self, master=None): self.choices = [] self.frame = Frame(master, name="frame") self.frame.pack(expand=1, fill=BOTH) self.master = self.frame.master self.subframe = Frame(self.frame, name="subframe") self.subframe.pack(expand=0, fill=BOTH) self.leftsubframe = Frame(self.subframe, name='leftsubframe') self.leftsubframe.pack(side=LEFT, expand=1, fill=BOTH) self.rightsubframe = Frame(self.subframe, name='rightsubframe') self.rightsubframe.pack(side=RIGHT, expand=1, fill=BOTH) self.chaptervar = StringVar(master) self.chapter = Menubutton(self.rightsubframe, name='chapter', text='Directory', relief=RAISED, borderwidth=2) self.chapter.pack(side=TOP) self.chaptermenu = Menu(self.chapter, name='chaptermenu') self.chaptermenu.add_radiobutton(label='C functions', value=MAN3DIR, variable=self.chaptervar, command=self.newchapter) self.chaptermenu.add_radiobutton(label='Tcl/Tk functions', value=MANNDIR, variable=self.chaptervar, command=self.newchapter) self.chapter['menu'] = self.chaptermenu self.listbox = Listbox(self.rightsubframe, name='listbox', relief=SUNKEN, borderwidth=2, width=20, height=5) self.listbox.pack(expand=1, fill=BOTH) self.l1 = Button(self.leftsubframe, name='l1', text='Display manual page named:', command=self.entry_cb) self.l1.pack(side=TOP) self.entry = Entry(self.leftsubframe, name='entry', relief=SUNKEN, borderwidth=2, width=20) self.entry.pack(expand=0, fill=X) self.l2frame = Frame(self.leftsubframe, name='l2frame') self.l2frame.pack(expand=0, fill=NONE) self.l2 = Button(self.l2frame, name='l2', text='Search regexp:', command=self.search_cb) self.l2.pack(side=LEFT) self.casevar = BooleanVar() self.casesense = Checkbutton(self.l2frame, name='casesense', text='Case sensitive', variable=self.casevar, relief=FLAT) self.casesense.pack(side=LEFT) self.search = Entry(self.leftsubframe, name='search', relief=SUNKEN, borderwidth=2, width=20) self.search.pack(expand=0, fill=X) self.title = Label(self.leftsubframe, name='title', text='(none)') self.title.pack(side=BOTTOM) self.text = ManPage(self.frame, name='text', relief=SUNKEN, borderwidth=2, wrap=NONE, width=72, selectbackground='pink') self.text.pack(expand=1, fill=BOTH) self.entry.bind('', self.entry_cb) self.search.bind('', self.search_cb) self.listbox.bind('', self.listbox_cb) self.entry.bind('', self.entry_tab) self.search.bind('', self.search_tab) self.text.bind('', self.text_tab) self.entry.focus_set() self.chaptervar.set(MANNDIR) self.newchapter() def newchapter(self): mandir = self.chaptervar.get() self.choices = [] self.addlist(listmanpages(mandir)) def addchoice(self, choice): if choice not in self.choices: self.choices.append(choice) self.choices.sort() self.update() def addlist(self, list): self.choices[len(self.choices):] = list self.choices.sort() self.update() def entry_cb(self, *e): self.update() def listbox_cb(self, e): selection = self.listbox.curselection() if selection and len(selection) == 1: name = self.listbox.get(selection[0]) self.show_page(name) def search_cb(self, *e): self.search_string(self.search.get()) def entry_tab(self, e): self.search.focus_set() def search_tab(self, e): self.entry.focus_set() def text_tab(self, e): self.entry.focus_set() def updatelist(self): key = self.entry.get() ok = filter(lambda name, key=key, n=len(key): name[:n]==key, self.choices) if not ok: self.frame.bell() self.listbox.delete(0, AtEnd()) exactmatch = 0 for item in ok: if item == key: exactmatch = 1 self.listbox.insert(AtEnd(), item) if exactmatch: return key n = self.listbox.size() if n == 1: return self.listbox.get(0) # Else return None, meaning not a unique selection def update(self): name = self.updatelist() if name: self.show_page(name) self.entry.delete(0, AtEnd()) self.updatelist() def show_page(self, name): file = '%s/%s.?' % (self.chaptervar.get(), name) fp = os.popen('nroff -man %s | ul -i' % file, 'r') self.text.kill() self.title['text'] = name self.text.parsefile(fp) def search_string(self, search): if not search: self.frame.bell() print 'Empty search string' return if not self.casevar.get(): map = re.IGNORECASE else: map = None try: if map: prog = re.compile(search, map) else: prog = re.compile(search) except re.error, msg: self.frame.bell() print 'Regex error:', msg return here = self.text.index(AtInsert()) lineno = string.atoi(here[:string.find(here, '.')]) end = self.text.index(AtEnd()) endlineno = string.atoi(end[:string.find(end, '.')]) wraplineno = lineno found = 0 while 1: lineno = lineno + 1 if lineno > endlineno: if wraplineno <= 0: break endlineno = wraplineno lineno = 0 wraplineno = 0 line = self.text.get('%d.0 linestart' % lineno, '%d.0 lineend' % lineno) i = prog.search(line) if i >= 0: found = 1 n = max(1, len(prog.group(0))) try: self.text.tag_remove('sel', AtSelFirst(), AtSelLast()) except TclError: pass self.text.tag_add('sel', '%d.%d' % (lineno, i), '%d.%d' % (lineno, i+n)) self.text.mark_set(AtInsert(), '%d.%d' % (lineno, i)) self.text.yview_pickplace(AtInsert()) break if not found: self.frame.bell() def main(): root = Tk() sb = SelectionBox(root) if sys.argv[1:]: sb.show_page(sys.argv[1]) root.minsize(1, 1) root.mainloop() main() PK!~H+guido/ShellWindow.pycnu[ ^c@sddlZddlZddlZddlTddlmZddlmZddlZdZdefdYZdZ d Z d Z e d kre ndS( iN(t*(t ScrolledText(tDialogit ShellWindowcBsheZd d dZdZdZdZdZdZdZ dZ dZ d Z RS( cKs|s>ytjd}Wntk r0d}nX|d}ntj|}|d}ttj||f|d|_|j d|j |j d|j |j d|j |j d |j |j d |jt||\|_|_|_|jj|jt|jdS( NtSHELLs/bin/shs -iis1.0ss s s s (tostenvirontKeyErrortstringtsplittapplyRt__init__tpostbindt inputhandlertsiginttsigtermtsigkilltsendeoftspawntpidt fromchildttochildttktcreatefilehandlertREADABLEt outputhandler(tselftmastertshelltcnftargs((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR s$     !c Cstj|t}|s|jj|tj|jd\}}dG|GdG|GHd|_|d?}|d@}|dkrd|}n%d|d@}|d @r|d }nt|j d |d d dddddddS|j t ||j d|_ |jt dS(NiRtstatusiisexit status %dskilled by signal %diis -- core dumpedttextttitles Exit statustbitmaptwarningtdefaulttstringstOKs end - 1 char(R'(RtreadtBUFSIZERtdeletefilehandlertwaitpidRtNoneRRtinserttENDtindexR tyview_pickplace( RtfiletmasktdataRtststdetailtcausetmsg((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR#s.        cGse|js|jdS|jtd|j|jd}|jt|_tj|j |dS(Ntbreaks s end - 1 char( Rt no_processR-R.tgetR R/RtwriteR(RRtline((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR=s  cGs+|js|jdStj|jdS(NR8(RR9RtcloseR(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyRGs   cCs.|js|jdStj|j|dS(NR8(RR9Rtkill(Rtsig((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pytsendsigNs   cGs|jtjS(N(R@tsignaltSIGINT(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyRUscGs|jtjS(N(R@RAtSIGQUIT(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pytsigquitXscGs|jtjS(N(R@RAtSIGTERM(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR[scGs|jtjS(N(R@RAtSIGKILL(RR((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR^sc Cs/t|jddddddddd d dS( NR!sNo active processR"s No processR#terrorR%iR&R'(R'(RR(R((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR9as  N( t__name__t __module__R,R RRRR@RRDRRR9(((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyR s       idcCs\tj\}}tj\}}tj}|dkr5x6dD].}ytj|WqCtjk rpqCXqCWtj|dkrtjjdntj|dkrtjjdntj|dkrtjjdntj dt ztj ||Wdtjjdtj dXntj|tj||||fS( Niiispopen2: bad read dup spopen2: bad write dup isexecvp failed (iii( RtpipetforkR=RGtduptsyststderrR;t closerangetMAXFDtexecvpt_exit(tprogRtp2creadtp2cwritetc2preadtc2pwriteRti((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyRks.     cCstjtjd}t}|jdd|rJt|d|}n t|}|jdddt|j |j j dS(NiRtexpandtfill( RtjoinRMtargvtTktminsizeRtpacktBOTHt focus_setRtmainloop(Rtroottw((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyttests   t__main__( RRMRtTkinterRRRAR)RRPRReRH(((s6/usr/lib64/python2.7/Demo/tkinter/guido/ShellWindow.pyts     ^  PK!$͕͕ __init__.pynu["""Wrapper functions for Tcl/Tk. Tkinter provides classes which allow the display, positioning and control of widgets. Toplevel widgets are Tk and Toplevel. Other widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox LabelFrame and PanedWindow. Properties of the widgets are specified with keyword arguments. Keyword arguments have the same name as the corresponding resource under Tk. Widgets are positioned with one of the geometry managers Place, Pack or Grid. These managers can be called with methods place, pack, grid available in every Widget. Actions are bound to events by resources (e.g. keyword argument command) or with the method bind. Example (Hello, World): import tkinter from tkinter.constants import * tk = tkinter.Tk() frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = tkinter.Label(frame, text="Hello, World") label.pack(fill=X, expand=1) button = tkinter.Button(frame,text="Exit",command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop() """ import enum import sys import _tkinter # If this fails your Python may not be configured for Tk TclError = _tkinter.TclError from tkinter.constants import * import re wantobjects = 1 TkVersion = float(_tkinter.TK_VERSION) TclVersion = float(_tkinter.TCL_VERSION) READABLE = _tkinter.READABLE WRITABLE = _tkinter.WRITABLE EXCEPTION = _tkinter.EXCEPTION _magic_re = re.compile(r'([\\{}])') _space_re = re.compile(r'([\s])', re.ASCII) def _join(value): """Internal function.""" return ' '.join(map(_stringify, value)) def _stringify(value): """Internal function.""" if isinstance(value, (list, tuple)): if len(value) == 1: value = _stringify(value[0]) if _magic_re.search(value): value = '{%s}' % value else: value = '{%s}' % _join(value) else: value = str(value) if not value: value = '{}' elif _magic_re.search(value): # add '\' before special characters and spaces value = _magic_re.sub(r'\\\1', value) value = value.replace('\n', r'\n') value = _space_re.sub(r'\\\1', value) if value[0] == '"': value = '\\' + value elif value[0] == '"' or _space_re.search(value): value = '{%s}' % value return value def _flatten(seq): """Internal function.""" res = () for item in seq: if isinstance(item, (tuple, list)): res = res + _flatten(item) elif item is not None: res = res + (item,) return res try: _flatten = _tkinter._flatten except AttributeError: pass def _cnfmerge(cnfs): """Internal function.""" if isinstance(cnfs, dict): return cnfs elif isinstance(cnfs, (type(None), str)): return cnfs else: cnf = {} for c in _flatten(cnfs): try: cnf.update(c) except (AttributeError, TypeError) as msg: print("_cnfmerge: fallback due to:", msg) for k, v in c.items(): cnf[k] = v return cnf try: _cnfmerge = _tkinter._cnfmerge except AttributeError: pass def _splitdict(tk, v, cut_minus=True, conv=None): """Return a properly formatted dict built from Tcl list pairs. If cut_minus is True, the supposed '-' prefix will be removed from keys. If conv is specified, it is used to convert values. Tcl list is expected to contain an even number of elements. """ t = tk.splitlist(v) if len(t) % 2: raise RuntimeError('Tcl list representing a dict is expected ' 'to contain an even number of elements') it = iter(t) dict = {} for key, value in zip(it, it): key = str(key) if cut_minus and key[0] == '-': key = key[1:] if conv: value = conv(value) dict[key] = value return dict class EventType(str, enum.Enum): KeyPress = '2' Key = KeyPress KeyRelease = '3' ButtonPress = '4' Button = ButtonPress ButtonRelease = '5' Motion = '6' Enter = '7' Leave = '8' FocusIn = '9' FocusOut = '10' Keymap = '11' # undocumented Expose = '12' GraphicsExpose = '13' # undocumented NoExpose = '14' # undocumented Visibility = '15' Create = '16' Destroy = '17' Unmap = '18' Map = '19' MapRequest = '20' Reparent = '21' Configure = '22' ConfigureRequest = '23' Gravity = '24' ResizeRequest = '25' Circulate = '26' CirculateRequest = '27' Property = '28' SelectionClear = '29' # undocumented SelectionRequest = '30' # undocumented Selection = '31' # undocumented Colormap = '32' ClientMessage = '33' # undocumented Mapping = '34' # undocumented VirtualEvent = '35' # undocumented Activate = '36' Deactivate = '37' MouseWheel = '38' __str__ = str.__str__ class Event: """Container for the properties of an event. Instances of this type are generated if one of the following events occurs: KeyPress, KeyRelease - for keyboard events ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for mouse events Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate, Colormap, Gravity, Reparent, Property, Destroy, Activate, Deactivate - for window events. If a callback function for one of these events is registered using bind, bind_all, bind_class, or tag_bind, the callback is called with an Event as first argument. It will have the following attributes (in braces are the event types for which the attribute is valid): serial - serial number of event num - mouse button pressed (ButtonPress, ButtonRelease) focus - whether the window has the focus (Enter, Leave) height - height of the exposed window (Configure, Expose) width - width of the exposed window (Configure, Expose) keycode - keycode of the pressed key (KeyPress, KeyRelease) state - state of the event as a number (ButtonPress, ButtonRelease, Enter, KeyPress, KeyRelease, Leave, Motion) state - state as a string (Visibility) time - when the event occurred x - x-position of the mouse y - y-position of the mouse x_root - x-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) y_root - y-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) char - pressed character (KeyPress, KeyRelease) send_event - see X/Windows documentation keysym - keysym of the event as a string (KeyPress, KeyRelease) keysym_num - keysym of the event as a number (KeyPress, KeyRelease) type - type of the event as a number widget - widget in which the event occurred delta - delta of wheel movement (MouseWheel) """ def __repr__(self): attrs = {k: v for k, v in self.__dict__.items() if v != '??'} if not self.char: del attrs['char'] elif self.char != '??': attrs['char'] = repr(self.char) if not getattr(self, 'send_event', True): del attrs['send_event'] if self.state == 0: del attrs['state'] elif isinstance(self.state, int): state = self.state mods = ('Shift', 'Lock', 'Control', 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Button1', 'Button2', 'Button3', 'Button4', 'Button5') s = [] for i, n in enumerate(mods): if state & (1 << i): s.append(n) state = state & ~((1<< len(mods)) - 1) if state or not s: s.append(hex(state)) attrs['state'] = '|'.join(s) if self.delta == 0: del attrs['delta'] # widget usually is known # serial and time are not very interesting # keysym_num duplicates keysym # x_root and y_root mostly duplicate x and y keys = ('send_event', 'state', 'keysym', 'keycode', 'char', 'num', 'delta', 'focus', 'x', 'y', 'width', 'height') return '<%s event%s>' % ( getattr(self.type, 'name', self.type), ''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs) ) _support_default_root = True _default_root = None def NoDefaultRoot(): """Inhibit setting of default root window. Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window. """ global _support_default_root, _default_root _support_default_root = False # Delete, so any use of _default_root will immediately raise an exception. # Rebind before deletion, so repeated calls will not fail. _default_root = None del _default_root def _get_default_root(what=None): if not _support_default_root: raise RuntimeError("No master specified and tkinter is " "configured to not support default root") if not _default_root: if what: raise RuntimeError(f"Too early to {what}: no default root window") root = Tk() assert _default_root is root return _default_root def _tkerror(err): """Internal function.""" pass def _exit(code=0): """Internal function. Calling it will raise the exception SystemExit.""" try: code = int(code) except ValueError: pass raise SystemExit(code) _varnum = 0 class Variable: """Class to define value holders for e.g. buttons. Subclasses StringVar, IntVar, DoubleVar, BooleanVar are specializations that constrain the type of the value returned from get().""" _default = "" _tk = None _tclCommands = None def __init__(self, master=None, value=None, name=None): """Construct a variable MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. """ # check for type of NAME parameter to override weird error message # raised from Modules/_tkinter.c:SetVar like: # TypeError: setvar() takes exactly 3 arguments (2 given) if name is not None and not isinstance(name, str): raise TypeError("name must be a string") global _varnum if not master: master = _get_default_root('create variable') self._root = master._root() self._tk = master.tk if name: self._name = name else: self._name = 'PY_VAR' + repr(_varnum) _varnum += 1 if value is not None: self.initialize(value) elif not self._tk.getboolean(self._tk.call("info", "exists", self._name)): self.initialize(self._default) def __del__(self): """Unset the variable in Tcl.""" if self._tk is None: return if self._tk.getboolean(self._tk.call("info", "exists", self._name)): self._tk.globalunsetvar(self._name) if self._tclCommands is not None: for name in self._tclCommands: #print '- Tkinter: deleted command', name self._tk.deletecommand(name) self._tclCommands = None def __str__(self): """Return the name of the variable in Tcl.""" return self._name def set(self, value): """Set the variable to VALUE.""" return self._tk.globalsetvar(self._name, value) initialize = set def get(self): """Return value of variable.""" return self._tk.globalgetvar(self._name) def _register(self, callback): f = CallWrapper(callback, None, self._root).__call__ cbname = repr(id(f)) try: callback = callback.__func__ except AttributeError: pass try: cbname = cbname + callback.__name__ except AttributeError: pass self._tk.createcommand(cbname, f) if self._tclCommands is None: self._tclCommands = [] self._tclCommands.append(cbname) return cbname def trace_add(self, mode, callback): """Define a trace callback for the variable. Mode is one of "read", "write", "unset", or a list or tuple of such strings. Callback must be a function which is called when the variable is read, written or unset. Return the name of the callback. """ cbname = self._register(callback) self._tk.call('trace', 'add', 'variable', self._name, mode, (cbname,)) return cbname def trace_remove(self, mode, cbname): """Delete the trace callback for a variable. Mode is one of "read", "write", "unset" or a list or tuple of such strings. Must be same as were specified in trace_add(). cbname is the name of the callback returned from trace_add(). """ self._tk.call('trace', 'remove', 'variable', self._name, mode, cbname) for m, ca in self.trace_info(): if self._tk.splitlist(ca)[0] == cbname: break else: self._tk.deletecommand(cbname) try: self._tclCommands.remove(cbname) except ValueError: pass def trace_info(self): """Return all trace callback information.""" splitlist = self._tk.splitlist return [(splitlist(k), v) for k, v in map(splitlist, splitlist(self._tk.call('trace', 'info', 'variable', self._name)))] def trace_variable(self, mode, callback): """Define a trace callback for the variable. MODE is one of "r", "w", "u" for read, write, undefine. CALLBACK must be a function which is called when the variable is read, written or undefined. Return the name of the callback. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_add() instead. """ # TODO: Add deprecation warning cbname = self._register(callback) self._tk.call("trace", "variable", self._name, mode, cbname) return cbname trace = trace_variable def trace_vdelete(self, mode, cbname): """Delete the trace callback for a variable. MODE is one of "r", "w", "u" for read, write, undefine. CBNAME is the name of the callback returned from trace_variable or trace. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_remove() instead. """ # TODO: Add deprecation warning self._tk.call("trace", "vdelete", self._name, mode, cbname) cbname = self._tk.splitlist(cbname)[0] for m, ca in self.trace_info(): if self._tk.splitlist(ca)[0] == cbname: break else: self._tk.deletecommand(cbname) try: self._tclCommands.remove(cbname) except ValueError: pass def trace_vinfo(self): """Return all trace callback information. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_info() instead. """ # TODO: Add deprecation warning return [self._tk.splitlist(x) for x in self._tk.splitlist( self._tk.call("trace", "vinfo", self._name))] def __eq__(self, other): if not isinstance(other, Variable): return NotImplemented return (self._name == other._name and self.__class__.__name__ == other.__class__.__name__ and self._tk == other._tk) class StringVar(Variable): """Value holder for strings variables.""" _default = "" def __init__(self, master=None, value=None, name=None): """Construct a string variable. MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. """ Variable.__init__(self, master, value, name) def get(self): """Return value of variable as string.""" value = self._tk.globalgetvar(self._name) if isinstance(value, str): return value return str(value) class IntVar(Variable): """Value holder for integer variables.""" _default = 0 def __init__(self, master=None, value=None, name=None): """Construct an integer variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. """ Variable.__init__(self, master, value, name) def get(self): """Return the value of the variable as an integer.""" value = self._tk.globalgetvar(self._name) try: return self._tk.getint(value) except (TypeError, TclError): return int(self._tk.getdouble(value)) class DoubleVar(Variable): """Value holder for float variables.""" _default = 0.0 def __init__(self, master=None, value=None, name=None): """Construct a float variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0.0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. """ Variable.__init__(self, master, value, name) def get(self): """Return the value of the variable as a float.""" return self._tk.getdouble(self._tk.globalgetvar(self._name)) class BooleanVar(Variable): """Value holder for boolean variables.""" _default = False def __init__(self, master=None, value=None, name=None): """Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. """ Variable.__init__(self, master, value, name) def set(self, value): """Set the variable to VALUE.""" return self._tk.globalsetvar(self._name, self._tk.getboolean(value)) initialize = set def get(self): """Return the value of the variable as a bool.""" try: return self._tk.getboolean(self._tk.globalgetvar(self._name)) except TclError: raise ValueError("invalid literal for getboolean()") def mainloop(n=0): """Run the main loop of Tcl.""" _get_default_root('run the main loop').tk.mainloop(n) getint = int getdouble = float def getboolean(s): """Convert Tcl object to True or False.""" try: return _get_default_root('use getboolean()').tk.getboolean(s) except TclError: raise ValueError("invalid literal for getboolean()") # Methods defined on both toplevel and interior widgets class Misc: """Internal class. Base class which defines methods common for interior widgets.""" # used for generating child widget names _last_child_ids = None # XXX font command? _tclCommands = None def destroy(self): """Internal function. Delete all Tcl commands created for this widget in the Tcl interpreter.""" if self._tclCommands is not None: for name in self._tclCommands: #print '- Tkinter: deleted command', name self.tk.deletecommand(name) self._tclCommands = None def deletecommand(self, name): """Internal function. Delete the Tcl command provided in NAME.""" #print '- Tkinter: deleted command', name self.tk.deletecommand(name) try: self._tclCommands.remove(name) except ValueError: pass def tk_strictMotif(self, boolean=None): """Set Tcl internal variable, whether the look and feel should adhere to Motif. A parameter of 1 means adhere to Motif (e.g. no color change if mouse passes over slider). Returns the set value.""" return self.tk.getboolean(self.tk.call( 'set', 'tk_strictMotif', boolean)) def tk_bisque(self): """Change the color scheme to light brown as used in Tk 3.6 and before.""" self.tk.call('tk_bisque') def tk_setPalette(self, *args, **kw): """Set a new color scheme for all widget elements. A single color as argument will cause that all colors of Tk widget elements are derived from this. Alternatively several keyword parameters and its associated colors can be given. The following keywords are valid: activeBackground, foreground, selectColor, activeForeground, highlightBackground, selectBackground, background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) + _flatten(args) + _flatten(list(kw.items()))) def wait_variable(self, name='PY_VAR'): """Wait until the variable is modified. A parameter of type IntVar, StringVar, DoubleVar or BooleanVar must be given.""" self.tk.call('tkwait', 'variable', name) waitvar = wait_variable # XXX b/w compat def wait_window(self, window=None): """Wait until a WIDGET is destroyed. If no parameter is given self is used.""" if window is None: window = self self.tk.call('tkwait', 'window', window._w) def wait_visibility(self, window=None): """Wait until the visibility of a WIDGET changes (e.g. it appears). If no parameter is given self is used.""" if window is None: window = self self.tk.call('tkwait', 'visibility', window._w) def setvar(self, name='PY_VAR', value='1'): """Set Tcl variable NAME to VALUE.""" self.tk.setvar(name, value) def getvar(self, name='PY_VAR'): """Return value of Tcl variable NAME.""" return self.tk.getvar(name) def getint(self, s): try: return self.tk.getint(s) except TclError as exc: raise ValueError(str(exc)) def getdouble(self, s): try: return self.tk.getdouble(s) except TclError as exc: raise ValueError(str(exc)) def getboolean(self, s): """Return a boolean value for Tcl boolean values true and false given as parameter.""" try: return self.tk.getboolean(s) except TclError: raise ValueError("invalid literal for getboolean()") def focus_set(self): """Direct input focus to this widget. If the application currently does not have the focus this widget will get the focus if the application gets the focus through the window manager.""" self.tk.call('focus', self._w) focus = focus_set # XXX b/w compat? def focus_force(self): """Direct input focus to this widget even if the application does not have the focus. Use with caution!""" self.tk.call('focus', '-force', self._w) def focus_get(self): """Return the widget which has currently the focus in the application. Use focus_displayof to allow working with several displays. Return None if application does not have the focus.""" name = self.tk.call('focus') if name == 'none' or not name: return None return self._nametowidget(name) def focus_displayof(self): """Return the widget which has currently the focus on the display where this widget is located. Return None if the application does not have the focus.""" name = self.tk.call('focus', '-displayof', self._w) if name == 'none' or not name: return None return self._nametowidget(name) def focus_lastfor(self): """Return the widget which would have the focus if top level for this widget gets the focus from the window manager.""" name = self.tk.call('focus', '-lastfor', self._w) if name == 'none' or not name: return None return self._nametowidget(name) def tk_focusFollowsMouse(self): """The widget under mouse will get automatically focus. Can not be disabled easily.""" self.tk.call('tk_focusFollowsMouse') def tk_focusNext(self): """Return the next widget in the focus order which follows widget which has currently the focus. The focus order first goes to the next child, then to the children of the child recursively and then to the next sibling which is higher in the stacking order. A widget is omitted if it has the takefocus resource set to 0.""" name = self.tk.call('tk_focusNext', self._w) if not name: return None return self._nametowidget(name) def tk_focusPrev(self): """Return previous widget in the focus order. See tk_focusNext for details.""" name = self.tk.call('tk_focusPrev', self._w) if not name: return None return self._nametowidget(name) def after(self, ms, func=None, *args): """Call function once after given time. MS specifies the time in milliseconds. FUNC gives the function which shall be called. Additional parameters are given as parameters to the function call. Return identifier to cancel scheduling with after_cancel.""" if not func: # I'd rather use time.sleep(ms*0.001) self.tk.call('after', ms) return None else: def callit(): try: func(*args) finally: try: self.deletecommand(name) except TclError: pass callit.__name__ = func.__name__ name = self._register(callit) return self.tk.call('after', ms, name) def after_idle(self, func, *args): """Call FUNC once if the Tcl main loop has no event to process. Return an identifier to cancel the scheduling with after_cancel.""" return self.after('idle', func, *args) def after_cancel(self, id): """Cancel scheduling of function identified with ID. Identifier returned by after or after_idle must be given as first parameter. """ if not id: raise ValueError('id must be a valid identifier returned from ' 'after or after_idle') try: data = self.tk.call('after', 'info', id) script = self.tk.splitlist(data)[0] self.deletecommand(script) except TclError: pass self.tk.call('after', 'cancel', id) def bell(self, displayof=0): """Ring a display's bell.""" self.tk.call(('bell',) + self._displayof(displayof)) # Clipboard handling: def clipboard_get(self, **kw): """Retrieve data from the clipboard on window's display. The window keyword defaults to the root window of the Tkinter application. The type keyword specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING, except on X11, where the default is to try UTF8_STRING and fall back to STRING. This command is equivalent to: selection_get(CLIPBOARD) """ if 'type' not in kw and self._windowingsystem == 'x11': try: kw['type'] = 'UTF8_STRING' return self.tk.call(('clipboard', 'get') + self._options(kw)) except TclError: del kw['type'] return self.tk.call(('clipboard', 'get') + self._options(kw)) def clipboard_clear(self, **kw): """Clear the data in the Tk clipboard. A widget specified for the optional displayof keyword argument specifies the target display.""" if 'displayof' not in kw: kw['displayof'] = self._w self.tk.call(('clipboard', 'clear') + self._options(kw)) def clipboard_append(self, string, **kw): """Append STRING to the Tk clipboard. A widget specified at the optional displayof keyword argument specifies the target display. The clipboard can be retrieved with selection_get.""" if 'displayof' not in kw: kw['displayof'] = self._w self.tk.call(('clipboard', 'append') + self._options(kw) + ('--', string)) # XXX grab current w/o window argument def grab_current(self): """Return widget which has currently the grab in this application or None.""" name = self.tk.call('grab', 'current', self._w) if not name: return None return self._nametowidget(name) def grab_release(self): """Release grab for this widget if currently set.""" self.tk.call('grab', 'release', self._w) def grab_set(self): """Set grab for this widget. A grab directs all events to this and descendant widgets in the application.""" self.tk.call('grab', 'set', self._w) def grab_set_global(self): """Set global grab for this widget. A global grab directs all events to this and descendant widgets on the display. Use with caution - other applications do not get events anymore.""" self.tk.call('grab', 'set', '-global', self._w) def grab_status(self): """Return None, "local" or "global" if this widget has no, a local or a global grab.""" status = self.tk.call('grab', 'status', self._w) if status == 'none': status = None return status def option_add(self, pattern, value, priority = None): """Set a VALUE (second parameter) for an option PATTERN (first parameter). An optional third parameter gives the numeric priority (defaults to 80).""" self.tk.call('option', 'add', pattern, value, priority) def option_clear(self): """Clear the option database. It will be reloaded if option_add is called.""" self.tk.call('option', 'clear') def option_get(self, name, className): """Return the value for an option NAME for this widget with CLASSNAME. Values with higher priority override lower values.""" return self.tk.call('option', 'get', self._w, name, className) def option_readfile(self, fileName, priority = None): """Read file FILENAME into the option database. An optional second parameter gives the numeric priority.""" self.tk.call('option', 'readfile', fileName, priority) def selection_clear(self, **kw): """Clear the current X selection.""" if 'displayof' not in kw: kw['displayof'] = self._w self.tk.call(('selection', 'clear') + self._options(kw)) def selection_get(self, **kw): """Return the contents of the current X selection. A keyword parameter selection specifies the name of the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display to use. A keyword parameter type specifies the form of data to be fetched, defaulting to STRING except on X11, where UTF8_STRING is tried before STRING.""" if 'displayof' not in kw: kw['displayof'] = self._w if 'type' not in kw and self._windowingsystem == 'x11': try: kw['type'] = 'UTF8_STRING' return self.tk.call(('selection', 'get') + self._options(kw)) except TclError: del kw['type'] return self.tk.call(('selection', 'get') + self._options(kw)) def selection_handle(self, command, **kw): """Specify a function COMMAND to call if the X selection owned by this widget is queried by another application. This function must return the contents of the selection. The function will be called with the arguments OFFSET and LENGTH which allows the chunking of very long selections. The following keyword parameters can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).""" name = self._register(command) self.tk.call(('selection', 'handle') + self._options(kw) + (self._w, name)) def selection_own(self, **kw): """Become owner of X selection. A keyword parameter selection specifies the name of the selection (default PRIMARY).""" self.tk.call(('selection', 'own') + self._options(kw) + (self._w,)) def selection_own_get(self, **kw): """Return owner of X selection. The following keyword parameter can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).""" if 'displayof' not in kw: kw['displayof'] = self._w name = self.tk.call(('selection', 'own') + self._options(kw)) if not name: return None return self._nametowidget(name) def send(self, interp, cmd, *args): """Send Tcl command CMD to different interpreter INTERP to be executed.""" return self.tk.call(('send', interp, cmd) + args) def lower(self, belowThis=None): """Lower this widget in the stacking order.""" self.tk.call('lower', self._w, belowThis) def tkraise(self, aboveThis=None): """Raise this widget in the stacking order.""" self.tk.call('raise', self._w, aboveThis) lift = tkraise def winfo_atom(self, name, displayof=0): """Return integer which represents atom NAME.""" args = ('winfo', 'atom') + self._displayof(displayof) + (name,) return self.tk.getint(self.tk.call(args)) def winfo_atomname(self, id, displayof=0): """Return name of atom with identifier ID.""" args = ('winfo', 'atomname') \ + self._displayof(displayof) + (id,) return self.tk.call(args) def winfo_cells(self): """Return number of cells in the colormap for this widget.""" return self.tk.getint( self.tk.call('winfo', 'cells', self._w)) def winfo_children(self): """Return a list of all widgets which are children of this widget.""" result = [] for child in self.tk.splitlist( self.tk.call('winfo', 'children', self._w)): try: # Tcl sometimes returns extra windows, e.g. for # menus; those need to be skipped result.append(self._nametowidget(child)) except KeyError: pass return result def winfo_class(self): """Return window class name of this widget.""" return self.tk.call('winfo', 'class', self._w) def winfo_colormapfull(self): """Return True if at the last color request the colormap was full.""" return self.tk.getboolean( self.tk.call('winfo', 'colormapfull', self._w)) def winfo_containing(self, rootX, rootY, displayof=0): """Return the widget which is at the root coordinates ROOTX, ROOTY.""" args = ('winfo', 'containing') \ + self._displayof(displayof) + (rootX, rootY) name = self.tk.call(args) if not name: return None return self._nametowidget(name) def winfo_depth(self): """Return the number of bits per pixel.""" return self.tk.getint(self.tk.call('winfo', 'depth', self._w)) def winfo_exists(self): """Return true if this widget exists.""" return self.tk.getint( self.tk.call('winfo', 'exists', self._w)) def winfo_fpixels(self, number): """Return the number of pixels for the given distance NUMBER (e.g. "3c") as float.""" return self.tk.getdouble(self.tk.call( 'winfo', 'fpixels', self._w, number)) def winfo_geometry(self): """Return geometry string for this widget in the form "widthxheight+X+Y".""" return self.tk.call('winfo', 'geometry', self._w) def winfo_height(self): """Return height of this widget.""" return self.tk.getint( self.tk.call('winfo', 'height', self._w)) def winfo_id(self): """Return identifier ID for this widget.""" return int(self.tk.call('winfo', 'id', self._w), 0) def winfo_interps(self, displayof=0): """Return the name of all Tcl interpreters for this display.""" args = ('winfo', 'interps') + self._displayof(displayof) return self.tk.splitlist(self.tk.call(args)) def winfo_ismapped(self): """Return true if this widget is mapped.""" return self.tk.getint( self.tk.call('winfo', 'ismapped', self._w)) def winfo_manager(self): """Return the window manager name for this widget.""" return self.tk.call('winfo', 'manager', self._w) def winfo_name(self): """Return the name of this widget.""" return self.tk.call('winfo', 'name', self._w) def winfo_parent(self): """Return the name of the parent of this widget.""" return self.tk.call('winfo', 'parent', self._w) def winfo_pathname(self, id, displayof=0): """Return the pathname of the widget given by ID.""" args = ('winfo', 'pathname') \ + self._displayof(displayof) + (id,) return self.tk.call(args) def winfo_pixels(self, number): """Rounded integer value of winfo_fpixels.""" return self.tk.getint( self.tk.call('winfo', 'pixels', self._w, number)) def winfo_pointerx(self): """Return the x coordinate of the pointer on the root window.""" return self.tk.getint( self.tk.call('winfo', 'pointerx', self._w)) def winfo_pointerxy(self): """Return a tuple of x and y coordinates of the pointer on the root window.""" return self._getints( self.tk.call('winfo', 'pointerxy', self._w)) def winfo_pointery(self): """Return the y coordinate of the pointer on the root window.""" return self.tk.getint( self.tk.call('winfo', 'pointery', self._w)) def winfo_reqheight(self): """Return requested height of this widget.""" return self.tk.getint( self.tk.call('winfo', 'reqheight', self._w)) def winfo_reqwidth(self): """Return requested width of this widget.""" return self.tk.getint( self.tk.call('winfo', 'reqwidth', self._w)) def winfo_rgb(self, color): """Return a tuple of integer RGB values in range(65536) for color in this widget.""" return self._getints( self.tk.call('winfo', 'rgb', self._w, color)) def winfo_rootx(self): """Return x coordinate of upper left corner of this widget on the root window.""" return self.tk.getint( self.tk.call('winfo', 'rootx', self._w)) def winfo_rooty(self): """Return y coordinate of upper left corner of this widget on the root window.""" return self.tk.getint( self.tk.call('winfo', 'rooty', self._w)) def winfo_screen(self): """Return the screen name of this widget.""" return self.tk.call('winfo', 'screen', self._w) def winfo_screencells(self): """Return the number of the cells in the colormap of the screen of this widget.""" return self.tk.getint( self.tk.call('winfo', 'screencells', self._w)) def winfo_screendepth(self): """Return the number of bits per pixel of the root window of the screen of this widget.""" return self.tk.getint( self.tk.call('winfo', 'screendepth', self._w)) def winfo_screenheight(self): """Return the number of pixels of the height of the screen of this widget in pixel.""" return self.tk.getint( self.tk.call('winfo', 'screenheight', self._w)) def winfo_screenmmheight(self): """Return the number of pixels of the height of the screen of this widget in mm.""" return self.tk.getint( self.tk.call('winfo', 'screenmmheight', self._w)) def winfo_screenmmwidth(self): """Return the number of pixels of the width of the screen of this widget in mm.""" return self.tk.getint( self.tk.call('winfo', 'screenmmwidth', self._w)) def winfo_screenvisual(self): """Return one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the default colormodel of this screen.""" return self.tk.call('winfo', 'screenvisual', self._w) def winfo_screenwidth(self): """Return the number of pixels of the width of the screen of this widget in pixel.""" return self.tk.getint( self.tk.call('winfo', 'screenwidth', self._w)) def winfo_server(self): """Return information of the X-Server of the screen of this widget in the form "XmajorRminor vendor vendorVersion".""" return self.tk.call('winfo', 'server', self._w) def winfo_toplevel(self): """Return the toplevel widget of this widget.""" return self._nametowidget(self.tk.call( 'winfo', 'toplevel', self._w)) def winfo_viewable(self): """Return true if the widget and all its higher ancestors are mapped.""" return self.tk.getint( self.tk.call('winfo', 'viewable', self._w)) def winfo_visual(self): """Return one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the colormodel of this widget.""" return self.tk.call('winfo', 'visual', self._w) def winfo_visualid(self): """Return the X identifier for the visual for this widget.""" return self.tk.call('winfo', 'visualid', self._w) def winfo_visualsavailable(self, includeids=False): """Return a list of all visuals available for the screen of this widget. Each item in the list consists of a visual name (see winfo_visual), a depth and if includeids is true is given also the X identifier.""" data = self.tk.call('winfo', 'visualsavailable', self._w, 'includeids' if includeids else None) data = [self.tk.splitlist(x) for x in self.tk.splitlist(data)] return [self.__winfo_parseitem(x) for x in data] def __winfo_parseitem(self, t): """Internal function.""" return t[:1] + tuple(map(self.__winfo_getint, t[1:])) def __winfo_getint(self, x): """Internal function.""" return int(x, 0) def winfo_vrootheight(self): """Return the height of the virtual root window associated with this widget in pixels. If there is no virtual root window return the height of the screen.""" return self.tk.getint( self.tk.call('winfo', 'vrootheight', self._w)) def winfo_vrootwidth(self): """Return the width of the virtual root window associated with this widget in pixel. If there is no virtual root window return the width of the screen.""" return self.tk.getint( self.tk.call('winfo', 'vrootwidth', self._w)) def winfo_vrootx(self): """Return the x offset of the virtual root relative to the root window of the screen of this widget.""" return self.tk.getint( self.tk.call('winfo', 'vrootx', self._w)) def winfo_vrooty(self): """Return the y offset of the virtual root relative to the root window of the screen of this widget.""" return self.tk.getint( self.tk.call('winfo', 'vrooty', self._w)) def winfo_width(self): """Return the width of this widget.""" return self.tk.getint( self.tk.call('winfo', 'width', self._w)) def winfo_x(self): """Return the x coordinate of the upper left corner of this widget in the parent.""" return self.tk.getint( self.tk.call('winfo', 'x', self._w)) def winfo_y(self): """Return the y coordinate of the upper left corner of this widget in the parent.""" return self.tk.getint( self.tk.call('winfo', 'y', self._w)) def update(self): """Enter event loop until all pending events have been processed by Tcl.""" self.tk.call('update') def update_idletasks(self): """Enter event loop until all idle callbacks have been called. This will update the display of windows but not process events caused by the user.""" self.tk.call('update', 'idletasks') def bindtags(self, tagList=None): """Set or get the list of bindtags for this widget. With no argument return the list of all bindtags associated with this widget. With a list of strings as argument the bindtags are set to this list. The bindtags determine in which order events are processed (see bind).""" if tagList is None: return self.tk.splitlist( self.tk.call('bindtags', self._w)) else: self.tk.call('bindtags', self._w, tagList) def _bind(self, what, sequence, func, add, needcleanup=1): """Internal function.""" if isinstance(func, str): self.tk.call(what + (sequence, func)) elif func: funcid = self._register(func, self._substitute, needcleanup) cmd = ('%sif {"[%s %s]" == "break"} break\n' % (add and '+' or '', funcid, self._subst_format_str)) self.tk.call(what + (sequence, cmd)) return funcid elif sequence: return self.tk.call(what + (sequence,)) else: return self.tk.splitlist(self.tk.call(what)) def bind(self, sequence=None, func=None, add=None): """Bind to this widget at event SEQUENCE a call to function FUNC. SEQUENCE is a string of concatenated event patterns. An event pattern is of the form where MODIFIER is one of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4, Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3, B3, Alt, Button4, B4, Double, Button5, B5 Triple, Mod1, M1. TYPE is one of Activate, Enter, Map, ButtonPress, Button, Expose, Motion, ButtonRelease FocusIn, MouseWheel, Circulate, FocusOut, Property, Colormap, Gravity Reparent, Configure, KeyPress, Key, Unmap, Deactivate, KeyRelease Visibility, Destroy, Leave and DETAIL is the button number for ButtonPress, ButtonRelease and DETAIL is the Keysym for KeyPress and KeyRelease. Examples are for pressing Control and mouse button 1 or for pressing A and the Alt key (KeyPress can be omitted). An event pattern can also be a virtual event of the form <> where AString can be arbitrary. This event can be generated by event_generate. If events are concatenated they must appear shortly after each other. FUNC will be called if the event sequence occurs with an instance of Event as argument. If the return value of FUNC is "break" no further bound function is invoked. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. Bind will return an identifier to allow deletion of the bound function with unbind without memory leak. If FUNC or SEQUENCE is omitted the bound function or list of bound events are returned.""" return self._bind(('bind', self._w), sequence, func, add) def unbind(self, sequence, funcid=None): """Unbind for this widget for event SEQUENCE the function identified with FUNCID.""" self.tk.call('bind', self._w, sequence, '') if funcid: self.deletecommand(funcid) def bind_all(self, sequence=None, func=None, add=None): """Bind to all widgets at an event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.""" return self._bind(('bind', 'all'), sequence, func, add, 0) def unbind_all(self, sequence): """Unbind for all widgets for event SEQUENCE all functions.""" self.tk.call('bind', 'all' , sequence, '') def bind_class(self, className, sequence=None, func=None, add=None): """Bind to widgets with bindtag CLASSNAME at event SEQUENCE a call of function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.""" return self._bind(('bind', className), sequence, func, add, 0) def unbind_class(self, className, sequence): """Unbind for all widgets with bindtag CLASSNAME for event SEQUENCE all functions.""" self.tk.call('bind', className , sequence, '') def mainloop(self, n=0): """Call the mainloop of Tk.""" self.tk.mainloop(n) def quit(self): """Quit the Tcl interpreter. All widgets will be destroyed.""" self.tk.quit() def _getints(self, string): """Internal function.""" if string: return tuple(map(self.tk.getint, self.tk.splitlist(string))) def _getdoubles(self, string): """Internal function.""" if string: return tuple(map(self.tk.getdouble, self.tk.splitlist(string))) def _getboolean(self, string): """Internal function.""" if string: return self.tk.getboolean(string) def _displayof(self, displayof): """Internal function.""" if displayof: return ('-displayof', displayof) if displayof is None: return ('-displayof', self._w) return () @property def _windowingsystem(self): """Internal function.""" try: return self._root()._windowingsystem_cached except AttributeError: ws = self._root()._windowingsystem_cached = \ self.tk.call('tk', 'windowingsystem') return ws def _options(self, cnf, kw = None): """Internal function.""" if kw: cnf = _cnfmerge((cnf, kw)) else: cnf = _cnfmerge(cnf) res = () for k, v in cnf.items(): if v is not None: if k[-1] == '_': k = k[:-1] if callable(v): v = self._register(v) elif isinstance(v, (tuple, list)): nv = [] for item in v: if isinstance(item, int): nv.append(str(item)) elif isinstance(item, str): nv.append(_stringify(item)) else: break else: v = ' '.join(nv) res = res + ('-'+k, v) return res def nametowidget(self, name): """Return the Tkinter instance of a widget identified by its Tcl name NAME.""" name = str(name).split('.') w = self if not name[0]: w = w._root() name = name[1:] for n in name: if not n: break w = w.children[n] return w _nametowidget = nametowidget def _register(self, func, subst=None, needcleanup=1): """Return a newly created Tcl function. If this function is called, the Python function FUNC will be executed. An optional function SUBST can be given which will be executed before FUNC.""" f = CallWrapper(func, subst, self).__call__ name = repr(id(f)) try: func = func.__func__ except AttributeError: pass try: name = name + func.__name__ except AttributeError: pass self.tk.createcommand(name, f) if needcleanup: if self._tclCommands is None: self._tclCommands = [] self._tclCommands.append(name) return name register = _register def _root(self): """Internal function.""" w = self while w.master: w = w.master return w _subst_format = ('%#', '%b', '%f', '%h', '%k', '%s', '%t', '%w', '%x', '%y', '%A', '%E', '%K', '%N', '%W', '%T', '%X', '%Y', '%D') _subst_format_str = " ".join(_subst_format) def _substitute(self, *args): """Internal function.""" if len(args) != len(self._subst_format): return args getboolean = self.tk.getboolean getint = self.tk.getint def getint_event(s): """Tk changed behavior in 8.4.2, returning "??" rather more often.""" try: return getint(s) except (ValueError, TclError): return s nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() # serial field: valid for all events # number of button: ButtonPress and ButtonRelease events only # height field: Configure, ConfigureRequest, Create, # ResizeRequest, and Expose events only # keycode field: KeyPress and KeyRelease events only # time field: "valid for events that contain a time field" # width field: Configure, ConfigureRequest, Create, ResizeRequest, # and Expose events only # x field: "valid for events that contain an x field" # y field: "valid for events that contain a y field" # keysym as decimal: KeyPress and KeyRelease events only # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress, # KeyRelease, and Motion events e.serial = getint(nsign) e.num = getint_event(b) try: e.focus = getboolean(f) except TclError: pass e.height = getint_event(h) e.keycode = getint_event(k) e.state = getint_event(s) e.time = getint_event(t) e.width = getint_event(w) e.x = getint_event(x) e.y = getint_event(y) e.char = A try: e.send_event = getboolean(E) except TclError: pass e.keysym = K e.keysym_num = getint_event(N) try: e.type = EventType(T) except ValueError: e.type = T try: e.widget = self._nametowidget(W) except KeyError: e.widget = W e.x_root = getint_event(X) e.y_root = getint_event(Y) try: e.delta = getint(D) except (ValueError, TclError): e.delta = 0 return (e,) def _report_exception(self): """Internal function.""" exc, val, tb = sys.exc_info() root = self._root() root.report_callback_exception(exc, val, tb) def _getconfigure(self, *args): """Call Tcl configure command and return the result as a dict.""" cnf = {} for x in self.tk.splitlist(self.tk.call(*args)): x = self.tk.splitlist(x) cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf def _getconfigure1(self, *args): x = self.tk.splitlist(self.tk.call(*args)) return (x[0][1:],) + x[1:] def _configure(self, cmd, cnf, kw): """Internal function.""" if kw: cnf = _cnfmerge((cnf, kw)) elif cnf: cnf = _cnfmerge(cnf) if cnf is None: return self._getconfigure(_flatten((self._w, cmd))) if isinstance(cnf, str): return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf))) self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) # These used to be defined in Widget: def configure(self, cnf=None, **kw): """Configure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys. """ return self._configure('configure', cnf, kw) config = configure def cget(self, key): """Return the resource value for a KEY given as string.""" return self.tk.call(self._w, 'cget', '-' + key) __getitem__ = cget def __setitem__(self, key, value): self.configure({key: value}) def keys(self): """Return a list of all resource names of this widget.""" splitlist = self.tk.splitlist return [splitlist(x)[0][1:] for x in splitlist(self.tk.call(self._w, 'configure'))] def __str__(self): """Return the window path name of this widget.""" return self._w def __repr__(self): return '<%s.%s object %s>' % ( self.__class__.__module__, self.__class__.__qualname__, self._w) # Pack methods that apply to the master _noarg_ = ['_noarg_'] def pack_propagate(self, flag=_noarg_): """Set or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given the current setting will be returned. """ if flag is Misc._noarg_: return self._getboolean(self.tk.call( 'pack', 'propagate', self._w)) else: self.tk.call('pack', 'propagate', self._w, flag) propagate = pack_propagate def pack_slaves(self): """Return a list of all slaves of this widget in its packing order.""" return [self._nametowidget(x) for x in self.tk.splitlist( self.tk.call('pack', 'slaves', self._w))] slaves = pack_slaves # Place method that applies to the master def place_slaves(self): """Return a list of all slaves of this widget in its packing order.""" return [self._nametowidget(x) for x in self.tk.splitlist( self.tk.call( 'place', 'slaves', self._w))] # Grid methods that apply to the master def grid_anchor(self, anchor=None): # new in Tk 8.5 """The anchor value controls how to place the grid within the master when no row/column has any weight. The default anchor is nw.""" self.tk.call('grid', 'anchor', self._w, anchor) anchor = grid_anchor def grid_bbox(self, column=None, row=None, col2=None, row2=None): """Return a tuple of integer coordinates for the bounding box of this widget controlled by the geometry manager grid. If COLUMN, ROW is given the bounding box applies from the cell with row and column 0 to the specified cell. If COL2 and ROW2 are given the bounding box starts at that cell. The returned integers specify the offset of the upper left corner in the master widget and the width and height. """ args = ('grid', 'bbox', self._w) if column is not None and row is not None: args = args + (column, row) if col2 is not None and row2 is not None: args = args + (col2, row2) return self._getints(self.tk.call(*args)) or None bbox = grid_bbox def _gridconvvalue(self, value): if isinstance(value, (str, _tkinter.Tcl_Obj)): try: svalue = str(value) if not svalue: return None elif '.' in svalue: return self.tk.getdouble(svalue) else: return self.tk.getint(svalue) except (ValueError, TclError): pass return value def _grid_configure(self, command, index, cnf, kw): """Internal function.""" if isinstance(cnf, str) and not kw: if cnf[-1:] == '_': cnf = cnf[:-1] if cnf[:1] != '-': cnf = '-'+cnf options = (cnf,) else: options = self._options(cnf, kw) if not options: return _splitdict( self.tk, self.tk.call('grid', command, self._w, index), conv=self._gridconvvalue) res = self.tk.call( ('grid', command, self._w, index) + options) if len(options) == 1: return self._gridconvvalue(res) def grid_columnconfigure(self, index, cnf={}, **kw): """Configure column INDEX of a grid. Valid resources are minsize (minimum size of the column), weight (how much does additional space propagate to this column) and pad (how much space to let additionally).""" return self._grid_configure('columnconfigure', index, cnf, kw) columnconfigure = grid_columnconfigure def grid_location(self, x, y): """Return a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.""" return self._getints( self.tk.call( 'grid', 'location', self._w, x, y)) or None def grid_propagate(self, flag=_noarg_): """Set or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given, the current setting will be returned. """ if flag is Misc._noarg_: return self._getboolean(self.tk.call( 'grid', 'propagate', self._w)) else: self.tk.call('grid', 'propagate', self._w, flag) def grid_rowconfigure(self, index, cnf={}, **kw): """Configure row INDEX of a grid. Valid resources are minsize (minimum size of the row), weight (how much does additional space propagate to this row) and pad (how much space to let additionally).""" return self._grid_configure('rowconfigure', index, cnf, kw) rowconfigure = grid_rowconfigure def grid_size(self): """Return a tuple of the number of column and rows in the grid.""" return self._getints( self.tk.call('grid', 'size', self._w)) or None size = grid_size def grid_slaves(self, row=None, column=None): """Return a list of all slaves of this widget in its packing order.""" args = () if row is not None: args = args + ('-row', row) if column is not None: args = args + ('-column', column) return [self._nametowidget(x) for x in self.tk.splitlist(self.tk.call( ('grid', 'slaves', self._w) + args))] # Support for the "event" command, new in Tk 4.2. # By Case Roole. def event_add(self, virtual, *sequences): """Bind a virtual event VIRTUAL (of the form <>) to an event SEQUENCE such that the virtual event is triggered whenever SEQUENCE occurs.""" args = ('event', 'add', virtual) + sequences self.tk.call(args) def event_delete(self, virtual, *sequences): """Unbind a virtual event VIRTUAL from SEQUENCE.""" args = ('event', 'delete', virtual) + sequences self.tk.call(args) def event_generate(self, sequence, **kw): """Generate an event SEQUENCE. Additional keyword arguments specify parameter of the event (e.g. x, y, rootx, rooty).""" args = ('event', 'generate', self._w, sequence) for k, v in kw.items(): args = args + ('-%s' % k, str(v)) self.tk.call(args) def event_info(self, virtual=None): """Return a list of all virtual events or the information about the SEQUENCE bound to the virtual event VIRTUAL.""" return self.tk.splitlist( self.tk.call('event', 'info', virtual)) # Image related commands def image_names(self): """Return a list of all existing image names.""" return self.tk.splitlist(self.tk.call('image', 'names')) def image_types(self): """Return a list of all available image types (e.g. photo bitmap).""" return self.tk.splitlist(self.tk.call('image', 'types')) class CallWrapper: """Internal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.""" def __init__(self, func, subst, widget): """Store FUNC, SUBST and WIDGET as members.""" self.func = func self.subst = subst self.widget = widget def __call__(self, *args): """Apply first function SUBST to arguments, than FUNC.""" try: if self.subst: args = self.subst(*args) return self.func(*args) except SystemExit: raise except: self.widget._report_exception() class XView: """Mix-in class for querying and changing the horizontal position of a widget's window.""" def xview(self, *args): """Query and change the horizontal position of the view.""" res = self.tk.call(self._w, 'xview', *args) if not args: return self._getdoubles(res) def xview_moveto(self, fraction): """Adjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.""" self.tk.call(self._w, 'xview', 'moveto', fraction) def xview_scroll(self, number, what): """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" self.tk.call(self._w, 'xview', 'scroll', number, what) class YView: """Mix-in class for querying and changing the vertical position of a widget's window.""" def yview(self, *args): """Query and change the vertical position of the view.""" res = self.tk.call(self._w, 'yview', *args) if not args: return self._getdoubles(res) def yview_moveto(self, fraction): """Adjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.""" self.tk.call(self._w, 'yview', 'moveto', fraction) def yview_scroll(self, number, what): """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" self.tk.call(self._w, 'yview', 'scroll', number, what) class Wm: """Provides functions for the communication with the window manager.""" def wm_aspect(self, minNumer=None, minDenom=None, maxNumer=None, maxDenom=None): """Instruct the window manager to set the aspect ratio (width/height) of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. Return a tuple of the actual values if no argument is given.""" return self._getints( self.tk.call('wm', 'aspect', self._w, minNumer, minDenom, maxNumer, maxDenom)) aspect = wm_aspect def wm_attributes(self, *args): """This subcommand returns or sets platform specific attributes The first form returns a list of the platform specific flags and their values. The second form returns the value for the specific option. The third form sets one or more of the values. The values are as follows: On Windows, -disabled gets or sets whether the window is in a disabled state. -toolwindow gets or sets the style of the window to toolwindow (as defined in the MSDN). -topmost gets or sets whether this is a topmost window (displays above all other windows). On Macintosh, XXXXX On Unix, there are currently no special attribute values. """ args = ('wm', 'attributes', self._w) + args return self.tk.call(args) attributes = wm_attributes def wm_client(self, name=None): """Store NAME in WM_CLIENT_MACHINE property of this widget. Return current value.""" return self.tk.call('wm', 'client', self._w, name) client = wm_client def wm_colormapwindows(self, *wlist): """Store list of window names (WLIST) into WM_COLORMAPWINDOWS property of this widget. This list contains windows whose colormaps differ from their parents. Return current list of widgets if WLIST is empty.""" if len(wlist) > 1: wlist = (wlist,) # Tk needs a list of windows here args = ('wm', 'colormapwindows', self._w) + wlist if wlist: self.tk.call(args) else: return [self._nametowidget(x) for x in self.tk.splitlist(self.tk.call(args))] colormapwindows = wm_colormapwindows def wm_command(self, value=None): """Store VALUE in WM_COMMAND property. It is the command which shall be used to invoke the application. Return current command if VALUE is None.""" return self.tk.call('wm', 'command', self._w, value) command = wm_command def wm_deiconify(self): """Deiconify this widget. If it was never mapped it will not be mapped. On Windows it will raise this widget and give it the focus.""" return self.tk.call('wm', 'deiconify', self._w) deiconify = wm_deiconify def wm_focusmodel(self, model=None): """Set focus model to MODEL. "active" means that this widget will claim the focus itself, "passive" means that the window manager shall give the focus. Return current focus model if MODEL is None.""" return self.tk.call('wm', 'focusmodel', self._w, model) focusmodel = wm_focusmodel def wm_forget(self, window): # new in Tk 8.5 """The window will be unmapped from the screen and will no longer be managed by wm. toplevel windows will be treated like frame windows once they are no longer managed by wm, however, the menu option configuration will be remembered and the menus will return once the widget is managed again.""" self.tk.call('wm', 'forget', window) forget = wm_forget def wm_frame(self): """Return identifier for decorative frame of this widget if present.""" return self.tk.call('wm', 'frame', self._w) frame = wm_frame def wm_geometry(self, newGeometry=None): """Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return current value if None is given.""" return self.tk.call('wm', 'geometry', self._w, newGeometry) geometry = wm_geometry def wm_grid(self, baseWidth=None, baseHeight=None, widthInc=None, heightInc=None): """Instruct the window manager that this widget shall only be resized on grid boundaries. WIDTHINC and HEIGHTINC are the width and height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are the number of grid units requested in Tk_GeometryRequest.""" return self._getints(self.tk.call( 'wm', 'grid', self._w, baseWidth, baseHeight, widthInc, heightInc)) grid = wm_grid def wm_group(self, pathName=None): """Set the group leader widgets for related widgets to PATHNAME. Return the group leader of this widget if None is given.""" return self.tk.call('wm', 'group', self._w, pathName) group = wm_group def wm_iconbitmap(self, bitmap=None, default=None): """Set bitmap for the iconified widget to BITMAP. Return the bitmap if None is given. Under Windows, the DEFAULT parameter can be used to set the icon for the widget and any descendents that don't have an icon set explicitly. DEFAULT can be the relative path to a .ico file (example: root.iconbitmap(default='myicon.ico') ). See Tk documentation for more information.""" if default: return self.tk.call('wm', 'iconbitmap', self._w, '-default', default) else: return self.tk.call('wm', 'iconbitmap', self._w, bitmap) iconbitmap = wm_iconbitmap def wm_iconify(self): """Display widget as icon.""" return self.tk.call('wm', 'iconify', self._w) iconify = wm_iconify def wm_iconmask(self, bitmap=None): """Set mask for the icon bitmap of this widget. Return the mask if None is given.""" return self.tk.call('wm', 'iconmask', self._w, bitmap) iconmask = wm_iconmask def wm_iconname(self, newName=None): """Set the name of the icon for this widget. Return the name if None is given.""" return self.tk.call('wm', 'iconname', self._w, newName) iconname = wm_iconname def wm_iconphoto(self, default=False, *args): # new in Tk 8.5 """Sets the titlebar icon for this window based on the named photo images passed through args. If default is True, this is applied to all future created toplevels as well. The data in the images is taken as a snapshot at the time of invocation. If the images are later changed, this is not reflected to the titlebar icons. Multiple images are accepted to allow different images sizes to be provided. The window manager may scale provided icons to an appropriate size. On Windows, the images are packed into a Windows icon structure. This will override an icon specified to wm_iconbitmap, and vice versa. On X, the images are arranged into the _NET_WM_ICON X property, which most modern window managers support. An icon specified by wm_iconbitmap may exist simultaneously. On Macintosh, this currently does nothing.""" if default: self.tk.call('wm', 'iconphoto', self._w, "-default", *args) else: self.tk.call('wm', 'iconphoto', self._w, *args) iconphoto = wm_iconphoto def wm_iconposition(self, x=None, y=None): """Set the position of the icon of this widget to X and Y. Return a tuple of the current values of X and X if None is given.""" return self._getints(self.tk.call( 'wm', 'iconposition', self._w, x, y)) iconposition = wm_iconposition def wm_iconwindow(self, pathName=None): """Set widget PATHNAME to be displayed instead of icon. Return the current value if None is given.""" return self.tk.call('wm', 'iconwindow', self._w, pathName) iconwindow = wm_iconwindow def wm_manage(self, widget): # new in Tk 8.5 """The widget specified will become a stand alone top-level window. The window will be decorated with the window managers title bar, etc.""" self.tk.call('wm', 'manage', widget) manage = wm_manage def wm_maxsize(self, width=None, height=None): """Set max WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.""" return self._getints(self.tk.call( 'wm', 'maxsize', self._w, width, height)) maxsize = wm_maxsize def wm_minsize(self, width=None, height=None): """Set min WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.""" return self._getints(self.tk.call( 'wm', 'minsize', self._w, width, height)) minsize = wm_minsize def wm_overrideredirect(self, boolean=None): """Instruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.""" return self._getboolean(self.tk.call( 'wm', 'overrideredirect', self._w, boolean)) overrideredirect = wm_overrideredirect def wm_positionfrom(self, who=None): """Instruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".""" return self.tk.call('wm', 'positionfrom', self._w, who) positionfrom = wm_positionfrom def wm_protocol(self, name=None, func=None): """Bind function FUNC to command NAME for this widget. Return the function bound to NAME if None is given. NAME could be e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW".""" if callable(func): command = self._register(func) else: command = func return self.tk.call( 'wm', 'protocol', self._w, name, command) protocol = wm_protocol def wm_resizable(self, width=None, height=None): """Instruct the window manager whether this width can be resized in WIDTH or HEIGHT. Both values are boolean values.""" return self.tk.call('wm', 'resizable', self._w, width, height) resizable = wm_resizable def wm_sizefrom(self, who=None): """Instruct the window manager that the size of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".""" return self.tk.call('wm', 'sizefrom', self._w, who) sizefrom = wm_sizefrom def wm_state(self, newstate=None): """Query or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).""" return self.tk.call('wm', 'state', self._w, newstate) state = wm_state def wm_title(self, string=None): """Set the title of this widget.""" return self.tk.call('wm', 'title', self._w, string) title = wm_title def wm_transient(self, master=None): """Instruct the window manager that this widget is transient with regard to widget MASTER.""" return self.tk.call('wm', 'transient', self._w, master) transient = wm_transient def wm_withdraw(self): """Withdraw this widget from the screen such that it is unmapped and forgotten by the window manager. Re-draw it with wm_deiconify.""" return self.tk.call('wm', 'withdraw', self._w) withdraw = wm_withdraw class Tk(Misc, Wm): """Toplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.""" _w = '.' def __init__(self, screenName=None, baseName=None, className='Tk', useTk=1, sync=0, use=None): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.""" self.master = None self.children = {} self._tkloaded = False # to avoid recursions in the getattr code in case of failure, we # ensure that self.tk is always _something_. self.tk = None if baseName is None: import os baseName = os.path.basename(sys.argv[0]) baseName, ext = os.path.splitext(baseName) if ext not in ('.py', '.pyc'): baseName = baseName + ext interactive = 0 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) if useTk: self._loadtk() if not sys.flags.ignore_environment: # Issue #16248: Honor the -E flag to avoid code injection. self.readprofile(baseName, className) def loadtk(self): if not self._tkloaded: self.tk.loadtk() self._loadtk() def _loadtk(self): self._tkloaded = True global _default_root # Version sanity checks tk_version = self.tk.getvar('tk_version') if tk_version != _tkinter.TK_VERSION: raise RuntimeError("tk.h version (%s) doesn't match libtk.a version (%s)" % (_tkinter.TK_VERSION, tk_version)) # Under unknown circumstances, tcl_version gets coerced to float tcl_version = str(self.tk.getvar('tcl_version')) if tcl_version != _tkinter.TCL_VERSION: raise RuntimeError("tcl.h version (%s) doesn't match libtcl.a version (%s)" \ % (_tkinter.TCL_VERSION, tcl_version)) # Create and register the tkerror and exit commands # We need to inline parts of _register here, _ register # would register differently-named commands. if self._tclCommands is None: self._tclCommands = [] self.tk.createcommand('tkerror', _tkerror) self.tk.createcommand('exit', _exit) self._tclCommands.append('tkerror') self._tclCommands.append('exit') if _support_default_root and not _default_root: _default_root = self self.protocol("WM_DELETE_WINDOW", self.destroy) def destroy(self): """Destroy this and all descendants widgets. This will end the application of this Tcl interpreter.""" for c in list(self.children.values()): c.destroy() self.tk.call('destroy', self._w) Misc.destroy(self) global _default_root if _support_default_root and _default_root is self: _default_root = None def readprofile(self, baseName, className): """Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into the Tcl Interpreter and calls exec on the contents of BASENAME.py and CLASSNAME.py if such a file exists in the home directory.""" import os if 'HOME' in os.environ: home = os.environ['HOME'] else: home = os.curdir class_tcl = os.path.join(home, '.%s.tcl' % className) class_py = os.path.join(home, '.%s.py' % className) base_tcl = os.path.join(home, '.%s.tcl' % baseName) base_py = os.path.join(home, '.%s.py' % baseName) dir = {'self': self} exec('from tkinter import *', dir) if os.path.isfile(class_tcl): self.tk.call('source', class_tcl) if os.path.isfile(class_py): exec(open(class_py).read(), dir) if os.path.isfile(base_tcl): self.tk.call('source', base_tcl) if os.path.isfile(base_py): exec(open(base_py).read(), dir) def report_callback_exception(self, exc, val, tb): """Report callback exception on sys.stderr. Applications may want to override this internal function, and should when sys.stderr is None.""" import traceback print("Exception in Tkinter callback", file=sys.stderr) sys.last_type = exc sys.last_value = val sys.last_traceback = tb traceback.print_exception(exc, val, tb) def __getattr__(self, attr): "Delegate attribute access to the interpreter object" return getattr(self.tk, attr) # Ideally, the classes Pack, Place and Grid disappear, the # pack/place/grid methods are defined on the Widget class, and # everybody uses w.pack_whatever(...) instead of Pack.whatever(w, # ...), with pack(), place() and grid() being short for # pack_configure(), place_configure() and grid_columnconfigure(), and # forget() being short for pack_forget(). As a practical matter, I'm # afraid that there is too much code out there that may be using the # Pack, Place or Grid class, so I leave them intact -- but only as # backwards compatibility features. Also note that those methods that # take a master as argument (e.g. pack_propagate) have been moved to # the Misc class (which now incorporates all methods common between # toplevel and interior widgets). Again, for compatibility, these are # copied into the Pack, Place or Grid class. def Tcl(screenName=None, baseName=None, className='Tk', useTk=0): return Tk(screenName, baseName, className, useTk) class Pack: """Geometry manager Pack. Base class to use the methods pack_* in every widget.""" def pack_configure(self, cnf={}, **kw): """Pack a widget in the parent widget. Use as options: after=widget - pack it after you have packed widget anchor=NSEW (or subset) - position widget according to given direction before=widget - pack it before you will pack widget expand=bool - expand widget if parent size grows fill=NONE or X or Y or BOTH - fill widget if widget grows in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction side=TOP or BOTTOM or LEFT or RIGHT - where to add this widget. """ self.tk.call( ('pack', 'configure', self._w) + self._options(cnf, kw)) pack = configure = config = pack_configure def pack_forget(self): """Unmap this widget and do not use it for the packing order.""" self.tk.call('pack', 'forget', self._w) forget = pack_forget def pack_info(self): """Return information about the packing options for this widget.""" d = _splitdict(self.tk, self.tk.call('pack', 'info', self._w)) if 'in' in d: d['in'] = self.nametowidget(d['in']) return d info = pack_info propagate = pack_propagate = Misc.pack_propagate slaves = pack_slaves = Misc.pack_slaves class Place: """Geometry manager Place. Base class to use the methods place_* in every widget.""" def place_configure(self, cnf={}, **kw): """Place a widget in the parent widget. Use as options: in=master - master relative to which the widget is placed in_=master - see 'in' option description x=amount - locate anchor of this widget at position x of master y=amount - locate anchor of this widget at position y of master relx=amount - locate anchor of this widget between 0.0 and 1.0 relative to width of master (1.0 is right edge) rely=amount - locate anchor of this widget between 0.0 and 1.0 relative to height of master (1.0 is bottom edge) anchor=NSEW (or subset) - position anchor according to given direction width=amount - width of this widget in pixel height=amount - height of this widget in pixel relwidth=amount - width of this widget between 0.0 and 1.0 relative to width of master (1.0 is the same width as the master) relheight=amount - height of this widget between 0.0 and 1.0 relative to height of master (1.0 is the same height as the master) bordermode="inside" or "outside" - whether to take border width of master widget into account """ self.tk.call( ('place', 'configure', self._w) + self._options(cnf, kw)) place = configure = config = place_configure def place_forget(self): """Unmap this widget.""" self.tk.call('place', 'forget', self._w) forget = place_forget def place_info(self): """Return information about the placing options for this widget.""" d = _splitdict(self.tk, self.tk.call('place', 'info', self._w)) if 'in' in d: d['in'] = self.nametowidget(d['in']) return d info = place_info slaves = place_slaves = Misc.place_slaves class Grid: """Geometry manager Grid. Base class to use the methods grid_* in every widget.""" # Thanks to Masazumi Yoshikawa (yosikawa@isi.edu) def grid_configure(self, cnf={}, **kw): """Position a widget in the parent widget in a grid. Use as options: column=number - use cell identified with given column (starting with 0) columnspan=number - this widget will span several columns in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction row=number - use cell identified with given row (starting with 0) rowspan=number - this widget will span several rows sticky=NSEW - if cell is larger on which sides will this widget stick to the cell boundary """ self.tk.call( ('grid', 'configure', self._w) + self._options(cnf, kw)) grid = configure = config = grid_configure bbox = grid_bbox = Misc.grid_bbox columnconfigure = grid_columnconfigure = Misc.grid_columnconfigure def grid_forget(self): """Unmap this widget.""" self.tk.call('grid', 'forget', self._w) forget = grid_forget def grid_remove(self): """Unmap this widget but remember the grid options.""" self.tk.call('grid', 'remove', self._w) def grid_info(self): """Return information about the options for positioning this widget in a grid.""" d = _splitdict(self.tk, self.tk.call('grid', 'info', self._w)) if 'in' in d: d['in'] = self.nametowidget(d['in']) return d info = grid_info location = grid_location = Misc.grid_location propagate = grid_propagate = Misc.grid_propagate rowconfigure = grid_rowconfigure = Misc.grid_rowconfigure size = grid_size = Misc.grid_size slaves = grid_slaves = Misc.grid_slaves class BaseWidget(Misc): """Internal class.""" def _setup(self, master, cnf): """Internal function. Sets up information about children.""" if not master: master = _get_default_root() self.master = master self.tk = master.tk name = None if 'name' in cnf: name = cnf['name'] del cnf['name'] if not name: name = self.__class__.__name__.lower() if master._last_child_ids is None: master._last_child_ids = {} count = master._last_child_ids.get(name, 0) + 1 master._last_child_ids[name] = count if count == 1: name = '!%s' % (name,) else: name = '!%s%d' % (name, count) self._name = name if master._w=='.': self._w = '.' + name else: self._w = master._w + '.' + name self.children = {} if self._name in self.master.children: self.master.children[self._name].destroy() self.master.children[self._name] = self def __init__(self, master, widgetName, cnf={}, kw={}, extra=()): """Construct a widget with the parent widget MASTER, a name WIDGETNAME and appropriate options.""" if kw: cnf = _cnfmerge((cnf, kw)) self.widgetName = widgetName BaseWidget._setup(self, master, cnf) if self._tclCommands is None: self._tclCommands = [] classes = [(k, v) for k, v in cnf.items() if isinstance(k, type)] for k, v in classes: del cnf[k] self.tk.call( (widgetName, self._w) + extra + self._options(cnf)) for k, v in classes: k.configure(self, v) def destroy(self): """Destroy this and all descendants widgets.""" for c in list(self.children.values()): c.destroy() self.tk.call('destroy', self._w) if self._name in self.master.children: del self.master.children[self._name] Misc.destroy(self) def _do(self, name, args=()): # XXX Obsolete -- better use self.tk.call directly! return self.tk.call((self._w, name) + args) class Widget(BaseWidget, Pack, Place, Grid): """Internal class. Base class for a widget which can be positioned with the geometry managers Pack, Place or Grid.""" pass class Toplevel(BaseWidget, Wm): """Toplevel widget, e.g. for dialogs.""" def __init__(self, master=None, cnf={}, **kw): """Construct a toplevel widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, menu, relief, screen, takefocus, use, visual, width.""" if kw: cnf = _cnfmerge((cnf, kw)) extra = () for wmkey in ['screen', 'class_', 'class', 'visual', 'colormap']: if wmkey in cnf: val = cnf[wmkey] # TBD: a hack needed because some keys # are not valid as keyword arguments if wmkey[-1] == '_': opt = '-'+wmkey[:-1] else: opt = '-'+wmkey extra = extra + (opt, val) del cnf[wmkey] BaseWidget.__init__(self, master, 'toplevel', cnf, {}, extra) root = self._root() self.iconname(root.iconname()) self.title(root.title()) self.protocol("WM_DELETE_WINDOW", self.destroy) class Button(Widget): """Button widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a button widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, repeatdelay, repeatinterval, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS command, compound, default, height, overrelief, state, width """ Widget.__init__(self, master, 'button', cnf, kw) def flash(self): """Flash the button. This is accomplished by redisplaying the button several times, alternating between active and normal colors. At the end of the flash the button is left in the same normal/active state as when the command was invoked. This command is ignored if the button's state is disabled. """ self.tk.call(self._w, 'flash') def invoke(self): """Invoke the command associated with the button. The return value is the return value from the command, or an empty string if there is no command associated with the button. This command is ignored if the button's state is disabled. """ return self.tk.call(self._w, 'invoke') class Canvas(Widget, XView, YView): """Canvas widget to display graphical elements like lines or text.""" def __init__(self, master=None, cnf={}, **kw): """Construct a canvas widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, closeenough, confine, cursor, height, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, offset, relief, scrollregion, selectbackground, selectborderwidth, selectforeground, state, takefocus, width, xscrollcommand, xscrollincrement, yscrollcommand, yscrollincrement.""" Widget.__init__(self, master, 'canvas', cnf, kw) def addtag(self, *args): """Internal function.""" self.tk.call((self._w, 'addtag') + args) def addtag_above(self, newtag, tagOrId): """Add tag NEWTAG to all items above TAGORID.""" self.addtag(newtag, 'above', tagOrId) def addtag_all(self, newtag): """Add tag NEWTAG to all items.""" self.addtag(newtag, 'all') def addtag_below(self, newtag, tagOrId): """Add tag NEWTAG to all items below TAGORID.""" self.addtag(newtag, 'below', tagOrId) def addtag_closest(self, newtag, x, y, halo=None, start=None): """Add tag NEWTAG to item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closests). If START is specified the next below this tag is taken.""" self.addtag(newtag, 'closest', x, y, halo, start) def addtag_enclosed(self, newtag, x1, y1, x2, y2): """Add tag NEWTAG to all items in the rectangle defined by X1,Y1,X2,Y2.""" self.addtag(newtag, 'enclosed', x1, y1, x2, y2) def addtag_overlapping(self, newtag, x1, y1, x2, y2): """Add tag NEWTAG to all items which overlap the rectangle defined by X1,Y1,X2,Y2.""" self.addtag(newtag, 'overlapping', x1, y1, x2, y2) def addtag_withtag(self, newtag, tagOrId): """Add tag NEWTAG to all items with TAGORID.""" self.addtag(newtag, 'withtag', tagOrId) def bbox(self, *args): """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses all items with tags specified as arguments.""" return self._getints( self.tk.call((self._w, 'bbox') + args)) or None def tag_unbind(self, tagOrId, sequence, funcid=None): """Unbind for all items with TAGORID for event SEQUENCE the function identified with FUNCID.""" self.tk.call(self._w, 'bind', tagOrId, sequence, '') if funcid: self.deletecommand(funcid) def tag_bind(self, tagOrId, sequence=None, func=None, add=None): """Bind to all items with TAGORID at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.""" return self._bind((self._w, 'bind', tagOrId), sequence, func, add) def canvasx(self, screenx, gridspacing=None): """Return the canvas x coordinate of pixel position SCREENX rounded to nearest multiple of GRIDSPACING units.""" return self.tk.getdouble(self.tk.call( self._w, 'canvasx', screenx, gridspacing)) def canvasy(self, screeny, gridspacing=None): """Return the canvas y coordinate of pixel position SCREENY rounded to nearest multiple of GRIDSPACING units.""" return self.tk.getdouble(self.tk.call( self._w, 'canvasy', screeny, gridspacing)) def coords(self, *args): """Return a list of coordinates for the item given in ARGS.""" # XXX Should use _flatten on args return [self.tk.getdouble(x) for x in self.tk.splitlist( self.tk.call((self._w, 'coords') + args))] def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={}) """Internal function.""" args = _flatten(args) cnf = args[-1] if isinstance(cnf, (dict, tuple)): args = args[:-1] else: cnf = {} return self.tk.getint(self.tk.call( self._w, 'create', itemType, *(args + self._options(cnf, kw)))) def create_arc(self, *args, **kw): """Create arc shaped region with coordinates x1,y1,x2,y2.""" return self._create('arc', args, kw) def create_bitmap(self, *args, **kw): """Create bitmap with coordinates x1,y1.""" return self._create('bitmap', args, kw) def create_image(self, *args, **kw): """Create image item with coordinates x1,y1.""" return self._create('image', args, kw) def create_line(self, *args, **kw): """Create line with coordinates x1,y1,...,xn,yn.""" return self._create('line', args, kw) def create_oval(self, *args, **kw): """Create oval with coordinates x1,y1,x2,y2.""" return self._create('oval', args, kw) def create_polygon(self, *args, **kw): """Create polygon with coordinates x1,y1,...,xn,yn.""" return self._create('polygon', args, kw) def create_rectangle(self, *args, **kw): """Create rectangle with coordinates x1,y1,x2,y2.""" return self._create('rectangle', args, kw) def create_text(self, *args, **kw): """Create text with coordinates x1,y1.""" return self._create('text', args, kw) def create_window(self, *args, **kw): """Create window with coordinates x1,y1,x2,y2.""" return self._create('window', args, kw) def dchars(self, *args): """Delete characters of text items identified by tag or id in ARGS (possibly several times) from FIRST to LAST character (including).""" self.tk.call((self._w, 'dchars') + args) def delete(self, *args): """Delete items identified by all tag or ids contained in ARGS.""" self.tk.call((self._w, 'delete') + args) def dtag(self, *args): """Delete tag or id given as last arguments in ARGS from items identified by first argument in ARGS.""" self.tk.call((self._w, 'dtag') + args) def find(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'find') + args)) or () def find_above(self, tagOrId): """Return items above TAGORID.""" return self.find('above', tagOrId) def find_all(self): """Return all items.""" return self.find('all') def find_below(self, tagOrId): """Return all items below TAGORID.""" return self.find('below', tagOrId) def find_closest(self, x, y, halo=None, start=None): """Return item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closest). If START is specified the next below this tag is taken.""" return self.find('closest', x, y, halo, start) def find_enclosed(self, x1, y1, x2, y2): """Return all items in rectangle defined by X1,Y1,X2,Y2.""" return self.find('enclosed', x1, y1, x2, y2) def find_overlapping(self, x1, y1, x2, y2): """Return all items which overlap the rectangle defined by X1,Y1,X2,Y2.""" return self.find('overlapping', x1, y1, x2, y2) def find_withtag(self, tagOrId): """Return all items with TAGORID.""" return self.find('withtag', tagOrId) def focus(self, *args): """Set focus to the first item specified in ARGS.""" return self.tk.call((self._w, 'focus') + args) def gettags(self, *args): """Return tags associated with the first item specified in ARGS.""" return self.tk.splitlist( self.tk.call((self._w, 'gettags') + args)) def icursor(self, *args): """Set cursor at position POS in the item identified by TAGORID. In ARGS TAGORID must be first.""" self.tk.call((self._w, 'icursor') + args) def index(self, *args): """Return position of cursor as integer in item specified in ARGS.""" return self.tk.getint(self.tk.call((self._w, 'index') + args)) def insert(self, *args): """Insert TEXT in item TAGORID at position POS. ARGS must be TAGORID POS TEXT.""" self.tk.call((self._w, 'insert') + args) def itemcget(self, tagOrId, option): """Return the resource value for an OPTION for item TAGORID.""" return self.tk.call( (self._w, 'itemcget') + (tagOrId, '-'+option)) def itemconfigure(self, tagOrId, cnf=None, **kw): """Configure resources of an item TAGORID. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method without arguments. """ return self._configure(('itemconfigure', tagOrId), cnf, kw) itemconfig = itemconfigure # lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift, # so the preferred name for them is tag_lower, tag_raise # (similar to tag_bind, and similar to the Text widget); # unfortunately can't delete the old ones yet (maybe in 1.6) def tag_lower(self, *args): """Lower an item TAGORID given in ARGS (optional below another item).""" self.tk.call((self._w, 'lower') + args) lower = tag_lower def move(self, *args): """Move an item TAGORID given in ARGS.""" self.tk.call((self._w, 'move') + args) def moveto(self, tagOrId, x='', y=''): """Move the items given by TAGORID in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag TAGORID is located at position (X,Y). X and Y may be the empty string, in which case the corresponding coordinate will be unchanged. All items matching TAGORID remain in the same positions relative to each other.""" self.tk.call(self._w, 'moveto', tagOrId, x, y) def postscript(self, cnf={}, **kw): """Print the contents of the canvas to a postscript file. Valid options: colormap, colormode, file, fontmap, height, pageanchor, pageheight, pagewidth, pagex, pagey, rotate, width, x, y.""" return self.tk.call((self._w, 'postscript') + self._options(cnf, kw)) def tag_raise(self, *args): """Raise an item TAGORID given in ARGS (optional above another item).""" self.tk.call((self._w, 'raise') + args) lift = tkraise = tag_raise def scale(self, *args): """Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE.""" self.tk.call((self._w, 'scale') + args) def scan_mark(self, x, y): """Remember the current X, Y coordinates.""" self.tk.call(self._w, 'scan', 'mark', x, y) def scan_dragto(self, x, y, gain=10): """Adjust the view of the canvas to GAIN times the difference between X and Y and the coordinates given in scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x, y, gain) def select_adjust(self, tagOrId, index): """Adjust the end of the selection near the cursor of an item TAGORID to index.""" self.tk.call(self._w, 'select', 'adjust', tagOrId, index) def select_clear(self): """Clear the selection if it is in this widget.""" self.tk.call(self._w, 'select', 'clear') def select_from(self, tagOrId, index): """Set the fixed end of a selection in item TAGORID to INDEX.""" self.tk.call(self._w, 'select', 'from', tagOrId, index) def select_item(self): """Return the item which has the selection.""" return self.tk.call(self._w, 'select', 'item') or None def select_to(self, tagOrId, index): """Set the variable end of a selection in item TAGORID to INDEX.""" self.tk.call(self._w, 'select', 'to', tagOrId, index) def type(self, tagOrId): """Return the type of the item TAGORID.""" return self.tk.call(self._w, 'type', tagOrId) or None class Checkbutton(Widget): """Checkbutton widget which is either in on- or off-state.""" def __init__(self, master=None, cnf={}, **kw): """Construct a checkbutton widget with the parent MASTER. Valid resource names: activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor, disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, offvalue, onvalue, padx, pady, relief, selectcolor, selectimage, state, takefocus, text, textvariable, underline, variable, width, wraplength.""" Widget.__init__(self, master, 'checkbutton', cnf, kw) def deselect(self): """Put the button in off-state.""" self.tk.call(self._w, 'deselect') def flash(self): """Flash the button.""" self.tk.call(self._w, 'flash') def invoke(self): """Toggle the button and invoke a command if given as resource.""" return self.tk.call(self._w, 'invoke') def select(self): """Put the button in on-state.""" self.tk.call(self._w, 'select') def toggle(self): """Toggle the button.""" self.tk.call(self._w, 'toggle') class Entry(Widget, XView): """Entry widget which allows displaying simple text.""" def __init__(self, master=None, cnf={}, **kw): """Construct an entry widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, cursor, exportselection, fg, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, invalidcommand, invcmd, justify, relief, selectbackground, selectborderwidth, selectforeground, show, state, takefocus, textvariable, validate, validatecommand, vcmd, width, xscrollcommand.""" Widget.__init__(self, master, 'entry', cnf, kw) def delete(self, first, last=None): """Delete text from FIRST to LAST (not included).""" self.tk.call(self._w, 'delete', first, last) def get(self): """Return the text.""" return self.tk.call(self._w, 'get') def icursor(self, index): """Insert cursor at INDEX.""" self.tk.call(self._w, 'icursor', index) def index(self, index): """Return position of cursor.""" return self.tk.getint(self.tk.call( self._w, 'index', index)) def insert(self, index, string): """Insert STRING at INDEX.""" self.tk.call(self._w, 'insert', index, string) def scan_mark(self, x): """Remember the current X, Y coordinates.""" self.tk.call(self._w, 'scan', 'mark', x) def scan_dragto(self, x): """Adjust the view of the canvas to 10 times the difference between X and Y and the coordinates given in scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x) def selection_adjust(self, index): """Adjust the end of the selection near the cursor to INDEX.""" self.tk.call(self._w, 'selection', 'adjust', index) select_adjust = selection_adjust def selection_clear(self): """Clear the selection if it is in this widget.""" self.tk.call(self._w, 'selection', 'clear') select_clear = selection_clear def selection_from(self, index): """Set the fixed end of a selection to INDEX.""" self.tk.call(self._w, 'selection', 'from', index) select_from = selection_from def selection_present(self): """Return True if there are characters selected in the entry, False otherwise.""" return self.tk.getboolean( self.tk.call(self._w, 'selection', 'present')) select_present = selection_present def selection_range(self, start, end): """Set the selection from START to END (not included).""" self.tk.call(self._w, 'selection', 'range', start, end) select_range = selection_range def selection_to(self, index): """Set the variable end of a selection to INDEX.""" self.tk.call(self._w, 'selection', 'to', index) select_to = selection_to class Frame(Widget): """Frame widget which may contain other widgets and can have a 3D border.""" def __init__(self, master=None, cnf={}, **kw): """Construct a frame widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.""" cnf = _cnfmerge((cnf, kw)) extra = () if 'class_' in cnf: extra = ('-class', cnf['class_']) del cnf['class_'] elif 'class' in cnf: extra = ('-class', cnf['class']) del cnf['class'] Widget.__init__(self, master, 'frame', cnf, {}, extra) class Label(Widget): """Label widget which can display text and bitmaps.""" def __init__(self, master=None, cnf={}, **kw): """Construct a label widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground, highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS height, state, width """ Widget.__init__(self, master, 'label', cnf, kw) class Listbox(Widget, XView, YView): """Listbox widget which can display a list of strings.""" def __init__(self, master=None, cnf={}, **kw): """Construct a listbox widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, cursor, exportselection, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, relief, selectbackground, selectborderwidth, selectforeground, selectmode, setgrid, takefocus, width, xscrollcommand, yscrollcommand, listvariable.""" Widget.__init__(self, master, 'listbox', cnf, kw) def activate(self, index): """Activate item identified by INDEX.""" self.tk.call(self._w, 'activate', index) def bbox(self, index): """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the item identified by the given index.""" return self._getints(self.tk.call(self._w, 'bbox', index)) or None def curselection(self): """Return the indices of currently selected item.""" return self._getints(self.tk.call(self._w, 'curselection')) or () def delete(self, first, last=None): """Delete items from FIRST to LAST (included).""" self.tk.call(self._w, 'delete', first, last) def get(self, first, last=None): """Get list of items from FIRST to LAST (included).""" if last is not None: return self.tk.splitlist(self.tk.call( self._w, 'get', first, last)) else: return self.tk.call(self._w, 'get', first) def index(self, index): """Return index of item identified with INDEX.""" i = self.tk.call(self._w, 'index', index) if i == 'none': return None return self.tk.getint(i) def insert(self, index, *elements): """Insert ELEMENTS at INDEX.""" self.tk.call((self._w, 'insert', index) + elements) def nearest(self, y): """Get index of item which is nearest to y coordinate Y.""" return self.tk.getint(self.tk.call( self._w, 'nearest', y)) def scan_mark(self, x, y): """Remember the current X, Y coordinates.""" self.tk.call(self._w, 'scan', 'mark', x, y) def scan_dragto(self, x, y): """Adjust the view of the listbox to 10 times the difference between X and Y and the coordinates given in scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x, y) def see(self, index): """Scroll such that INDEX is visible.""" self.tk.call(self._w, 'see', index) def selection_anchor(self, index): """Set the fixed end oft the selection to INDEX.""" self.tk.call(self._w, 'selection', 'anchor', index) select_anchor = selection_anchor def selection_clear(self, first, last=None): """Clear the selection from FIRST to LAST (included).""" self.tk.call(self._w, 'selection', 'clear', first, last) select_clear = selection_clear def selection_includes(self, index): """Return True if INDEX is part of the selection.""" return self.tk.getboolean(self.tk.call( self._w, 'selection', 'includes', index)) select_includes = selection_includes def selection_set(self, first, last=None): """Set the selection from FIRST to LAST (included) without changing the currently selected elements.""" self.tk.call(self._w, 'selection', 'set', first, last) select_set = selection_set def size(self): """Return the number of elements in the listbox.""" return self.tk.getint(self.tk.call(self._w, 'size')) def itemcget(self, index, option): """Return the resource value for an ITEM and an OPTION.""" return self.tk.call( (self._w, 'itemcget') + (index, '-'+option)) def itemconfigure(self, index, cnf=None, **kw): """Configure resources of an ITEM. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method without arguments. Valid resource names: background, bg, foreground, fg, selectbackground, selectforeground.""" return self._configure(('itemconfigure', index), cnf, kw) itemconfig = itemconfigure class Menu(Widget): """Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.""" def __init__(self, master=None, cnf={}, **kw): """Construct menu widget with the parent MASTER. Valid resource names: activebackground, activeborderwidth, activeforeground, background, bd, bg, borderwidth, cursor, disabledforeground, fg, font, foreground, postcommand, relief, selectcolor, takefocus, tearoff, tearoffcommand, title, type.""" Widget.__init__(self, master, 'menu', cnf, kw) def tk_popup(self, x, y, entry=""): """Post the menu at position X,Y with entry ENTRY.""" self.tk.call('tk_popup', self._w, x, y, entry) def activate(self, index): """Activate entry at INDEX.""" self.tk.call(self._w, 'activate', index) def add(self, itemType, cnf={}, **kw): """Internal function.""" self.tk.call((self._w, 'add', itemType) + self._options(cnf, kw)) def add_cascade(self, cnf={}, **kw): """Add hierarchical menu item.""" self.add('cascade', cnf or kw) def add_checkbutton(self, cnf={}, **kw): """Add checkbutton menu item.""" self.add('checkbutton', cnf or kw) def add_command(self, cnf={}, **kw): """Add command menu item.""" self.add('command', cnf or kw) def add_radiobutton(self, cnf={}, **kw): """Addd radio menu item.""" self.add('radiobutton', cnf or kw) def add_separator(self, cnf={}, **kw): """Add separator.""" self.add('separator', cnf or kw) def insert(self, index, itemType, cnf={}, **kw): """Internal function.""" self.tk.call((self._w, 'insert', index, itemType) + self._options(cnf, kw)) def insert_cascade(self, index, cnf={}, **kw): """Add hierarchical menu item at INDEX.""" self.insert(index, 'cascade', cnf or kw) def insert_checkbutton(self, index, cnf={}, **kw): """Add checkbutton menu item at INDEX.""" self.insert(index, 'checkbutton', cnf or kw) def insert_command(self, index, cnf={}, **kw): """Add command menu item at INDEX.""" self.insert(index, 'command', cnf or kw) def insert_radiobutton(self, index, cnf={}, **kw): """Addd radio menu item at INDEX.""" self.insert(index, 'radiobutton', cnf or kw) def insert_separator(self, index, cnf={}, **kw): """Add separator at INDEX.""" self.insert(index, 'separator', cnf or kw) def delete(self, index1, index2=None): """Delete menu items between INDEX1 and INDEX2 (included).""" if index2 is None: index2 = index1 num_index1, num_index2 = self.index(index1), self.index(index2) if (num_index1 is None) or (num_index2 is None): num_index1, num_index2 = 0, -1 for i in range(num_index1, num_index2 + 1): if 'command' in self.entryconfig(i): c = str(self.entrycget(i, 'command')) if c: self.deletecommand(c) self.tk.call(self._w, 'delete', index1, index2) def entrycget(self, index, option): """Return the resource value of a menu item for OPTION at INDEX.""" return self.tk.call(self._w, 'entrycget', index, '-' + option) def entryconfigure(self, index, cnf=None, **kw): """Configure a menu item at INDEX.""" return self._configure(('entryconfigure', index), cnf, kw) entryconfig = entryconfigure def index(self, index): """Return the index of a menu item identified by INDEX.""" i = self.tk.call(self._w, 'index', index) if i == 'none': return None return self.tk.getint(i) def invoke(self, index): """Invoke a menu item identified by INDEX and execute the associated command.""" return self.tk.call(self._w, 'invoke', index) def post(self, x, y): """Display a menu at position X,Y.""" self.tk.call(self._w, 'post', x, y) def type(self, index): """Return the type of the menu item at INDEX.""" return self.tk.call(self._w, 'type', index) def unpost(self): """Unmap a menu.""" self.tk.call(self._w, 'unpost') def xposition(self, index): # new in Tk 8.5 """Return the x-position of the leftmost pixel of the menu item at INDEX.""" return self.tk.getint(self.tk.call(self._w, 'xposition', index)) def yposition(self, index): """Return the y-position of the topmost pixel of the menu item at INDEX.""" return self.tk.getint(self.tk.call( self._w, 'yposition', index)) class Menubutton(Widget): """Menubutton widget, obsolete since Tk8.0.""" def __init__(self, master=None, cnf={}, **kw): Widget.__init__(self, master, 'menubutton', cnf, kw) class Message(Widget): """Message widget to display multiline text. Obsolete since Label does it too.""" def __init__(self, master=None, cnf={}, **kw): Widget.__init__(self, master, 'message', cnf, kw) class Radiobutton(Widget): """Radiobutton widget which shows only one of several buttons in on-state.""" def __init__(self, master=None, cnf={}, **kw): """Construct a radiobutton widget with the parent MASTER. Valid resource names: activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor, disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, padx, pady, relief, selectcolor, selectimage, state, takefocus, text, textvariable, underline, value, variable, width, wraplength.""" Widget.__init__(self, master, 'radiobutton', cnf, kw) def deselect(self): """Put the button in off-state.""" self.tk.call(self._w, 'deselect') def flash(self): """Flash the button.""" self.tk.call(self._w, 'flash') def invoke(self): """Toggle the button and invoke a command if given as resource.""" return self.tk.call(self._w, 'invoke') def select(self): """Put the button in on-state.""" self.tk.call(self._w, 'select') class Scale(Widget): """Scale widget which can display a numerical scale.""" def __init__(self, master=None, cnf={}, **kw): """Construct a scale widget with the parent MASTER. Valid resource names: activebackground, background, bigincrement, bd, bg, borderwidth, command, cursor, digits, fg, font, foreground, from, highlightbackground, highlightcolor, highlightthickness, label, length, orient, relief, repeatdelay, repeatinterval, resolution, showvalue, sliderlength, sliderrelief, state, takefocus, tickinterval, to, troughcolor, variable, width.""" Widget.__init__(self, master, 'scale', cnf, kw) def get(self): """Get the current value as integer or float.""" value = self.tk.call(self._w, 'get') try: return self.tk.getint(value) except (ValueError, TypeError, TclError): return self.tk.getdouble(value) def set(self, value): """Set the value to VALUE.""" self.tk.call(self._w, 'set', value) def coords(self, value=None): """Return a tuple (X,Y) of the point along the centerline of the trough that corresponds to VALUE or the current value if None is given.""" return self._getints(self.tk.call(self._w, 'coords', value)) def identify(self, x, y): """Return where the point X,Y lies. Valid return values are "slider", "though1" and "though2".""" return self.tk.call(self._w, 'identify', x, y) class Scrollbar(Widget): """Scrollbar widget which displays a slider at a certain position.""" def __init__(self, master=None, cnf={}, **kw): """Construct a scrollbar widget with the parent MASTER. Valid resource names: activebackground, activerelief, background, bd, bg, borderwidth, command, cursor, elementborderwidth, highlightbackground, highlightcolor, highlightthickness, jump, orient, relief, repeatdelay, repeatinterval, takefocus, troughcolor, width.""" Widget.__init__(self, master, 'scrollbar', cnf, kw) def activate(self, index=None): """Marks the element indicated by index as active. The only index values understood by this method are "arrow1", "slider", or "arrow2". If any other value is specified then no element of the scrollbar will be active. If index is not specified, the method returns the name of the element that is currently active, or None if no element is active.""" return self.tk.call(self._w, 'activate', index) or None def delta(self, deltax, deltay): """Return the fractional change of the scrollbar setting if it would be moved by DELTAX or DELTAY pixels.""" return self.tk.getdouble( self.tk.call(self._w, 'delta', deltax, deltay)) def fraction(self, x, y): """Return the fractional value which corresponds to a slider position of X,Y.""" return self.tk.getdouble(self.tk.call(self._w, 'fraction', x, y)) def identify(self, x, y): """Return the element under position X,Y as one of "arrow1","slider","arrow2" or "".""" return self.tk.call(self._w, 'identify', x, y) def get(self): """Return the current fractional values (upper and lower end) of the slider position.""" return self._getdoubles(self.tk.call(self._w, 'get')) def set(self, first, last): """Set the fractional values of the slider position (upper and lower ends as value between 0 and 1).""" self.tk.call(self._w, 'set', first, last) class Text(Widget, XView, YView): """Text widget which can display text in various forms.""" def __init__(self, master=None, cnf={}, **kw): """Construct a text widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, padx, pady, relief, selectbackground, selectborderwidth, selectforeground, setgrid, takefocus, xscrollcommand, yscrollcommand, WIDGET-SPECIFIC OPTIONS autoseparators, height, maxundo, spacing1, spacing2, spacing3, state, tabs, undo, width, wrap, """ Widget.__init__(self, master, 'text', cnf, kw) def bbox(self, index): """Return a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the given index.""" return self._getints( self.tk.call(self._w, 'bbox', index)) or None def compare(self, index1, op, index2): """Return whether between index INDEX1 and index INDEX2 the relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=.""" return self.tk.getboolean(self.tk.call( self._w, 'compare', index1, op, index2)) def count(self, index1, index2, *args): # new in Tk 8.5 """Counts the number of relevant things between the two indices. If index1 is after index2, the result will be a negative number (and this holds for each of the possible options). The actual items which are counted depends on the options given by args. The result is a list of integers, one for the result of each counting option given. Valid counting options are "chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels" and "ypixels". There is an additional possible option "update", which if given then all subsequent options ensure that any possible out of date information is recalculated.""" args = ['-%s' % arg for arg in args if not arg.startswith('-')] args += [index1, index2] res = self.tk.call(self._w, 'count', *args) or None if res is not None and len(args) <= 3: return (res, ) else: return res def debug(self, boolean=None): """Turn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.""" if boolean is None: return self.tk.getboolean(self.tk.call(self._w, 'debug')) self.tk.call(self._w, 'debug', boolean) def delete(self, index1, index2=None): """Delete the characters between INDEX1 and INDEX2 (not included).""" self.tk.call(self._w, 'delete', index1, index2) def dlineinfo(self, index): """Return tuple (x,y,width,height,baseline) giving the bounding box and baseline position of the visible part of the line containing the character at INDEX.""" return self._getints(self.tk.call(self._w, 'dlineinfo', index)) def dump(self, index1, index2=None, command=None, **kw): """Return the contents of the widget between index1 and index2. The type of contents returned in filtered based on the keyword parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are given and true, then the corresponding items are returned. The result is a list of triples of the form (key, value, index). If none of the keywords are true then 'all' is used by default. If the 'command' argument is given, it is called once for each element of the list of triples, with the values of each triple serving as the arguments to the function. In this case the list is not returned.""" args = [] func_name = None result = None if not command: # Never call the dump command without the -command flag, since the # output could involve Tcl quoting and would be a pain to parse # right. Instead just set the command to build a list of triples # as if we had done the parsing. result = [] def append_triple(key, value, index, result=result): result.append((key, value, index)) command = append_triple try: if not isinstance(command, str): func_name = command = self._register(command) args += ["-command", command] for key in kw: if kw[key]: args.append("-" + key) args.append(index1) if index2: args.append(index2) self.tk.call(self._w, "dump", *args) return result finally: if func_name: self.deletecommand(func_name) ## new in tk8.4 def edit(self, *args): """Internal method This method controls the undo mechanism and the modified flag. The exact behavior of the command depends on the option argument that follows the edit argument. The following forms of the command are currently supported: edit_modified, edit_redo, edit_reset, edit_separator and edit_undo """ return self.tk.call(self._w, 'edit', *args) def edit_modified(self, arg=None): """Get or Set the modified flag If arg is not specified, returns the modified flag of the widget. The insert, delete, edit undo and edit redo commands or the user can set or clear the modified flag. If boolean is specified, sets the modified flag of the widget to arg. """ return self.edit("modified", arg) def edit_redo(self): """Redo the last undone edit When the undo option is true, reapplies the last undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the undo option is false. """ return self.edit("redo") def edit_reset(self): """Clears the undo and redo stacks """ return self.edit("reset") def edit_separator(self): """Inserts a separator (boundary) on the undo stack. Does nothing when the undo option is false """ return self.edit("separator") def edit_undo(self): """Undoes the last edit action If the undo option is true. An edit action is defined as all the insert and delete commands that are recorded on the undo stack in between two separators. Generates an error when the undo stack is empty. Does nothing when the undo option is false """ return self.edit("undo") def get(self, index1, index2=None): """Return the text from INDEX1 to INDEX2 (not included).""" return self.tk.call(self._w, 'get', index1, index2) # (Image commands are new in 8.0) def image_cget(self, index, option): """Return the value of OPTION of an embedded image at INDEX.""" if option[:1] != "-": option = "-" + option if option[-1:] == "_": option = option[:-1] return self.tk.call(self._w, "image", "cget", index, option) def image_configure(self, index, cnf=None, **kw): """Configure an embedded image at INDEX.""" return self._configure(('image', 'configure', index), cnf, kw) def image_create(self, index, cnf={}, **kw): """Create an embedded image at INDEX.""" return self.tk.call( self._w, "image", "create", index, *self._options(cnf, kw)) def image_names(self): """Return all names of embedded images in this widget.""" return self.tk.call(self._w, "image", "names") def index(self, index): """Return the index in the form line.char for INDEX.""" return str(self.tk.call(self._w, 'index', index)) def insert(self, index, chars, *args): """Insert CHARS before the characters at INDEX. An additional tag can be given in ARGS. Additional CHARS and tags can follow in ARGS.""" self.tk.call((self._w, 'insert', index, chars) + args) def mark_gravity(self, markName, direction=None): """Change the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT). Return the current value if None is given for DIRECTION.""" return self.tk.call( (self._w, 'mark', 'gravity', markName, direction)) def mark_names(self): """Return all mark names.""" return self.tk.splitlist(self.tk.call( self._w, 'mark', 'names')) def mark_set(self, markName, index): """Set mark MARKNAME before the character at INDEX.""" self.tk.call(self._w, 'mark', 'set', markName, index) def mark_unset(self, *markNames): """Delete all marks in MARKNAMES.""" self.tk.call((self._w, 'mark', 'unset') + markNames) def mark_next(self, index): """Return the name of the next mark after INDEX.""" return self.tk.call(self._w, 'mark', 'next', index) or None def mark_previous(self, index): """Return the name of the previous mark before INDEX.""" return self.tk.call(self._w, 'mark', 'previous', index) or None def peer_create(self, newPathName, cnf={}, **kw): # new in Tk 8.5 """Creates a peer text widget with the given newPathName, and any optional standard configuration options. By default the peer will have the same start and end line as the parent widget, but these can be overridden with the standard configuration options.""" self.tk.call(self._w, 'peer', 'create', newPathName, *self._options(cnf, kw)) def peer_names(self): # new in Tk 8.5 """Returns a list of peers of this widget (this does not include the widget itself).""" return self.tk.splitlist(self.tk.call(self._w, 'peer', 'names')) def replace(self, index1, index2, chars, *args): # new in Tk 8.5 """Replaces the range of characters between index1 and index2 with the given characters and tags specified by args. See the method insert for some more information about args, and the method delete for information about the indices.""" self.tk.call(self._w, 'replace', index1, index2, chars, *args) def scan_mark(self, x, y): """Remember the current X, Y coordinates.""" self.tk.call(self._w, 'scan', 'mark', x, y) def scan_dragto(self, x, y): """Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x, y) def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None, elide=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" args = [self._w, 'search'] if forwards: args.append('-forwards') if backwards: args.append('-backwards') if exact: args.append('-exact') if regexp: args.append('-regexp') if nocase: args.append('-nocase') if elide: args.append('-elide') if count: args.append('-count'); args.append(count) if pattern and pattern[0] == '-': args.append('--') args.append(pattern) args.append(index) if stopindex: args.append(stopindex) return str(self.tk.call(tuple(args))) def see(self, index): """Scroll such that the character at INDEX is visible.""" self.tk.call(self._w, 'see', index) def tag_add(self, tagName, index1, *args): """Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS. Additional pairs of indices may follow in ARGS.""" self.tk.call( (self._w, 'tag', 'add', tagName, index1) + args) def tag_unbind(self, tagName, sequence, funcid=None): """Unbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.""" self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '') if funcid: self.deletecommand(funcid) def tag_bind(self, tagName, sequence, func, add=None): """Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.""" return self._bind((self._w, 'tag', 'bind', tagName), sequence, func, add) def tag_cget(self, tagName, option): """Return the value of OPTION for tag TAGNAME.""" if option[:1] != '-': option = '-' + option if option[-1:] == '_': option = option[:-1] return self.tk.call(self._w, 'tag', 'cget', tagName, option) def tag_configure(self, tagName, cnf=None, **kw): """Configure a tag TAGNAME.""" return self._configure(('tag', 'configure', tagName), cnf, kw) tag_config = tag_configure def tag_delete(self, *tagNames): """Delete all tags in TAGNAMES.""" self.tk.call((self._w, 'tag', 'delete') + tagNames) def tag_lower(self, tagName, belowThis=None): """Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.""" self.tk.call(self._w, 'tag', 'lower', tagName, belowThis) def tag_names(self, index=None): """Return a list of all tag names.""" return self.tk.splitlist( self.tk.call(self._w, 'tag', 'names', index)) def tag_nextrange(self, tagName, index1, index2=None): """Return a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched forward from INDEX1.""" return self.tk.splitlist(self.tk.call( self._w, 'tag', 'nextrange', tagName, index1, index2)) def tag_prevrange(self, tagName, index1, index2=None): """Return a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched backwards from INDEX1.""" return self.tk.splitlist(self.tk.call( self._w, 'tag', 'prevrange', tagName, index1, index2)) def tag_raise(self, tagName, aboveThis=None): """Change the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.""" self.tk.call( self._w, 'tag', 'raise', tagName, aboveThis) def tag_ranges(self, tagName): """Return a list of ranges of text which have tag TAGNAME.""" return self.tk.splitlist(self.tk.call( self._w, 'tag', 'ranges', tagName)) def tag_remove(self, tagName, index1, index2=None): """Remove tag TAGNAME from all characters between INDEX1 and INDEX2.""" self.tk.call( self._w, 'tag', 'remove', tagName, index1, index2) def window_cget(self, index, option): """Return the value of OPTION of an embedded window at INDEX.""" if option[:1] != '-': option = '-' + option if option[-1:] == '_': option = option[:-1] return self.tk.call(self._w, 'window', 'cget', index, option) def window_configure(self, index, cnf=None, **kw): """Configure an embedded window at INDEX.""" return self._configure(('window', 'configure', index), cnf, kw) window_config = window_configure def window_create(self, index, cnf={}, **kw): """Create a window at INDEX.""" self.tk.call( (self._w, 'window', 'create', index) + self._options(cnf, kw)) def window_names(self): """Return all names of embedded windows in this widget.""" return self.tk.splitlist( self.tk.call(self._w, 'window', 'names')) def yview_pickplace(self, *what): """Obsolete function, use see.""" self.tk.call((self._w, 'yview', '-pickplace') + what) class _setit: """Internal class. It wraps the command in the widget OptionMenu.""" def __init__(self, var, value, callback=None): self.__value = value self.__var = var self.__callback = callback def __call__(self, *args): self.__var.set(self.__value) if self.__callback: self.__callback(self.__value, *args) class OptionMenu(Menubutton): """OptionMenu which allows the user to select a value from a menu.""" def __init__(self, master, variable, value, *values, **kwargs): """Construct an optionmenu widget with the parent MASTER, with the resource textvariable set to VARIABLE, the initially selected value VALUE, the other menu values VALUES and an additional keyword argument command.""" kw = {"borderwidth": 2, "textvariable": variable, "indicatoron": 1, "relief": RAISED, "anchor": "c", "highlightthickness": 2} Widget.__init__(self, master, "menubutton", kw) self.widgetName = 'tk_optionMenu' menu = self.__menu = Menu(self, name="menu", tearoff=0) self.menuname = menu._w # 'command' is the only supported keyword callback = kwargs.get('command') if 'command' in kwargs: del kwargs['command'] if kwargs: raise TclError('unknown option -'+next(iter(kwargs))) menu.add_command(label=value, command=_setit(variable, value, callback)) for v in values: menu.add_command(label=v, command=_setit(variable, v, callback)) self["menu"] = menu def __getitem__(self, name): if name == 'menu': return self.__menu return Widget.__getitem__(self, name) def destroy(self): """Destroy this widget and the associated menu.""" Menubutton.destroy(self) self.__menu = None class Image: """Base class for images.""" _last_id = 0 def __init__(self, imgtype, name=None, cnf={}, master=None, **kw): self.name = None if not master: master = _get_default_root('create image') self.tk = getattr(master, 'tk', master) if not name: Image._last_id += 1 name = "pyimage%r" % (Image._last_id,) # tk itself would use image if kw and cnf: cnf = _cnfmerge((cnf, kw)) elif kw: cnf = kw options = () for k, v in cnf.items(): if callable(v): v = self._register(v) options = options + ('-'+k, v) self.tk.call(('image', 'create', imgtype, name,) + options) self.name = name def __str__(self): return self.name def __del__(self): if self.name: try: self.tk.call('image', 'delete', self.name) except TclError: # May happen if the root was destroyed pass def __setitem__(self, key, value): self.tk.call(self.name, 'configure', '-'+key, value) def __getitem__(self, key): return self.tk.call(self.name, 'configure', '-'+key) def configure(self, **kw): """Configure the image.""" res = () for k, v in _cnfmerge(kw).items(): if v is not None: if k[-1] == '_': k = k[:-1] if callable(v): v = self._register(v) res = res + ('-'+k, v) self.tk.call((self.name, 'config') + res) config = configure def height(self): """Return the height of the image.""" return self.tk.getint( self.tk.call('image', 'height', self.name)) def type(self): """Return the type of the image, e.g. "photo" or "bitmap".""" return self.tk.call('image', 'type', self.name) def width(self): """Return the width of the image.""" return self.tk.getint( self.tk.call('image', 'width', self.name)) class PhotoImage(Image): """Widget which can display images in PGM, PPM, GIF, PNG format.""" def __init__(self, name=None, cnf={}, master=None, **kw): """Create an image with NAME. Valid resource names: data, format, file, gamma, height, palette, width.""" Image.__init__(self, 'photo', name, cnf, master, **kw) def blank(self): """Display a transparent image.""" self.tk.call(self.name, 'blank') def cget(self, option): """Return the value of OPTION.""" return self.tk.call(self.name, 'cget', '-' + option) # XXX config def __getitem__(self, key): return self.tk.call(self.name, 'cget', '-' + key) # XXX copy -from, -to, ...? def copy(self): """Return a new PhotoImage with the same image as this widget.""" destImage = PhotoImage(master=self.tk) self.tk.call(destImage, 'copy', self.name) return destImage def zoom(self, x, y=''): """Return a new PhotoImage with the same image as this widget but zoom it with a factor of x in the X direction and y in the Y direction. If y is not given, the default value is the same as x. """ destImage = PhotoImage(master=self.tk) if y=='': y=x self.tk.call(destImage, 'copy', self.name, '-zoom',x,y) return destImage def subsample(self, x, y=''): """Return a new PhotoImage based on the same image as this widget but use only every Xth or Yth pixel. If y is not given, the default value is the same as x. """ destImage = PhotoImage(master=self.tk) if y=='': y=x self.tk.call(destImage, 'copy', self.name, '-subsample',x,y) return destImage def get(self, x, y): """Return the color (red, green, blue) of the pixel at X,Y.""" return self.tk.call(self.name, 'get', x, y) def put(self, data, to=None): """Put row formatted colors to image starting from position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))""" args = (self.name, 'put', data) if to: if to[0] == '-to': to = to[1:] args = args + ('-to',) + tuple(to) self.tk.call(args) # XXX read def write(self, filename, format=None, from_coords=None): """Write image to file FILENAME in FORMAT starting from position FROM_COORDS.""" args = (self.name, 'write', filename) if format: args = args + ('-format', format) if from_coords: args = args + ('-from',) + tuple(from_coords) self.tk.call(args) def transparency_get(self, x, y): """Return True if the pixel at x,y is transparent.""" return self.tk.getboolean(self.tk.call( self.name, 'transparency', 'get', x, y)) def transparency_set(self, x, y, boolean): """Set the transparency of the pixel at x,y.""" self.tk.call(self.name, 'transparency', 'set', x, y, boolean) class BitmapImage(Image): """Widget which can display images in XBM format.""" def __init__(self, name=None, cnf={}, master=None, **kw): """Create a bitmap with NAME. Valid resource names: background, data, file, foreground, maskdata, maskfile.""" Image.__init__(self, 'bitmap', name, cnf, master, **kw) def image_names(): tk = _get_default_root('use image_names()').tk return tk.splitlist(tk.call('image', 'names')) def image_types(): tk = _get_default_root('use image_types()').tk return tk.splitlist(tk.call('image', 'types')) class Spinbox(Widget, XView): """spinbox widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a spinbox widget with the parent MASTER. STANDARD OPTIONS activebackground, background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, justify, relief, repeatdelay, repeatinterval, selectbackground, selectborderwidth selectforeground, takefocus, textvariable xscrollcommand. WIDGET-SPECIFIC OPTIONS buttonbackground, buttoncursor, buttondownrelief, buttonuprelief, command, disabledbackground, disabledforeground, format, from, invalidcommand, increment, readonlybackground, state, to, validate, validatecommand values, width, wrap, """ Widget.__init__(self, master, 'spinbox', cnf, kw) def bbox(self, index): """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the character given by index. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window. """ return self._getints(self.tk.call(self._w, 'bbox', index)) or None def delete(self, first, last=None): """Delete one or more elements of the spinbox. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last isn't specified it defaults to first+1, i.e. a single character is deleted. This command returns an empty string. """ return self.tk.call(self._w, 'delete', first, last) def get(self): """Returns the spinbox's string""" return self.tk.call(self._w, 'get') def icursor(self, index): """Alter the position of the insertion cursor. The insertion cursor will be displayed just before the character given by index. Returns an empty string """ return self.tk.call(self._w, 'icursor', index) def identify(self, x, y): """Returns the name of the widget at position x, y Return value is one of: none, buttondown, buttonup, entry """ return self.tk.call(self._w, 'identify', x, y) def index(self, index): """Returns the numerical index corresponding to index """ return self.tk.call(self._w, 'index', index) def insert(self, index, s): """Insert string s at index Returns an empty string. """ return self.tk.call(self._w, 'insert', index, s) def invoke(self, element): """Causes the specified element to be invoked The element could be buttondown or buttonup triggering the action associated with it. """ return self.tk.call(self._w, 'invoke', element) def scan(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'scan') + args)) or () def scan_mark(self, x): """Records x and the current view in the spinbox window; used in conjunction with later scan dragto commands. Typically this command is associated with a mouse button press in the widget. It returns an empty string. """ return self.scan("mark", x) def scan_dragto(self, x): """Compute the difference between the given x argument and the x argument to the last scan mark command It then adjusts the view left or right by 10 times the difference in x-coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the spinbox at high speed through the window. The return value is an empty string. """ return self.scan("dragto", x) def selection(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'selection') + args)) or () def selection_adjust(self, index): """Locate the end of the selection nearest to the character given by index, Then adjust that end of the selection to be at index (i.e including but not going beyond index). The other end of the selection is made the anchor point for future select to commands. If the selection isn't currently in the spinbox, then a new selection is created to include the characters between index and the most recent selection anchor point, inclusive. """ return self.selection("adjust", index) def selection_clear(self): """Clear the selection If the selection isn't in this widget then the command has no effect. """ return self.selection("clear") def selection_element(self, element=None): """Sets or gets the currently selected element. If a spinbutton element is specified, it will be displayed depressed. """ return self.tk.call(self._w, 'selection', 'element', element) def selection_from(self, index): """Set the fixed end of a selection to INDEX.""" self.selection('from', index) def selection_present(self): """Return True if there are characters selected in the spinbox, False otherwise.""" return self.tk.getboolean( self.tk.call(self._w, 'selection', 'present')) def selection_range(self, start, end): """Set the selection from START to END (not included).""" self.selection('range', start, end) def selection_to(self, index): """Set the variable end of a selection to INDEX.""" self.selection('to', index) ########################################################################### class LabelFrame(Widget): """labelframe widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a labelframe widget with the parent MASTER. STANDARD OPTIONS borderwidth, cursor, font, foreground, highlightbackground, highlightcolor, highlightthickness, padx, pady, relief, takefocus, text WIDGET-SPECIFIC OPTIONS background, class, colormap, container, height, labelanchor, labelwidget, visual, width """ Widget.__init__(self, master, 'labelframe', cnf, kw) ######################################################################## class PanedWindow(Widget): """panedwindow widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a panedwindow widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, height, orient, relief, width WIDGET-SPECIFIC OPTIONS handlepad, handlesize, opaqueresize, sashcursor, sashpad, sashrelief, sashwidth, showhandle, """ Widget.__init__(self, master, 'panedwindow', cnf, kw) def add(self, child, **kw): """Add a child widget to the panedwindow in a new pane. The child argument is the name of the child widget followed by pairs of arguments that specify how to manage the windows. The possible options and values are the ones accepted by the paneconfigure method. """ self.tk.call((self._w, 'add', child) + self._options(kw)) def remove(self, child): """Remove the pane containing child from the panedwindow All geometry management options for child will be forgotten. """ self.tk.call(self._w, 'forget', child) forget = remove def identify(self, x, y): """Identify the panedwindow component at point x, y If the point is over a sash or a sash handle, the result is a two element list containing the index of the sash or handle, and a word indicating whether it is over a sash or a handle, such as {0 sash} or {2 handle}. If the point is over any other part of the panedwindow, the result is an empty list. """ return self.tk.call(self._w, 'identify', x, y) def proxy(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'proxy') + args)) or () def proxy_coord(self): """Return the x and y pair of the most recent proxy location """ return self.proxy("coord") def proxy_forget(self): """Remove the proxy from the display. """ return self.proxy("forget") def proxy_place(self, x, y): """Place the proxy at the given x and y coordinates. """ return self.proxy("place", x, y) def sash(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'sash') + args)) or () def sash_coord(self, index): """Return the current x and y pair for the sash given by index. Index must be an integer between 0 and 1 less than the number of panes in the panedwindow. The coordinates given are those of the top left corner of the region containing the sash. pathName sash dragto index x y This command computes the difference between the given coordinates and the coordinates given to the last sash coord command for the given sash. It then moves that sash the computed difference. The return value is the empty string. """ return self.sash("coord", index) def sash_mark(self, index): """Records x and y for the sash given by index; Used in conjunction with later dragto commands to move the sash. """ return self.sash("mark", index) def sash_place(self, index, x, y): """Place the sash given by index at the given coordinates """ return self.sash("place", index, x, y) def panecget(self, child, option): """Query a management option for window. Option may be any value allowed by the paneconfigure subcommand """ return self.tk.call( (self._w, 'panecget') + (child, '-'+option)) def paneconfigure(self, tagOrId, cnf=None, **kw): """Query or modify the management options for window. If no option is specified, returns a list describing all of the available options for pathName. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. The following options are supported: after window Insert the window after the window specified. window should be the name of a window already managed by pathName. before window Insert the window before the window specified. window should be the name of a window already managed by pathName. height size Specify a height for the window. The height will be the outer dimension of the window including its border, if any. If size is an empty string, or if -height is not specified, then the height requested internally by the window will be used initially; the height may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. minsize n Specifies that the size of the window cannot be made less than n. This constraint only affects the size of the widget in the paned dimension -- the x dimension for horizontal panedwindows, the y dimension for vertical panedwindows. May be any value accepted by Tk_GetPixels. padx n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the X-direction. The value may have any of the forms accepted by Tk_GetPixels. pady n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the Y-direction. The value may have any of the forms accepted by Tk_GetPixels. sticky style If a window's pane is larger than the requested dimensions of the window, this option may be used to position (or stretch) the window within its pane. Style is a string that contains zero or more of the characters n, s, e or w. The string can optionally contains spaces or commas, but they are ignored. Each letter refers to a side (north, south, east, or west) that the window will "stick" to. If both n and s (or e and w) are specified, the window will be stretched to fill the entire height (or width) of its cavity. width size Specify a width for the window. The width will be the outer dimension of the window including its border, if any. If size is an empty string, or if -width is not specified, then the width requested internally by the window will be used initially; the width may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. """ if cnf is None and not kw: return self._getconfigure(self._w, 'paneconfigure', tagOrId) if isinstance(cnf, str) and not kw: return self._getconfigure1( self._w, 'paneconfigure', tagOrId, '-'+cnf) self.tk.call((self._w, 'paneconfigure', tagOrId) + self._options(cnf, kw)) paneconfig = paneconfigure def panes(self): """Returns an ordered list of the child panes.""" return self.tk.splitlist(self.tk.call(self._w, 'panes')) # Test: def _test(): root = Tk() text = "This is Tcl/Tk version %s" % TclVersion text += "\nThis should be a cedilla: \xe7" label = Label(root, text=text) label.pack() test = Button(root, text="Click me!", command=lambda root=root: root.test.configure( text="[%s]" % root.test['text'])) test.pack() root.test = test quit = Button(root, text="QUIT", command=root.destroy) quit.pack() # The following three commands are needed so the window pops # up on top on Windows... root.iconify() root.update() root.deiconify() root.mainloop() if __name__ == '__main__': _test() PK!a `A A colorchooser.pynu[# tk common color chooser dialogue # # this module provides an interface to the native color dialogue # available in Tk 4.2 and newer. # # written by Fredrik Lundh, May 1997 # # fixed initialcolor handling in August 1998 # from tkinter.commondialog import Dialog class Chooser(Dialog): """Create a dialog for the tk_chooseColor command. Args: master: The master widget for this dialog. If not provided, defaults to options['parent'] (if defined). options: Dictionary of options for the tk_chooseColor call. initialcolor: Specifies the selected color when the dialog is first displayed. This can be a tk color string or a 3-tuple of ints in the range (0, 255) for an RGB triplet. parent: The parent window of the color dialog. The color dialog is displayed on top of this. title: A string for the title of the dialog box. """ command = "tk_chooseColor" def _fixoptions(self): """Ensure initialcolor is a tk color string. Convert initialcolor from a RGB triplet to a color string. """ try: color = self.options["initialcolor"] if isinstance(color, tuple): # Assume an RGB triplet. self.options["initialcolor"] = "#%02x%02x%02x" % color except KeyError: pass def _fixresult(self, widget, result): """Adjust result returned from call to tk_chooseColor. Return both an RGB tuple of ints in the range (0, 255) and the tk color string in the form #rrggbb. """ # Result can be many things: an empty tuple, an empty string, or # a _tkinter.Tcl_Obj, so this somewhat weird check handles that. if not result or not str(result): return None, None # canceled # To simplify application code, the color chooser returns # an RGB tuple together with the Tk color string. r, g, b = widget.winfo_rgb(result) return (r//256, g//256, b//256), str(result) # # convenience stuff def askcolor(color=None, **options): """Display dialog window for selection of a color. Convenience wrapper for the Chooser class. Displays the color chooser dialog with color as the initial value. """ if color: options = options.copy() options["initialcolor"] = color return Chooser(**options).show() # -------------------------------------------------------------------- # test stuff if __name__ == "__main__": print("color", askcolor()) PK!_ Y-,-,tix.pynu[# Tix.py -- Tix widget wrappers. # # For Tix, see http://tix.sourceforge.net # # - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995. # based on an idea of Jean-Marc Lugrin (lugrin@ms.com) # # NOTE: In order to minimize changes to Tkinter.py, some of the code here # (TixWidget.__init__) has been taken from Tkinter (Widget.__init__) # and will break if there are major changes in Tkinter. # # The Tix widgets are represented by a class hierarchy in python with proper # inheritance of base classes. # # As a result after creating a 'w = StdButtonBox', I can write # w.ok['text'] = 'Who Cares' # or w.ok['bg'] = w['bg'] # or even w.ok.invoke() # etc. # # Compare the demo tixwidgets.py to the original Tcl program and you will # appreciate the advantages. # import os import tkinter from tkinter import * from tkinter import _cnfmerge import _tkinter # If this fails your Python may not be configured for Tk # Some more constants (for consistency with Tkinter) WINDOW = 'window' TEXT = 'text' STATUS = 'status' IMMEDIATE = 'immediate' IMAGE = 'image' IMAGETEXT = 'imagetext' BALLOON = 'balloon' AUTO = 'auto' ACROSSTOP = 'acrosstop' # A few useful constants for the Grid widget ASCII = 'ascii' CELL = 'cell' COLUMN = 'column' DECREASING = 'decreasing' INCREASING = 'increasing' INTEGER = 'integer' MAIN = 'main' MAX = 'max' REAL = 'real' ROW = 'row' S_REGION = 's-region' X_REGION = 'x-region' Y_REGION = 'y-region' # Some constants used by Tkinter dooneevent() TCL_DONT_WAIT = 1 << 1 TCL_WINDOW_EVENTS = 1 << 2 TCL_FILE_EVENTS = 1 << 3 TCL_TIMER_EVENTS = 1 << 4 TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore # liable to break. # Could probably add this to Tkinter.Misc class tixCommand: """The tix commands provide access to miscellaneous elements of Tix's internal state and the Tix application context. Most of the information manipulated by these commands pertains to the application as a whole, or to a screen or display, rather than to a particular window. This is a mixin class, assumed to be mixed to Tkinter.Tk that supports the self.tk.call method. """ def tix_addbitmapdir(self, directory): """Tix maintains a list of directories under which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap directory is $TIX_LIBRARY/bitmaps. The addbitmapdir command adds directory into this list. By using this command, the image files of an applications can also be located using the tix_getimage or tix_getbitmap command. """ return self.tk.call('tix', 'addbitmapdir', directory) def tix_cget(self, option): """Returns the current value of the configuration option given by option. Option may be any of the options described in the CONFIGURATION OPTIONS section. """ return self.tk.call('tix', 'cget', option) def tix_configure(self, cnf=None, **kw): """Query or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the configuration options. """ # Copied from Tkinter.py if kw: cnf = _cnfmerge((cnf, kw)) elif cnf: cnf = _cnfmerge(cnf) if cnf is None: return self._getconfigure('tix', 'configure') if isinstance(cnf, str): return self._getconfigure1('tix', 'configure', '-'+cnf) return self.tk.call(('tix', 'configure') + self._options(cnf)) def tix_filedialog(self, dlgclass=None): """Returns the file selection dialog that may be shared among different calls from this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix_filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are tix FileSelectDialog or tixExFileSelectDialog. """ if dlgclass is not None: return self.tk.call('tix', 'filedialog', dlgclass) else: return self.tk.call('tix', 'filedialog') def tix_getbitmap(self, name): """Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (see the tix_addbitmapdir command above). By using tix_getbitmap, you can avoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets. """ return self.tk.call('tix', 'getbitmap', name) def tix_getimage(self, name): """Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directories (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix_ getimage, you can avoid hard coding the pathnames of the image files in your application. When successful, this command returns the name of the newly created image, which can be used to configure the -image option of the Tk and Tix widgets. """ return self.tk.call('tix', 'getimage', name) def tix_option_get(self, name): """Gets the options maintained by the Tix scheme mechanism. Available options include: active_bg active_fg bg bold_font dark1_bg dark1_fg dark2_bg dark2_fg disabled_fg fg fixed_font font inactive_bg inactive_fg input1_bg input2_bg italic_font light1_bg light1_fg light2_bg light2_fg menu_font output1_bg output2_bg select_bg select_fg selector """ # could use self.tk.globalgetvar('tixOption', name) return self.tk.call('tix', 'option', 'get', name) def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None): """Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetoptions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to reset the priority level of the Tk options set by the Tix schemes. Because of the way Tk handles the X option database, after Tix has been has imported and inited, it is not possible to reset the color schemes and font sets using the tix config command. Instead, the tix_resetoptions command must be used. """ if newScmPrio is not None: return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio) else: return self.tk.call('tix', 'resetoptions', newScheme, newFontSet) class Tk(tkinter.Tk, tixCommand): """Toplevel widget of Tix which represents mostly the main window of an application. It has an associated Tcl interpreter.""" def __init__(self, screenName=None, baseName=None, className='Tix'): tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, tcl/tix8.1/pkgIndex.tcl should have # 'load {} Tix' # If it's dynamic under Unix, tcl/tix8.1/pkgIndex.tcl should have # 'load libtix8.1.8.3.so Tix' self.tk.eval('package require Tix') def destroy(self): # For safety, remove the delete_window binding before destroy self.protocol("WM_DELETE_WINDOW", "") tkinter.Tk.destroy(self) # The Tix 'tixForm' geometry manager class Form: """The Tix Form geometry manager Widgets can be arranged by specifying attachments to other widgets. See Tix documentation for complete details""" def config(self, cnf={}, **kw): self.tk.call('tixForm', self._w, *self._options(cnf, kw)) form = config def __setitem__(self, key, value): Form.form(self, {key: value}) def check(self): return self.tk.call('tixForm', 'check', self._w) def forget(self): self.tk.call('tixForm', 'forget', self._w) def grid(self, xsize=0, ysize=0): if (not xsize) and (not ysize): x = self.tk.call('tixForm', 'grid', self._w) y = self.tk.splitlist(x) z = () for x in y: z = z + (self.tk.getint(x),) return z return self.tk.call('tixForm', 'grid', self._w, xsize, ysize) def info(self, option=None): if not option: return self.tk.call('tixForm', 'info', self._w) if option[0] != '-': option = '-' + option return self.tk.call('tixForm', 'info', self._w, option) def slaves(self): return [self._nametowidget(x) for x in self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w))] tkinter.Widget.__bases__ = tkinter.Widget.__bases__ + (Form,) class TixWidget(tkinter.Widget): """A TixWidget class is used to package all (or most) Tix widgets. Widget initialization is extended in two ways: 1) It is possible to give a list of options which must be part of the creation command (so called Tix 'static' options). These cannot be given as a 'config' command later. 2) It is possible to give the name of an existing TK widget. These are child widgets created automatically by a Tix mega-widget. The Tk call to create these widgets is therefore bypassed in TixWidget.__init__ Both options are for use by subclasses only. """ def __init__ (self, master=None, widgetName=None, static_options=None, cnf={}, kw={}): # Merge keywords and dictionary arguments if kw: cnf = _cnfmerge((cnf, kw)) else: cnf = _cnfmerge(cnf) # Move static options into extra. static_options must be # a list of keywords (or None). extra=() # 'options' is always a static option if static_options: static_options.append('options') else: static_options = ['options'] for k,v in list(cnf.items()): if k in static_options: extra = extra + ('-' + k, v) del cnf[k] self.widgetName = widgetName Widget._setup(self, master, cnf) # If widgetName is None, this is a dummy creation call where the # corresponding Tk widget has already been created by Tix if widgetName: self.tk.call(widgetName, self._w, *extra) # Non-static options - to be done via a 'config' command if cnf: Widget.config(self, cnf) # Dictionary to hold subwidget names for easier access. We can't # use the children list because the public Tix names may not be the # same as the pathname component self.subwidget_list = {} # We set up an attribute access function so that it is possible to # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello' # when w is a StdButtonBox. # We can even do w.ok.invoke() because w.ok is subclassed from the # Button class if you go through the proper constructors def __getattr__(self, name): if name in self.subwidget_list: return self.subwidget_list[name] raise AttributeError(name) def set_silent(self, value): """Set a variable without calling its action routine""" self.tk.call('tixSetSilent', self._w, value) def subwidget(self, name): """Return the named subwidget (which must have been created by the sub-class).""" n = self._subwidget_name(name) if not n: raise TclError("Subwidget " + name + " not child of " + self._name) # Remove header of name and leading dot n = n[len(self._w)+1:] return self._nametowidget(n) def subwidgets_all(self): """Return all subwidgets.""" names = self._subwidget_names() if not names: return [] retlist = [] for name in names: name = name[len(self._w)+1:] try: retlist.append(self._nametowidget(name)) except: # some of the widgets are unknown e.g. border in LabelFrame pass return retlist def _subwidget_name(self,name): """Get a subwidget name (returns a String, not a Widget !)""" try: return self.tk.call(self._w, 'subwidget', name) except TclError: return None def _subwidget_names(self): """Return the name of all subwidgets.""" try: x = self.tk.call(self._w, 'subwidgets', '-all') return self.tk.splitlist(x) except TclError: return None def config_all(self, option, value): """Set configuration options for all subwidgets (and self).""" if option == '': return elif not isinstance(option, str): option = repr(option) if not isinstance(value, str): value = repr(value) names = self._subwidget_names() for name in names: self.tk.call(name, 'configure', '-' + option, value) # These are missing from Tkinter def image_create(self, imgtype, cnf={}, master=None, **kw): if not master: master = self if kw and cnf: cnf = _cnfmerge((cnf, kw)) elif kw: cnf = kw options = () for k, v in cnf.items(): if callable(v): v = self._register(v) options = options + ('-'+k, v) return master.tk.call(('image', 'create', imgtype,) + options) def image_delete(self, imgname): try: self.tk.call('image', 'delete', imgname) except TclError: # May happen if the root was destroyed pass # Subwidgets are child widgets created automatically by mega-widgets. # In python, we have to create these subwidgets manually to mirror their # existence in Tk/Tix. class TixSubWidget(TixWidget): """Subwidget class. This is used to mirror child widgets automatically created by Tix/Tk as part of a mega-widget in Python (which is not informed of this)""" def __init__(self, master, name, destroy_physically=1, check_intermediate=1): if check_intermediate: path = master._subwidget_name(name) try: path = path[len(master._w)+1:] plist = path.split('.') except: plist = [] if not check_intermediate: # immediate descendant TixWidget.__init__(self, master, None, None, {'name' : name}) else: # Ensure that the intermediate widgets exist parent = master for i in range(len(plist) - 1): n = '.'.join(plist[:i+1]) try: w = master._nametowidget(n) parent = w except KeyError: # Create the intermediate widget parent = TixSubWidget(parent, plist[i], destroy_physically=0, check_intermediate=0) # The Tk widget name is in plist, not in name if plist: name = plist[-1] TixWidget.__init__(self, parent, None, None, {'name' : name}) self.destroy_physically = destroy_physically def destroy(self): # For some widgets e.g., a NoteBook, when we call destructors, # we must be careful not to destroy the frame widget since this # also destroys the parent NoteBook thus leading to an exception # in Tkinter when it finally calls Tcl to destroy the NoteBook for c in list(self.children.values()): c.destroy() if self._name in self.master.children: del self.master.children[self._name] if self._name in self.master.subwidget_list: del self.master.subwidget_list[self._name] if self.destroy_physically: # This is bypassed only for a few widgets self.tk.call('destroy', self._w) # Useful class to create a display style - later shared by many items. # Contributed by Steffen Kremser class DisplayStyle: """DisplayStyle - handle configuration options shared by (multiple) Display Items""" def __init__(self, itemtype, cnf={}, *, master=None, **kw): if not master: if 'refwindow' in kw: master = kw['refwindow'] elif 'refwindow' in cnf: master = cnf['refwindow'] else: master = tkinter._get_default_root('create display style') self.tk = master.tk self.stylename = self.tk.call('tixDisplayStyle', itemtype, *self._options(cnf,kw) ) def __str__(self): return self.stylename def _options(self, cnf, kw): if kw and cnf: cnf = _cnfmerge((cnf, kw)) elif kw: cnf = kw opts = () for k, v in cnf.items(): opts = opts + ('-'+k, v) return opts def delete(self): self.tk.call(self.stylename, 'delete') def __setitem__(self,key,value): self.tk.call(self.stylename, 'configure', '-%s'%key, value) def config(self, cnf={}, **kw): return self._getconfigure( self.stylename, 'configure', *self._options(cnf,kw)) def __getitem__(self,key): return self.tk.call(self.stylename, 'cget', '-%s'%key) ###################################################### ### The Tix Widget classes - in alphabetical order ### ###################################################### class Balloon(TixWidget): """Balloon help widget. Subwidget Class --------- ----- label Label message Message""" # FIXME: It should inherit -superclass tixShell def __init__(self, master=None, cnf={}, **kw): # static seem to be -installcolormap -initwait -statusbar -cursor static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor'] TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label', destroy_physically=0) self.subwidget_list['message'] = _dummyLabel(self, 'message', destroy_physically=0) def bind_widget(self, widget, cnf={}, **kw): """Bind balloon widget to another. One balloon widget may be bound to several widgets at the same time""" self.tk.call(self._w, 'bind', widget._w, *self._options(cnf, kw)) def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) class ButtonBox(TixWidget): """ButtonBox - A container for pushbuttons. Subwidgets are the buttons added with the add method. """ def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixButtonBox', ['orientation', 'options'], cnf, kw) def add(self, name, cnf={}, **kw): """Add a button with given name to box.""" btn = self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = _dummyButton(self, name) return btn def invoke(self, name): if name in self.subwidget_list: self.tk.call(self._w, 'invoke', name) class ComboBox(TixWidget): """ComboBox - an Entry field with a dropdown menu. The user can select a choice by either typing in the entry subwidget or selecting from the listbox subwidget. Subwidget Class --------- ----- entry Entry arrow Button slistbox ScrolledListBox tick Button cross Button : present if created with the fancy option""" # FIXME: It should inherit -superclass tixLabelWidget def __init__ (self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixComboBox', ['editable', 'dropdown', 'fancy', 'options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, 'slistbox') try: self.subwidget_list['tick'] = _dummyButton(self, 'tick') self.subwidget_list['cross'] = _dummyButton(self, 'cross') except TypeError: # unavailable when -fancy not specified pass # align def add_history(self, str): self.tk.call(self._w, 'addhistory', str) def append_history(self, str): self.tk.call(self._w, 'appendhistory', str) def insert(self, index, str): self.tk.call(self._w, 'insert', index, str) def pick(self, index): self.tk.call(self._w, 'pick', index) class Control(TixWidget): """Control - An entry field with value change arrows. The user can adjust the value by pressing the two arrow buttons or by entering the value directly into the entry. The new value will be checked against the user-defined upper and lower limits. Subwidget Class --------- ----- incr Button decr Button entry Entry label Label""" # FIXME: It should inherit -superclass tixLabelWidget def __init__ (self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw) self.subwidget_list['incr'] = _dummyButton(self, 'incr') self.subwidget_list['decr'] = _dummyButton(self, 'decr') self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') def decrement(self): self.tk.call(self._w, 'decr') def increment(self): self.tk.call(self._w, 'incr') def invoke(self): self.tk.call(self._w, 'invoke') def update(self): self.tk.call(self._w, 'update') class DirList(TixWidget): """DirList - displays a list view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb Scrollbar""" # FIXME: It should inherit -superclass tixScrolledHList def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def chdir(self, dir): self.tk.call(self._w, 'chdir', dir) class DirTree(TixWidget): """DirTree - Directory Listing in a hierarchical view. Displays a tree view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb Scrollbar""" # FIXME: It should inherit -superclass tixScrolledHList def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def chdir(self, dir): self.tk.call(self._w, 'chdir', dir) class DirSelectBox(TixWidget): """DirSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBox""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw) self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') class ExFileSelectBox(TixWidget): """ExFileSelectBox - MS Windows style file select box. It provides a convenient method for the user to select files. Subwidget Class --------- ----- cancel Button ok Button hidden Checkbutton types ComboBox dir ComboBox file ComboBox dirlist ScrolledListBox filelist ScrolledListBox""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw) self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') self.subwidget_list['types'] = _dummyComboBox(self, 'types') self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') self.subwidget_list['file'] = _dummyComboBox(self, 'file') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') def filter(self): self.tk.call(self._w, 'filter') def invoke(self): self.tk.call(self._w, 'invoke') # Should inherit from a Dialog class class DirSelectDialog(TixWidget): """The DirSelectDialog widget presents the directories in the file system in a dialog window. The user can use this dialog window to navigate through the file system to select the desired directory. Subwidgets Class ---------- ----- dirbox DirSelectDialog""" # FIXME: It should inherit -superclass tixDialogShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirSelectDialog', ['options'], cnf, kw) self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox') # cancel and ok buttons are missing def popup(self): self.tk.call(self._w, 'popup') def popdown(self): self.tk.call(self._w, 'popdown') # Should inherit from a Dialog class class ExFileSelectDialog(TixWidget): """ExFileSelectDialog - MS Windows style file select dialog. It provides a convenient method for the user to select files. Subwidgets Class ---------- ----- fsbox ExFileSelectBox""" # FIXME: It should inherit -superclass tixDialogShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixExFileSelectDialog', ['options'], cnf, kw) self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox') def popup(self): self.tk.call(self._w, 'popup') def popdown(self): self.tk.call(self._w, 'popdown') class FileSelectBox(TixWidget): """ExFileSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBox""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw) self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') def apply_filter(self): # name of subwidget is same as command self.tk.call(self._w, 'filter') def invoke(self): self.tk.call(self._w, 'invoke') # Should inherit from a Dialog class class FileSelectDialog(TixWidget): """FileSelectDialog - Motif style file select dialog. Subwidgets Class ---------- ----- btns StdButtonBox fsbox FileSelectBox""" # FIXME: It should inherit -superclass tixStdDialogShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixFileSelectDialog', ['options'], cnf, kw) self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns') self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox') def popup(self): self.tk.call(self._w, 'popup') def popdown(self): self.tk.call(self._w, 'popdown') class FileEntry(TixWidget): """FileEntry - Entry field with button that invokes a FileSelectDialog. The user can type in the filename manually. Alternatively, the user can press the button widget that sits next to the entry, which will bring up a file selection dialog. Subwidgets Class ---------- ----- button Button entry Entry""" # FIXME: It should inherit -superclass tixLabelWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixFileEntry', ['dialogtype', 'options'], cnf, kw) self.subwidget_list['button'] = _dummyButton(self, 'button') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') def invoke(self): self.tk.call(self._w, 'invoke') def file_dialog(self): # FIXME: return python object pass class HList(TixWidget, XView, YView): """HList - Hierarchy display widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixHList', ['columns', 'options'], cnf, kw) def add(self, entry, cnf={}, **kw): return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw)) def add_child(self, parent=None, cnf={}, **kw): if not parent: parent = '' return self.tk.call( self._w, 'addchild', parent, *self._options(cnf, kw)) def anchor_set(self, entry): self.tk.call(self._w, 'anchor', 'set', entry) def anchor_clear(self): self.tk.call(self._w, 'anchor', 'clear') def column_width(self, col=0, width=None, chars=None): if not chars: return self.tk.call(self._w, 'column', 'width', col, width) else: return self.tk.call(self._w, 'column', 'width', col, '-char', chars) def delete_all(self): self.tk.call(self._w, 'delete', 'all') def delete_entry(self, entry): self.tk.call(self._w, 'delete', 'entry', entry) def delete_offsprings(self, entry): self.tk.call(self._w, 'delete', 'offsprings', entry) def delete_siblings(self, entry): self.tk.call(self._w, 'delete', 'siblings', entry) def dragsite_set(self, index): self.tk.call(self._w, 'dragsite', 'set', index) def dragsite_clear(self): self.tk.call(self._w, 'dragsite', 'clear') def dropsite_set(self, index): self.tk.call(self._w, 'dropsite', 'set', index) def dropsite_clear(self): self.tk.call(self._w, 'dropsite', 'clear') def header_create(self, col, cnf={}, **kw): self.tk.call(self._w, 'header', 'create', col, *self._options(cnf, kw)) def header_configure(self, col, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'header', 'configure', col) self.tk.call(self._w, 'header', 'configure', col, *self._options(cnf, kw)) def header_cget(self, col, opt): return self.tk.call(self._w, 'header', 'cget', col, opt) def header_exists(self, col): # A workaround to Tix library bug (issue #25464). # The documented command is "exists", but only erroneous "exist" is # accepted. return self.tk.getboolean(self.tk.call(self._w, 'header', 'exist', col)) header_exist = header_exists def header_delete(self, col): self.tk.call(self._w, 'header', 'delete', col) def header_size(self, col): return self.tk.call(self._w, 'header', 'size', col) def hide_entry(self, entry): self.tk.call(self._w, 'hide', 'entry', entry) def indicator_create(self, entry, cnf={}, **kw): self.tk.call( self._w, 'indicator', 'create', entry, *self._options(cnf, kw)) def indicator_configure(self, entry, cnf={}, **kw): if cnf is None: return self._getconfigure( self._w, 'indicator', 'configure', entry) self.tk.call( self._w, 'indicator', 'configure', entry, *self._options(cnf, kw)) def indicator_cget(self, entry, opt): return self.tk.call(self._w, 'indicator', 'cget', entry, opt) def indicator_exists(self, entry): return self.tk.call (self._w, 'indicator', 'exists', entry) def indicator_delete(self, entry): self.tk.call(self._w, 'indicator', 'delete', entry) def indicator_size(self, entry): return self.tk.call(self._w, 'indicator', 'size', entry) def info_anchor(self): return self.tk.call(self._w, 'info', 'anchor') def info_bbox(self, entry): return self._getints( self.tk.call(self._w, 'info', 'bbox', entry)) or None def info_children(self, entry=None): c = self.tk.call(self._w, 'info', 'children', entry) return self.tk.splitlist(c) def info_data(self, entry): return self.tk.call(self._w, 'info', 'data', entry) def info_dragsite(self): return self.tk.call(self._w, 'info', 'dragsite') def info_dropsite(self): return self.tk.call(self._w, 'info', 'dropsite') def info_exists(self, entry): return self.tk.call(self._w, 'info', 'exists', entry) def info_hidden(self, entry): return self.tk.call(self._w, 'info', 'hidden', entry) def info_next(self, entry): return self.tk.call(self._w, 'info', 'next', entry) def info_parent(self, entry): return self.tk.call(self._w, 'info', 'parent', entry) def info_prev(self, entry): return self.tk.call(self._w, 'info', 'prev', entry) def info_selection(self): c = self.tk.call(self._w, 'info', 'selection') return self.tk.splitlist(c) def item_cget(self, entry, col, opt): return self.tk.call(self._w, 'item', 'cget', entry, col, opt) def item_configure(self, entry, col, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'item', 'configure', entry, col) self.tk.call(self._w, 'item', 'configure', entry, col, *self._options(cnf, kw)) def item_create(self, entry, col, cnf={}, **kw): self.tk.call( self._w, 'item', 'create', entry, col, *self._options(cnf, kw)) def item_exists(self, entry, col): return self.tk.call(self._w, 'item', 'exists', entry, col) def item_delete(self, entry, col): self.tk.call(self._w, 'item', 'delete', entry, col) def entrycget(self, entry, opt): return self.tk.call(self._w, 'entrycget', entry, opt) def entryconfigure(self, entry, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'entryconfigure', entry) self.tk.call(self._w, 'entryconfigure', entry, *self._options(cnf, kw)) def nearest(self, y): return self.tk.call(self._w, 'nearest', y) def see(self, entry): self.tk.call(self._w, 'see', entry) def selection_clear(self, cnf={}, **kw): self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) def selection_includes(self, entry): return self.tk.call(self._w, 'selection', 'includes', entry) def selection_set(self, first, last=None): self.tk.call(self._w, 'selection', 'set', first, last) def show_entry(self, entry): return self.tk.call(self._w, 'show', 'entry', entry) class InputOnly(TixWidget): """InputOnly - Invisible widget. Unix only. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) class LabelEntry(TixWidget): """LabelEntry - Entry field with label. Packages an entry widget and a label into one mega widget. It can be used to simplify the creation of ``entry-form'' type of interface. Subwidgets Class ---------- ----- label Label entry Entry""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelEntry', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') class LabelFrame(TixWidget): """LabelFrame - Labelled Frame container. Packages a frame widget and a label into one mega widget. To create widgets inside a LabelFrame widget, one creates the new widgets relative to the frame subwidget and manage them inside the frame subwidget. Subwidgets Class ---------- ----- label Label frame Frame""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelFrame', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['frame'] = _dummyFrame(self, 'frame') class ListNoteBook(TixWidget): """A ListNoteBook widget is very similar to the TixNoteBook widget: it can be used to display many windows in a limited space using a notebook metaphor. The notebook is divided into a stack of pages (windows). At one time only one of these pages can be shown. The user can navigate through these pages by choosing the name of the desired page in the hlist subwidget.""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw) # Is this necessary? It's not an exposed subwidget in Tix. self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane', destroy_physically=0) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'shlist') def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name) return self.subwidget_list[name] def page(self, name): return self.subwidget(name) def pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.splitlist(self.tk.call(self._w, 'pages')) ret = [] for x in names: ret.append(self.subwidget(x)) return ret def raise_page(self, name): # raise is a python keyword self.tk.call(self._w, 'raise', name) class Meter(TixWidget): """The Meter widget can be used to show the progress of a background job which may take a long time to execute. """ def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixMeter', ['options'], cnf, kw) class NoteBook(TixWidget): """NoteBook - Multi-page container widget (tabbed notebook metaphor). Subwidgets Class ---------- ----- nbframe NoteBookFrame page widgets added dynamically with the add method""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw) self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe', destroy_physically=0) def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name) return self.subwidget_list[name] def delete(self, name): self.tk.call(self._w, 'delete', name) self.subwidget_list[name].destroy() del self.subwidget_list[name] def page(self, name): return self.subwidget(name) def pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.splitlist(self.tk.call(self._w, 'pages')) ret = [] for x in names: ret.append(self.subwidget(x)) return ret def raise_page(self, name): # raise is a python keyword self.tk.call(self._w, 'raise', name) def raised(self): return self.tk.call(self._w, 'raised') class NoteBookFrame(TixWidget): # FIXME: This is dangerous to expose to be called on its own. pass class OptionMenu(TixWidget): """OptionMenu - creates a menu button of options. Subwidget Class --------- ----- menubutton Menubutton menu Menu""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw) self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') self.subwidget_list['menu'] = _dummyMenu(self, 'menu') def add_command(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', 'command', name, *self._options(cnf, kw)) def add_separator(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', 'separator', name, *self._options(cnf, kw)) def delete(self, name): self.tk.call(self._w, 'delete', name) def disable(self, name): self.tk.call(self._w, 'disable', name) def enable(self, name): self.tk.call(self._w, 'enable', name) class PanedWindow(TixWidget): """PanedWindow - Multi-pane container widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.The user changes the sizes of the panes by dragging the resize handle between two panes. Subwidgets Class ---------- ----- g/p widgets added dynamically with the add method.""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw) # add delete forget panecget paneconfigure panes setsize def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name, check_intermediate=0) return self.subwidget_list[name] def delete(self, name): self.tk.call(self._w, 'delete', name) self.subwidget_list[name].destroy() del self.subwidget_list[name] def forget(self, name): self.tk.call(self._w, 'forget', name) def panecget(self, entry, opt): return self.tk.call(self._w, 'panecget', entry, opt) def paneconfigure(self, entry, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'paneconfigure', entry) self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw)) def panes(self): names = self.tk.splitlist(self.tk.call(self._w, 'panes')) return [self.subwidget(x) for x in names] class PopupMenu(TixWidget): """PopupMenu widget can be used as a replacement of the tk_popup command. The advantage of the Tix PopupMenu widget is it requires less application code to manipulate. Subwidgets Class ---------- ----- menubutton Menubutton menu Menu""" # FIXME: It should inherit -superclass tixShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw) self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') self.subwidget_list['menu'] = _dummyMenu(self, 'menu') def bind_widget(self, widget): self.tk.call(self._w, 'bind', widget._w) def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) def post_widget(self, widget, x, y): self.tk.call(self._w, 'post', widget._w, x, y) class ResizeHandle(TixWidget): """Internal widget to draw resize handles on Scrolled widgets.""" def __init__(self, master, cnf={}, **kw): # There seems to be a Tix bug rejecting the configure method # Let's try making the flags -static flags = ['options', 'command', 'cursorfg', 'cursorbg', 'handlesize', 'hintcolor', 'hintwidth', 'x', 'y'] # In fact, x y height width are configurable TixWidget.__init__(self, master, 'tixResizeHandle', flags, cnf, kw) def attach_widget(self, widget): self.tk.call(self._w, 'attachwidget', widget._w) def detach_widget(self, widget): self.tk.call(self._w, 'detachwidget', widget._w) def hide(self, widget): self.tk.call(self._w, 'hide', widget._w) def show(self, widget): self.tk.call(self._w, 'show', widget._w) class ScrolledHList(TixWidget): """ScrolledHList - HList with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledListBox(TixWidget): """ScrolledListBox - Listbox with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledText(TixWidget): """ScrolledText - Text with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) self.subwidget_list['text'] = _dummyText(self, 'text') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledTList(TixWidget): """ScrolledTList - TList with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], cnf, kw) self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledWindow(TixWidget): """ScrolledWindow - Window with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) self.subwidget_list['window'] = _dummyFrame(self, 'window') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class Select(TixWidget): """Select - Container of button subwidgets. It can be used to provide radio-box or check-box style of selection options for the user. Subwidgets are buttons added dynamically using the add method.""" # FIXME: It should inherit -superclass tixLabelWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixSelect', ['allowzero', 'radio', 'orientation', 'labelside', 'options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = _dummyButton(self, name) return self.subwidget_list[name] def invoke(self, name): self.tk.call(self._w, 'invoke', name) class Shell(TixWidget): """Toplevel window. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixShell', ['options', 'title'], cnf, kw) class DialogShell(TixWidget): """Toplevel window, with popup popdown and center methods. It tells the window manager that it is a dialog window and should be treated specially. The exact treatment depends on the treatment of the window manager. Subwidgets - None""" # FIXME: It should inherit from Shell def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixDialogShell', ['options', 'title', 'mapped', 'minheight', 'minwidth', 'parent', 'transient'], cnf, kw) def popdown(self): self.tk.call(self._w, 'popdown') def popup(self): self.tk.call(self._w, 'popup') def center(self): self.tk.call(self._w, 'center') class StdButtonBox(TixWidget): """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """ def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixStdButtonBox', ['orientation', 'options'], cnf, kw) self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['apply'] = _dummyButton(self, 'apply') self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['help'] = _dummyButton(self, 'help') def invoke(self, name): if name in self.subwidget_list: self.tk.call(self._w, 'invoke', name) class TList(TixWidget, XView, YView): """TList - Hierarchy display widget which can be used to display data in a tabular format. The list entries of a TList widget are similar to the entries in the Tk listbox widget. The main differences are (1) the TList widget can display the list entries in a two dimensional format and (2) you can use graphical images as well as multiple colors and fonts for the list entries. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw) def active_set(self, index): self.tk.call(self._w, 'active', 'set', index) def active_clear(self): self.tk.call(self._w, 'active', 'clear') def anchor_set(self, index): self.tk.call(self._w, 'anchor', 'set', index) def anchor_clear(self): self.tk.call(self._w, 'anchor', 'clear') def delete(self, from_, to=None): self.tk.call(self._w, 'delete', from_, to) def dragsite_set(self, index): self.tk.call(self._w, 'dragsite', 'set', index) def dragsite_clear(self): self.tk.call(self._w, 'dragsite', 'clear') def dropsite_set(self, index): self.tk.call(self._w, 'dropsite', 'set', index) def dropsite_clear(self): self.tk.call(self._w, 'dropsite', 'clear') def insert(self, index, cnf={}, **kw): self.tk.call(self._w, 'insert', index, *self._options(cnf, kw)) def info_active(self): return self.tk.call(self._w, 'info', 'active') def info_anchor(self): return self.tk.call(self._w, 'info', 'anchor') def info_down(self, index): return self.tk.call(self._w, 'info', 'down', index) def info_left(self, index): return self.tk.call(self._w, 'info', 'left', index) def info_right(self, index): return self.tk.call(self._w, 'info', 'right', index) def info_selection(self): c = self.tk.call(self._w, 'info', 'selection') return self.tk.splitlist(c) def info_size(self): return self.tk.call(self._w, 'info', 'size') def info_up(self, index): return self.tk.call(self._w, 'info', 'up', index) def nearest(self, x, y): return self.tk.call(self._w, 'nearest', x, y) def see(self, index): self.tk.call(self._w, 'see', index) def selection_clear(self, cnf={}, **kw): self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) def selection_includes(self, index): return self.tk.call(self._w, 'selection', 'includes', index) def selection_set(self, first, last=None): self.tk.call(self._w, 'selection', 'set', first, last) class Tree(TixWidget): """Tree - The tixTree widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixTree', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def autosetmode(self): '''This command calls the setmode method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to none. Otherwise, if the entry has any hidden child entries, its mode is set to open; otherwise its mode is set to close.''' self.tk.call(self._w, 'autosetmode') def close(self, entrypath): '''Close the entry given by entryPath if its mode is close.''' self.tk.call(self._w, 'close', entrypath) def getmode(self, entrypath): '''Returns the current mode of the entry given by entryPath.''' return self.tk.call(self._w, 'getmode', entrypath) def open(self, entrypath): '''Open the entry given by entryPath if its mode is open.''' self.tk.call(self._w, 'open', entrypath) def setmode(self, entrypath, mode='none'): '''This command is used to indicate whether the entry given by entryPath has children entries and whether the children are visible. mode must be one of open, close or none. If mode is set to open, a (+) indicator is drawn next the entry. If mode is set to close, a (-) indicator is drawn next the entry. If mode is set to none, no indicators will be drawn for this entry. The default mode is none. The open mode indicates the entry has hidden children and this entry can be opened by the user. The close mode indicates that all the children of the entry are now visible and the entry can be closed by the user.''' self.tk.call(self._w, 'setmode', entrypath, mode) # Could try subclassing Tree for CheckList - would need another arg to init class CheckList(TixWidget): """The CheckList widget displays a list of items to be selected by the user. CheckList acts similarly to the Tk checkbutton or radiobutton widgets, except it is capable of handling many more items than checkbuttons or radiobuttons. """ # FIXME: It should inherit -superclass tixTree def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixCheckList', ['options', 'radio'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def autosetmode(self): '''This command calls the setmode method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to none. Otherwise, if the entry has any hidden child entries, its mode is set to open; otherwise its mode is set to close.''' self.tk.call(self._w, 'autosetmode') def close(self, entrypath): '''Close the entry given by entryPath if its mode is close.''' self.tk.call(self._w, 'close', entrypath) def getmode(self, entrypath): '''Returns the current mode of the entry given by entryPath.''' return self.tk.call(self._w, 'getmode', entrypath) def open(self, entrypath): '''Open the entry given by entryPath if its mode is open.''' self.tk.call(self._w, 'open', entrypath) def getselection(self, mode='on'): '''Returns a list of items whose status matches status. If status is not specified, the list of items in the "on" status will be returned. Mode can be on, off, default''' return self.tk.splitlist(self.tk.call(self._w, 'getselection', mode)) def getstatus(self, entrypath): '''Returns the current status of entryPath.''' return self.tk.call(self._w, 'getstatus', entrypath) def setstatus(self, entrypath, mode='on'): '''Sets the status of entryPath to be status. A bitmap will be displayed next to the entry its status is on, off or default.''' self.tk.call(self._w, 'setstatus', entrypath, mode) ########################################################################### ### The subclassing below is used to instantiate the subwidgets in each ### ### mega widget. This allows us to access their methods directly. ### ########################################################################### class _dummyButton(Button, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyCheckbutton(Checkbutton, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyEntry(Entry, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyFrame(Frame, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyLabel(Label, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyListbox(Listbox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyMenu(Menu, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyMenubutton(Menubutton, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyScrollbar(Scrollbar, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyText(Text, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyScrolledListBox(ScrolledListBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class _dummyHList(HList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyScrolledHList(ScrolledHList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class _dummyTList(TList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyComboBox(ComboBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, ['fancy',destroy_physically]) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, 'slistbox') try: self.subwidget_list['tick'] = _dummyButton(self, 'tick') #cross Button : present if created with the fancy option self.subwidget_list['cross'] = _dummyButton(self, 'cross') except TypeError: # unavailable when -fancy not specified pass class _dummyDirList(DirList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class _dummyDirSelectBox(DirSelectBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') self.subwidget_list['types'] = _dummyComboBox(self, 'types') self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') self.subwidget_list['file'] = _dummyComboBox(self, 'file') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') class _dummyFileSelectBox(FileSelectBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') class _dummyFileComboBox(ComboBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx') class _dummyStdButtonBox(StdButtonBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['apply'] = _dummyButton(self, 'apply') self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['help'] = _dummyButton(self, 'help') class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget): def __init__(self, master, name, destroy_physically=0): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyPanedWindow(PanedWindow, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) ######################## ### Utility Routines ### ######################## #mike Should tixDestroy be exposed as a wrapper? - but not for widgets. def OptionName(widget): '''Returns the qualified path name for the widget. Normally used to set default options for subwidgets. See tixwidgets.py''' return widget.tk.call('tixOptionName', widget._w) # Called with a dictionary argument of the form # {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'} # returns a string which can be used to configure the fsbox file types # in an ExFileSelectBox. i.e., # '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}' def FileTypeList(dict): s = '' for type in dict.keys(): s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' return s # Still to be done: # tixIconView class CObjView(TixWidget): """This file implements the Canvas Object View widget. This is a base class of IconView. It implements automatic placement/adjustment of the scrollbars according to the canvas objects inside the canvas subwidget. The scrollbars are adjusted so that the canvas is just large enough to see all the objects. """ # FIXME: It should inherit -superclass tixScrolledWidget pass class Grid(TixWidget, XView, YView): '''The Tix Grid command creates a new window and makes it into a tixGrid widget. Additional options, may be specified on the command line or in the option database to configure aspects such as its cursor and relief. A Grid widget displays its contents in a two dimensional grid of cells. Each cell may contain one Tix display item, which may be in text, graphics or other formats. See the DisplayStyle class for more information about Tix display items. Individual cells, or groups of cells, can be formatted with a wide range of attributes, such as its color, relief and border. Subwidgets - None''' # valid specific resources as of Tk 8.4 # editdonecmd, editnotifycmd, floatingcols, floatingrows, formatcmd, # highlightbackground, highlightcolor, leftmargin, itemtype, selectmode, # selectunit, topmargin, def __init__(self, master=None, cnf={}, **kw): static= [] self.cnf= cnf TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw) # valid options as of Tk 8.4 # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, # edit, entryconfigure, format, geometryinfo, info, index, move, nearest, # selection, set, size, unset, xview, yview def anchor_clear(self): """Removes the selection anchor.""" self.tk.call(self, 'anchor', 'clear') def anchor_get(self): "Get the (x,y) coordinate of the current anchor cell" return self._getints(self.tk.call(self, 'anchor', 'get')) def anchor_set(self, x, y): """Set the selection anchor to the cell at (x, y).""" self.tk.call(self, 'anchor', 'set', x, y) def delete_row(self, from_, to=None): """Delete rows between from_ and to inclusive. If to is not provided, delete only row at from_""" if to is None: self.tk.call(self, 'delete', 'row', from_) else: self.tk.call(self, 'delete', 'row', from_, to) def delete_column(self, from_, to=None): """Delete columns between from_ and to inclusive. If to is not provided, delete only column at from_""" if to is None: self.tk.call(self, 'delete', 'column', from_) else: self.tk.call(self, 'delete', 'column', from_, to) def edit_apply(self): """If any cell is being edited, de-highlight the cell and applies the changes.""" self.tk.call(self, 'edit', 'apply') def edit_set(self, x, y): """Highlights the cell at (x, y) for editing, if the -editnotify command returns True for this cell.""" self.tk.call(self, 'edit', 'set', x, y) def entrycget(self, x, y, option): "Get the option value for cell at (x,y)" if option and option[0] != '-': option = '-' + option return self.tk.call(self, 'entrycget', x, y, option) def entryconfigure(self, x, y, cnf=None, **kw): return self._configure(('entryconfigure', x, y), cnf, kw) # def format # def index def info_exists(self, x, y): "Return True if display item exists at (x,y)" return self._getboolean(self.tk.call(self, 'info', 'exists', x, y)) def info_bbox(self, x, y): # This seems to always return '', at least for 'text' displayitems return self.tk.call(self, 'info', 'bbox', x, y) def move_column(self, from_, to, offset): """Moves the range of columns from position FROM through TO by the distance indicated by OFFSET. For example, move_column(2, 4, 1) moves the columns 2,3,4 to columns 3,4,5.""" self.tk.call(self, 'move', 'column', from_, to, offset) def move_row(self, from_, to, offset): """Moves the range of rows from position FROM through TO by the distance indicated by OFFSET. For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.""" self.tk.call(self, 'move', 'row', from_, to, offset) def nearest(self, x, y): "Return coordinate of cell nearest pixel coordinate (x,y)" return self._getints(self.tk.call(self, 'nearest', x, y)) # def selection adjust # def selection clear # def selection includes # def selection set # def selection toggle def set(self, x, y, itemtype=None, **kw): args= self._options(self.cnf, kw) if itemtype is not None: args= ('-itemtype', itemtype) + args self.tk.call(self, 'set', x, y, *args) def size_column(self, index, **kw): """Queries or sets the size of the column given by INDEX. INDEX may be any non-negative integer that gives the position of a given column. INDEX can also be the string "default"; in this case, this command queries or sets the default size of all columns. When no option-value pair is given, this command returns a tuple containing the current size setting of the given column. When option-value pairs are given, the corresponding options of the size setting of the given column are changed. Options may be one of the following: pad0 pixels Specifies the paddings to the left of a column. pad1 pixels Specifies the paddings to the right of a column. size val Specifies the width of a column. Val may be: "auto" -- the width of the column is set to the width of the widest cell in the column; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the width of the column to the given number of characters.""" return self.tk.splitlist(self.tk.call(self._w, 'size', 'column', index, *self._options({}, kw))) def size_row(self, index, **kw): """Queries or sets the size of the row given by INDEX. INDEX may be any non-negative integer that gives the position of a given row . INDEX can also be the string "default"; in this case, this command queries or sets the default size of all rows. When no option-value pair is given, this command returns a list con- taining the current size setting of the given row . When option-value pairs are given, the corresponding options of the size setting of the given row are changed. Options may be one of the following: pad0 pixels Specifies the paddings to the top of a row. pad1 pixels Specifies the paddings to the bottom of a row. size val Specifies the height of a row. Val may be: "auto" -- the height of the row is set to the height of the highest cell in the row; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the height of the row to the given number of characters.""" return self.tk.splitlist(self.tk.call( self, 'size', 'row', index, *self._options({}, kw))) def unset(self, x, y): """Clears the cell at (x, y) by removing its display item.""" self.tk.call(self._w, 'unset', x, y) class ScrolledGrid(Grid): '''Scrolled Grid widgets''' # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master=None, cnf={}, **kw): static= [] self.cnf= cnf TixWidget.__init__(self, master, 'tixScrolledGrid', static, cnf, kw) PK! jttk.pynu["""Ttk wrapper. This module provides classes to allow using Tk themed widget set. Ttk is based on a revised and enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style engine. Its basic idea is to separate, to the extent possible, the code implementing a widget's behavior from the code implementing its appearance. Widget class bindings are primarily responsible for maintaining the widget state and invoking callbacks, all aspects of the widgets appearance lies at Themes. """ __version__ = "0.3.1" __author__ = "Guilherme Polo " __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label", "Labelframe", "LabelFrame", "Menubutton", "Notebook", "Panedwindow", "PanedWindow", "Progressbar", "Radiobutton", "Scale", "Scrollbar", "Separator", "Sizegrip", "Spinbox", "Style", "Treeview", # Extensions "LabeledScale", "OptionMenu", # functions "tclobjs_to_py", "setup_master"] import tkinter from tkinter import _flatten, _join, _stringify, _splitdict # Verify if Tk is new enough to not need the Tile package _REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False def _load_tile(master): if _REQUIRE_TILE: import os tilelib = os.environ.get('TILE_LIBRARY') if tilelib: # append custom tile path to the list of directories that # Tcl uses when attempting to resolve packages with the package # command master.tk.eval( 'global auto_path; ' 'lappend auto_path {%s}' % tilelib) master.tk.eval('package require tile') # TclError may be raised here master._tile_loaded = True def _format_optvalue(value, script=False): """Internal function.""" if script: # if caller passes a Tcl script to tk.call, all the values need to # be grouped into words (arguments to a command in Tcl dialect) value = _stringify(value) elif isinstance(value, (list, tuple)): value = _join(value) return value def _format_optdict(optdict, script=False, ignore=None): """Formats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')""" opts = [] for opt, value in optdict.items(): if not ignore or opt not in ignore: opts.append("-%s" % opt) if value is not None: opts.append(_format_optvalue(value, script)) return _flatten(opts) def _mapdict_values(items): # each value in mapdict is expected to be a sequence, where each item # is another sequence containing a state (or several) and a value # E.g. (script=False): # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])] # returns: # ['active selected', 'grey', 'focus', [1, 2, 3, 4]] opt_val = [] for *state, val in items: if len(state) == 1: # if it is empty (something that evaluates to False), then # format it to Tcl code to denote the "normal" state state = state[0] or '' else: # group multiple states state = ' '.join(state) # raise TypeError if not str opt_val.append(state) if val is not None: opt_val.append(val) return opt_val def _format_mapdict(mapdict, script=False): """Formats mapdict to pass it to tk.call. E.g. (script=False): {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]} returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')""" opts = [] for opt, value in mapdict.items(): opts.extend(("-%s" % opt, _format_optvalue(_mapdict_values(value), script))) return _flatten(opts) def _format_elemcreate(etype, script=False, *args, **kw): """Formats args and kw according to the given element factory etype.""" spec = None opts = () if etype in ("image", "vsapi"): if etype == "image": # define an element based on an image # first arg should be the default image name iname = args[0] # next args, if any, are statespec/value pairs which is almost # a mapdict, but we just need the value imagespec = _join(_mapdict_values(args[1:])) spec = "%s %s" % (iname, imagespec) else: # define an element whose visual appearance is drawn using the # Microsoft Visual Styles API which is responsible for the # themed styles on Windows XP and Vista. # Availability: Tk 8.6, Windows XP and Vista. class_name, part_id = args[:2] statemap = _join(_mapdict_values(args[2:])) spec = "%s %s %s" % (class_name, part_id, statemap) opts = _format_optdict(kw, script) elif etype == "from": # clone an element # it expects a themename and optionally an element to clone from, # otherwise it will clone {} (empty element) spec = args[0] # theme name if len(args) > 1: # elementfrom specified opts = (_format_optvalue(args[1], script),) if script: spec = '{%s}' % spec opts = ' '.join(opts) return spec, opts def _format_layoutlist(layout, indent=0, indent_size=2): """Formats a layout list so we can pass the result to ttk::style layout and ttk::style settings. Note that the layout doesn't have to be a list necessarily. E.g.: [("Menubutton.background", None), ("Menubutton.button", {"children": [("Menubutton.focus", {"children": [("Menubutton.padding", {"children": [("Menubutton.label", {"side": "left", "expand": 1})] })] })] }), ("Menubutton.indicator", {"side": "right"}) ] returns: Menubutton.background Menubutton.button -children { Menubutton.focus -children { Menubutton.padding -children { Menubutton.label -side left -expand 1 } } } Menubutton.indicator -side right""" script = [] for layout_elem in layout: elem, opts = layout_elem opts = opts or {} fopts = ' '.join(_format_optdict(opts, True, ("children",))) head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '') if "children" in opts: script.append(head + " -children {") indent += indent_size newscript, indent = _format_layoutlist(opts['children'], indent, indent_size) script.append(newscript) indent -= indent_size script.append('%s}' % (' ' * indent)) else: script.append(head) return '\n'.join(script), indent def _script_from_settings(settings): """Returns an appropriate script, based on settings, according to theme_settings definition to be used by theme_settings and theme_create.""" script = [] # a script will be generated according to settings passed, which # will then be evaluated by Tcl for name, opts in settings.items(): # will format specific keys according to Tcl code if opts.get('configure'): # format 'configure' s = ' '.join(_format_optdict(opts['configure'], True)) script.append("ttk::style configure %s %s;" % (name, s)) if opts.get('map'): # format 'map' s = ' '.join(_format_mapdict(opts['map'], True)) script.append("ttk::style map %s %s;" % (name, s)) if 'layout' in opts: # format 'layout' which may be empty if not opts['layout']: s = 'null' # could be any other word, but this one makes sense else: s, _ = _format_layoutlist(opts['layout']) script.append("ttk::style layout %s {\n%s\n}" % (name, s)) if opts.get('element create'): # format 'element create' eopts = opts['element create'] etype = eopts[0] # find where args end, and where kwargs start argc = 1 # etype was the first one while argc < len(eopts) and not hasattr(eopts[argc], 'items'): argc += 1 elemargs = eopts[1:argc] elemkw = eopts[argc] if argc < len(eopts) and eopts[argc] else {} spec, opts = _format_elemcreate(etype, True, *elemargs, **elemkw) script.append("ttk::style element create %s %s %s %s" % ( name, etype, spec, opts)) return '\n'.join(script) def _list_from_statespec(stuple): """Construct a list from the given statespec tuple according to the accepted statespec accepted by _format_mapdict.""" if isinstance(stuple, str): return stuple result = [] it = iter(stuple) for state, val in zip(it, it): if hasattr(state, 'typename'): # this is a Tcl object state = str(state).split() elif isinstance(state, str): state = state.split() elif not isinstance(state, (tuple, list)): state = (state,) if hasattr(val, 'typename'): val = str(val) result.append((*state, val)) return result def _list_from_layouttuple(tk, ltuple): """Construct a list from the tuple returned by ttk::layout, this is somewhat the reverse of _format_layoutlist.""" ltuple = tk.splitlist(ltuple) res = [] indx = 0 while indx < len(ltuple): name = ltuple[indx] opts = {} res.append((name, opts)) indx += 1 while indx < len(ltuple): # grab name's options opt, val = ltuple[indx:indx + 2] if not opt.startswith('-'): # found next name break opt = opt[1:] # remove the '-' from the option indx += 2 if opt == 'children': val = _list_from_layouttuple(tk, val) opts[opt] = val return res def _val_or_dict(tk, options, *args): """Format options then call Tk command with args and options and return the appropriate result. If no option is specified, a dict is returned. If an option is specified with the None value, the value for that option is returned. Otherwise, the function just sets the passed options and the caller shouldn't be expecting a return value anyway.""" options = _format_optdict(options) res = tk.call(*(args + options)) if len(options) % 2: # option specified without a value, return its value return res return _splitdict(tk, res, conv=_tclobj_to_py) def _convert_stringval(value): """Converts a value to, hopefully, a more appropriate Python object.""" value = str(value) try: value = int(value) except (ValueError, TypeError): pass return value def _to_number(x): if isinstance(x, str): if '.' in x: x = float(x) else: x = int(x) return x def _tclobj_to_py(val): """Return value converted from Tcl object to Python object.""" if val and hasattr(val, '__len__') and not isinstance(val, str): if getattr(val[0], 'typename', None) == 'StateSpec': val = _list_from_statespec(val) else: val = list(map(_convert_stringval, val)) elif hasattr(val, 'typename'): # some other (single) Tcl object val = _convert_stringval(val) return val def tclobjs_to_py(adict): """Returns adict with its values converted from Tcl objects to Python objects.""" for opt, val in adict.items(): adict[opt] = _tclobj_to_py(val) return adict def setup_master(master=None): """If master is not None, itself is returned. If master is None, the default master is returned if there is one, otherwise a new master is created and returned. If it is not allowed to use the default root and master is None, RuntimeError is raised.""" if master is None: master = tkinter._get_default_root() return master class Style(object): """Manipulate style database.""" _name = "ttk::style" def __init__(self, master=None): master = setup_master(master) if not getattr(master, '_tile_loaded', False): # Load tile now, if needed _load_tile(master) self.master = master self.tk = self.master.tk def configure(self, style, query_opt=None, **kw): """Query or sets the default value of the specified option(s) in style. Each key in kw is an option and each value is either a string or a sequence identifying the value for that option.""" if query_opt is not None: kw[query_opt] = None result = _val_or_dict(self.tk, kw, self._name, "configure", style) if result or query_opt: return result def map(self, style, query_opt=None, **kw): """Query or sets dynamic values of the specified option(s) in style. Each key in kw is an option and each value should be a list or a tuple (usually) containing statespecs grouped in tuples, or list, or something else of your preference. A statespec is compound of one or more states and then a value.""" if query_opt is not None: result = self.tk.call(self._name, "map", style, '-%s' % query_opt) return _list_from_statespec(self.tk.splitlist(result)) result = self.tk.call(self._name, "map", style, *_format_mapdict(kw)) return {k: _list_from_statespec(self.tk.splitlist(v)) for k, v in _splitdict(self.tk, result).items()} def lookup(self, style, option, state=None, default=None): """Returns the value specified for option in style. If state is specified it is expected to be a sequence of one or more states. If the default argument is set, it is used as a fallback value in case no specification for option is found.""" state = ' '.join(state) if state else '' return self.tk.call(self._name, "lookup", style, '-%s' % option, state, default) def layout(self, style, layoutspec=None): """Define the widget layout for given style. If layoutspec is omitted, return the layout specification for given style. layoutspec is expected to be a list or an object different than None that evaluates to False if you want to "turn off" that style. If it is a list (or tuple, or something else), each item should be a tuple where the first item is the layout name and the second item should have the format described below: LAYOUTS A layout can contain the value None, if takes no options, or a dict of options specifying how to arrange the element. The layout mechanism uses a simplified version of the pack geometry manager: given an initial cavity, each element is allocated a parcel. Valid options/values are: side: whichside Specifies which side of the cavity to place the element; one of top, right, bottom or left. If omitted, the element occupies the entire cavity. sticky: nswe Specifies where the element is placed inside its allocated parcel. children: [sublayout... ] Specifies a list of elements to place inside the element. Each element is a tuple (or other sequence) where the first item is the layout name, and the other is a LAYOUT.""" lspec = None if layoutspec: lspec = _format_layoutlist(layoutspec)[0] elif layoutspec is not None: # will disable the layout ({}, '', etc) lspec = "null" # could be any other word, but this may make sense # when calling layout(style) later return _list_from_layouttuple(self.tk, self.tk.call(self._name, "layout", style, lspec)) def element_create(self, elementname, etype, *args, **kw): """Create a new element in the current theme of given etype.""" spec, opts = _format_elemcreate(etype, False, *args, **kw) self.tk.call(self._name, "element", "create", elementname, etype, spec, *opts) def element_names(self): """Returns the list of elements defined in the current theme.""" return tuple(n.lstrip('-') for n in self.tk.splitlist( self.tk.call(self._name, "element", "names"))) def element_options(self, elementname): """Return the list of elementname's options.""" return tuple(o.lstrip('-') for o in self.tk.splitlist( self.tk.call(self._name, "element", "options", elementname))) def theme_create(self, themename, parent=None, settings=None): """Creates a new theme. It is an error if themename already exists. If parent is specified, the new theme will inherit styles, elements and layouts from the specified parent theme. If settings are present, they are expected to have the same syntax used for theme_settings.""" script = _script_from_settings(settings) if settings else '' if parent: self.tk.call(self._name, "theme", "create", themename, "-parent", parent, "-settings", script) else: self.tk.call(self._name, "theme", "create", themename, "-settings", script) def theme_settings(self, themename, settings): """Temporarily sets the current theme to themename, apply specified settings and then restore the previous theme. Each key in settings is a style and each value may contain the keys 'configure', 'map', 'layout' and 'element create' and they are expected to have the same format as specified by the methods configure, map, layout and element_create respectively.""" script = _script_from_settings(settings) self.tk.call(self._name, "theme", "settings", themename, script) def theme_names(self): """Returns a list of all known themes.""" return self.tk.splitlist(self.tk.call(self._name, "theme", "names")) def theme_use(self, themename=None): """If themename is None, returns the theme in use, otherwise, set the current theme to themename, refreshes all widgets and emits a <> event.""" if themename is None: # Starting on Tk 8.6, checking this global is no longer needed # since it allows doing self.tk.call(self._name, "theme", "use") return self.tk.eval("return $ttk::currentTheme") # using "ttk::setTheme" instead of "ttk::style theme use" causes # the variable currentTheme to be updated, also, ttk::setTheme calls # "ttk::style theme use" in order to change theme. self.tk.call("ttk::setTheme", themename) class Widget(tkinter.Widget): """Base class for Tk themed widgets.""" def __init__(self, master, widgetname, kw=None): """Constructs a Ttk Widget with the parent master. STANDARD OPTIONS class, cursor, takefocus, style SCROLLABLE WIDGET OPTIONS xscrollcommand, yscrollcommand LABEL WIDGET OPTIONS text, textvariable, underline, image, compound, width WIDGET STATES active, disabled, focus, pressed, selected, background, readonly, alternate, invalid """ master = setup_master(master) if not getattr(master, '_tile_loaded', False): # Load tile now, if needed _load_tile(master) tkinter.Widget.__init__(self, master, widgetname, kw=kw) def identify(self, x, y): """Returns the name of the element at position x, y, or the empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget.""" return self.tk.call(self._w, "identify", x, y) def instate(self, statespec, callback=None, *args, **kw): """Test the widget's state. If callback is not specified, returns True if the widget state matches statespec and False otherwise. If callback is specified, then it will be invoked with *args, **kw if the widget state matches statespec. statespec is expected to be a sequence.""" ret = self.tk.getboolean( self.tk.call(self._w, "instate", ' '.join(statespec))) if ret and callback: return callback(*args, **kw) return ret def state(self, statespec=None): """Modify or inquire widget state. Widget state is returned if statespec is None, otherwise it is set according to the statespec flags and then a new state spec is returned indicating which flags were changed. statespec is expected to be a sequence.""" if statespec is not None: statespec = ' '.join(statespec) return self.tk.splitlist(str(self.tk.call(self._w, "state", statespec))) class Button(Widget): """Ttk Button widget, displays a textual label and/or image, and evaluates a command when pressed.""" def __init__(self, master=None, **kw): """Construct a Ttk Button widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, default, width """ Widget.__init__(self, master, "ttk::button", kw) def invoke(self): """Invokes the command associated with the button.""" return self.tk.call(self._w, "invoke") class Checkbutton(Widget): """Ttk Checkbutton widget which is either in on- or off-state.""" def __init__(self, master=None, **kw): """Construct a Ttk Checkbutton widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, offvalue, onvalue, variable """ Widget.__init__(self, master, "ttk::checkbutton", kw) def invoke(self): """Toggles between the selected and deselected states and invokes the associated command. If the widget is currently selected, sets the option variable to the offvalue option and deselects the widget; otherwise, sets the option variable to the option onvalue. Returns the result of the associated command.""" return self.tk.call(self._w, "invoke") class Entry(Widget, tkinter.Entry): """Ttk Entry widget displays a one-line text string and allows that string to be edited by the user.""" def __init__(self, master=None, widget=None, **kw): """Constructs a Ttk Entry widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand WIDGET-SPECIFIC OPTIONS exportselection, invalidcommand, justify, show, state, textvariable, validate, validatecommand, width VALIDATION MODES none, key, focus, focusin, focusout, all """ Widget.__init__(self, master, widget or "ttk::entry", kw) def bbox(self, index): """Return a tuple of (x, y, width, height) which describes the bounding box of the character given by index.""" return self._getints(self.tk.call(self._w, "bbox", index)) def identify(self, x, y): """Returns the name of the element at position x, y, or the empty string if the coordinates are outside the window.""" return self.tk.call(self._w, "identify", x, y) def validate(self): """Force revalidation, independent of the conditions specified by the validate option. Returns False if validation fails, True if it succeeds. Sets or clears the invalid state accordingly.""" return self.tk.getboolean(self.tk.call(self._w, "validate")) class Combobox(Entry): """Ttk Combobox widget combines a text field with a pop-down list of values.""" def __init__(self, master=None, **kw): """Construct a Ttk Combobox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS exportselection, justify, height, postcommand, state, textvariable, values, width """ Entry.__init__(self, master, "ttk::combobox", **kw) def current(self, newindex=None): """If newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, returns the index of the current value in the list of values or -1 if the current value does not appear in the list.""" if newindex is None: return self.tk.getint(self.tk.call(self._w, "current")) return self.tk.call(self._w, "current", newindex) def set(self, value): """Sets the value of the combobox to value.""" self.tk.call(self._w, "set", value) class Frame(Widget): """Ttk Frame widget is a container, used to group other widgets together.""" def __init__(self, master=None, **kw): """Construct a Ttk Frame with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS borderwidth, relief, padding, width, height """ Widget.__init__(self, master, "ttk::frame", kw) class Label(Widget): """Ttk Label widget displays a textual label and/or image.""" def __init__(self, master=None, **kw): """Construct a Ttk Label with parent master. STANDARD OPTIONS class, compound, cursor, image, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS anchor, background, font, foreground, justify, padding, relief, text, wraplength """ Widget.__init__(self, master, "ttk::label", kw) class Labelframe(Widget): """Ttk Labelframe widget is a container used to group other widgets together. It has an optional label, which may be a plain text string or another widget.""" def __init__(self, master=None, **kw): """Construct a Ttk Labelframe with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS labelanchor, text, underline, padding, labelwidget, width, height """ Widget.__init__(self, master, "ttk::labelframe", kw) LabelFrame = Labelframe # tkinter name compatibility class Menubutton(Widget): """Ttk Menubutton widget displays a textual label and/or image, and displays a menu when pressed.""" def __init__(self, master=None, **kw): """Construct a Ttk Menubutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS direction, menu """ Widget.__init__(self, master, "ttk::menubutton", kw) class Notebook(Widget): """Ttk Notebook widget manages a collection of windows and displays a single one at a time. Each child window is associated with a tab, which the user may select to change the currently-displayed window.""" def __init__(self, master=None, **kw): """Construct a Ttk Notebook with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS height, padding, width TAB OPTIONS state, sticky, padding, text, image, compound, underline TAB IDENTIFIERS (tab_id) The tab_id argument found in several methods may take any of the following forms: * An integer between zero and the number of tabs * The name of a child window * A positional specification of the form "@x,y", which defines the tab * The string "current", which identifies the currently-selected tab * The string "end", which returns the number of tabs (only valid for method index) """ Widget.__init__(self, master, "ttk::notebook", kw) def add(self, child, **kw): """Adds a new tab to the notebook. If window is currently managed by the notebook but hidden, it is restored to its previous position.""" self.tk.call(self._w, "add", child, *(_format_optdict(kw))) def forget(self, tab_id): """Removes the tab specified by tab_id, unmaps and unmanages the associated window.""" self.tk.call(self._w, "forget", tab_id) def hide(self, tab_id): """Hides the tab specified by tab_id. The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the add command.""" self.tk.call(self._w, "hide", tab_id) def identify(self, x, y): """Returns the name of the tab element at position x, y, or the empty string if none.""" return self.tk.call(self._w, "identify", x, y) def index(self, tab_id): """Returns the numeric index of the tab specified by tab_id, or the total number of tabs if tab_id is the string "end".""" return self.tk.getint(self.tk.call(self._w, "index", tab_id)) def insert(self, pos, child, **kw): """Inserts a pane at the specified position. pos is either the string end, an integer index, or the name of a managed child. If child is already managed by the notebook, moves it to the specified position.""" self.tk.call(self._w, "insert", pos, child, *(_format_optdict(kw))) def select(self, tab_id=None): """Selects the specified tab. The associated child window will be displayed, and the previously-selected window (if different) is unmapped. If tab_id is omitted, returns the widget name of the currently selected pane.""" return self.tk.call(self._w, "select", tab_id) def tab(self, tab_id, option=None, **kw): """Query or modify the options of the specific tab_id. If kw is not given, returns a dict of the tab option values. If option is specified, returns the value of that option. Otherwise, sets the options to the corresponding values.""" if option is not None: kw[option] = None return _val_or_dict(self.tk, kw, self._w, "tab", tab_id) def tabs(self): """Returns a list of windows managed by the notebook.""" return self.tk.splitlist(self.tk.call(self._w, "tabs") or ()) def enable_traversal(self): """Enable keyboard traversal for a toplevel window containing this notebook. This will extend the bindings for the toplevel window containing this notebook as follows: Control-Tab: selects the tab following the currently selected one Shift-Control-Tab: selects the tab preceding the currently selected one Alt-K: where K is the mnemonic (underlined) character of any tab, will select that tab. Multiple notebooks in a single toplevel may be enabled for traversal, including nested notebooks. However, notebook traversal only works properly if all panes are direct children of the notebook.""" # The only, and good, difference I see is about mnemonics, which works # after calling this method. Control-Tab and Shift-Control-Tab always # works (here at least). self.tk.call("ttk::notebook::enableTraversal", self._w) class Panedwindow(Widget, tkinter.PanedWindow): """Ttk Panedwindow widget displays a number of subwindows, stacked either vertically or horizontally.""" def __init__(self, master=None, **kw): """Construct a Ttk Panedwindow with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient, width, height PANE OPTIONS weight """ Widget.__init__(self, master, "ttk::panedwindow", kw) forget = tkinter.PanedWindow.forget # overrides Pack.forget def insert(self, pos, child, **kw): """Inserts a pane at the specified positions. pos is either the string end, and integer index, or the name of a child. If child is already managed by the paned window, moves it to the specified position.""" self.tk.call(self._w, "insert", pos, child, *(_format_optdict(kw))) def pane(self, pane, option=None, **kw): """Query or modify the options of the specified pane. pane is either an integer index or the name of a managed subwindow. If kw is not given, returns a dict of the pane option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.""" if option is not None: kw[option] = None return _val_or_dict(self.tk, kw, self._w, "pane", pane) def sashpos(self, index, newpos=None): """If newpos is specified, sets the position of sash number index. May adjust the positions of adjacent sashes to ensure that positions are monotonically increasing. Sash positions are further constrained to be between 0 and the total size of the widget. Returns the new position of sash number index.""" return self.tk.getint(self.tk.call(self._w, "sashpos", index, newpos)) PanedWindow = Panedwindow # tkinter name compatibility class Progressbar(Widget): """Ttk Progressbar widget shows the status of a long-running operation. They can operate in two modes: determinate mode shows the amount completed relative to the total amount of work to be done, and indeterminate mode provides an animated display to let the user know that something is happening.""" def __init__(self, master=None, **kw): """Construct a Ttk Progressbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient, length, mode, maximum, value, variable, phase """ Widget.__init__(self, master, "ttk::progressbar", kw) def start(self, interval=None): """Begin autoincrement mode: schedules a recurring timer event that calls method step every interval milliseconds. interval defaults to 50 milliseconds (20 steps/second) if omitted.""" self.tk.call(self._w, "start", interval) def step(self, amount=None): """Increments the value option by amount. amount defaults to 1.0 if omitted.""" self.tk.call(self._w, "step", amount) def stop(self): """Stop autoincrement mode: cancels any recurring timer event initiated by start.""" self.tk.call(self._w, "stop") class Radiobutton(Widget): """Ttk Radiobutton widgets are used in groups to show or change a set of mutually-exclusive options.""" def __init__(self, master=None, **kw): """Construct a Ttk Radiobutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, value, variable """ Widget.__init__(self, master, "ttk::radiobutton", kw) def invoke(self): """Sets the option variable to the option value, selects the widget, and invokes the associated command. Returns the result of the command, or an empty string if no command is specified.""" return self.tk.call(self._w, "invoke") class Scale(Widget, tkinter.Scale): """Ttk Scale widget is typically used to control the numeric value of a linked variable that varies uniformly over some range.""" def __init__(self, master=None, **kw): """Construct a Ttk Scale with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, from, length, orient, to, value, variable """ Widget.__init__(self, master, "ttk::scale", kw) def configure(self, cnf=None, **kw): """Modify or query scale options. Setting a value for any of the "from", "from_" or "to" options generates a <> event.""" retval = Widget.configure(self, cnf, **kw) if not isinstance(cnf, (type(None), str)): kw.update(cnf) if any(['from' in kw, 'from_' in kw, 'to' in kw]): self.event_generate('<>') return retval def get(self, x=None, y=None): """Get the current value of the value option, or the value corresponding to the coordinates x, y if they are specified. x and y are pixel coordinates relative to the scale widget origin.""" return self.tk.call(self._w, 'get', x, y) class Scrollbar(Widget, tkinter.Scrollbar): """Ttk Scrollbar controls the viewport of a scrollable widget.""" def __init__(self, master=None, **kw): """Construct a Ttk Scrollbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, orient """ Widget.__init__(self, master, "ttk::scrollbar", kw) class Separator(Widget): """Ttk Separator widget displays a horizontal or vertical separator bar.""" def __init__(self, master=None, **kw): """Construct a Ttk Separator with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient """ Widget.__init__(self, master, "ttk::separator", kw) class Sizegrip(Widget): """Ttk Sizegrip allows the user to resize the containing toplevel window by pressing and dragging the grip.""" def __init__(self, master=None, **kw): """Construct a Ttk Sizegrip with parent master. STANDARD OPTIONS class, cursor, state, style, takefocus """ Widget.__init__(self, master, "ttk::sizegrip", kw) class Spinbox(Entry): """Ttk Spinbox is an Entry with increment and decrement arrows It is commonly used for number entry or to select from a list of string values. """ def __init__(self, master=None, **kw): """Construct a Ttk Spinbox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, validate, validatecommand, xscrollcommand, invalidcommand WIDGET-SPECIFIC OPTIONS to, from_, increment, values, wrap, format, command """ Entry.__init__(self, master, "ttk::spinbox", **kw) def set(self, value): """Sets the value of the Spinbox to value.""" self.tk.call(self._w, "set", value) class Treeview(Widget, tkinter.XView, tkinter.YView): """Ttk Treeview widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label.""" def __init__(self, master=None, **kw): """Construct a Ttk Treeview with parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand, yscrollcommand WIDGET-SPECIFIC OPTIONS columns, displaycolumns, height, padding, selectmode, show ITEM OPTIONS text, image, values, open, tags TAG OPTIONS foreground, background, font, image """ Widget.__init__(self, master, "ttk::treeview", kw) def bbox(self, item, column=None): """Returns the bounding box (relative to the treeview widget's window) of the specified item in the form x y width height. If column is specified, returns the bounding box of that cell. If the item is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.""" return self._getints(self.tk.call(self._w, "bbox", item, column)) or '' def get_children(self, item=None): """Returns a tuple of children belonging to item. If item is not specified, returns root children.""" return self.tk.splitlist( self.tk.call(self._w, "children", item or '') or ()) def set_children(self, item, *newchildren): """Replaces item's child with newchildren. Children present in item that are not present in newchildren are detached from tree. No items in newchildren may be an ancestor of item.""" self.tk.call(self._w, "children", item, newchildren) def column(self, column, option=None, **kw): """Query or modify the options for the specified column. If kw is not given, returns a dict of the column option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.""" if option is not None: kw[option] = None return _val_or_dict(self.tk, kw, self._w, "column", column) def delete(self, *items): """Delete all specified items and all their descendants. The root item may not be deleted.""" self.tk.call(self._w, "delete", items) def detach(self, *items): """Unlinks all of the specified items from the tree. The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed. The root item may not be detached.""" self.tk.call(self._w, "detach", items) def exists(self, item): """Returns True if the specified item is present in the tree, False otherwise.""" return self.tk.getboolean(self.tk.call(self._w, "exists", item)) def focus(self, item=None): """If item is specified, sets the focus item to item. Otherwise, returns the current focus item, or '' if there is none.""" return self.tk.call(self._w, "focus", item) def heading(self, column, option=None, **kw): """Query or modify the heading options for the specified column. If kw is not given, returns a dict of the heading option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values. Valid options/values are: text: text The text to display in the column heading image: image_name Specifies an image to display to the right of the column heading anchor: anchor Specifies how the heading text should be aligned. One of the standard Tk anchor values command: callback A callback to be invoked when the heading label is pressed. To configure the tree column heading, call this with column = "#0" """ cmd = kw.get('command') if cmd and not isinstance(cmd, str): # callback not registered yet, do it now kw['command'] = self.master.register(cmd, self._substitute) if option is not None: kw[option] = None return _val_or_dict(self.tk, kw, self._w, 'heading', column) def identify(self, component, x, y): """Returns a description of the specified component under the point given by x and y, or the empty string if no such component is present at that position.""" return self.tk.call(self._w, "identify", component, x, y) def identify_row(self, y): """Returns the item ID of the item at position y.""" return self.identify("row", 0, y) def identify_column(self, x): """Returns the data column identifier of the cell at position x. The tree column has ID #0.""" return self.identify("column", x, 0) def identify_region(self, x, y): """Returns one of: heading: Tree heading area. separator: Space between two columns headings; tree: The tree area. cell: A data cell. * Availability: Tk 8.6""" return self.identify("region", x, y) def identify_element(self, x, y): """Returns the element at position x, y. * Availability: Tk 8.6""" return self.identify("element", x, y) def index(self, item): """Returns the integer index of item within its parent's list of children.""" return self.tk.getint(self.tk.call(self._w, "index", item)) def insert(self, parent, index, iid=None, **kw): """Creates a new item and return the item identifier of the newly created item. parent is the item ID of the parent item, or the empty string to create a new top-level item. index is an integer, or the value end, specifying where in the list of parent's children to insert the new item. If index is less than or equal to zero, the new node is inserted at the beginning, if index is greater than or equal to the current number of children, it is inserted at the end. If iid is specified, it is used as the item identifier, iid must not already exist in the tree. Otherwise, a new unique identifier is generated.""" opts = _format_optdict(kw) if iid is not None: res = self.tk.call(self._w, "insert", parent, index, "-id", iid, *opts) else: res = self.tk.call(self._w, "insert", parent, index, *opts) return res def item(self, item, option=None, **kw): """Query or modify the options for the specified item. If no options are given, a dict with options/values for the item is returned. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values as given by kw.""" if option is not None: kw[option] = None return _val_or_dict(self.tk, kw, self._w, "item", item) def move(self, item, parent, index): """Moves item to position index in parent's list of children. It is illegal to move an item under one of its descendants. If index is less than or equal to zero, item is moved to the beginning, if greater than or equal to the number of children, it is moved to the end. If item was detached it is reattached.""" self.tk.call(self._w, "move", item, parent, index) reattach = move # A sensible method name for reattaching detached items def next(self, item): """Returns the identifier of item's next sibling, or '' if item is the last child of its parent.""" return self.tk.call(self._w, "next", item) def parent(self, item): """Returns the ID of the parent of item, or '' if item is at the top level of the hierarchy.""" return self.tk.call(self._w, "parent", item) def prev(self, item): """Returns the identifier of item's previous sibling, or '' if item is the first child of its parent.""" return self.tk.call(self._w, "prev", item) def see(self, item): """Ensure that item is visible. Sets all of item's ancestors open option to True, and scrolls the widget if necessary so that item is within the visible portion of the tree.""" self.tk.call(self._w, "see", item) def selection(self): """Returns the tuple of selected items.""" return self.tk.splitlist(self.tk.call(self._w, "selection")) def _selection(self, selop, items): if len(items) == 1 and isinstance(items[0], (tuple, list)): items = items[0] self.tk.call(self._w, "selection", selop, items) def selection_set(self, *items): """The specified items becomes the new selection.""" self._selection("set", items) def selection_add(self, *items): """Add all of the specified items to the selection.""" self._selection("add", items) def selection_remove(self, *items): """Remove all of the specified items from the selection.""" self._selection("remove", items) def selection_toggle(self, *items): """Toggle the selection state of each specified item.""" self._selection("toggle", items) def set(self, item, column=None, value=None): """Query or set the value of given item. With one argument, return a dictionary of column/value pairs for the specified item. With two arguments, return the current value of the specified column. With three arguments, set the value of given column in given item to the specified value.""" res = self.tk.call(self._w, "set", item, column, value) if column is None and value is None: return _splitdict(self.tk, res, cut_minus=False, conv=_tclobj_to_py) else: return res def tag_bind(self, tagname, sequence=None, callback=None): """Bind a callback for the given event sequence to the tag tagname. When an event is delivered to an item, the callbacks for each of the item's tags option are called.""" self._bind((self._w, "tag", "bind", tagname), sequence, callback, add=0) def tag_configure(self, tagname, option=None, **kw): """Query or modify the options for the specified tagname. If kw is not given, returns a dict of the option settings for tagname. If option is specified, returns the value for that option for the specified tagname. Otherwise, sets the options to the corresponding values for the given tagname.""" if option is not None: kw[option] = None return _val_or_dict(self.tk, kw, self._w, "tag", "configure", tagname) def tag_has(self, tagname, item=None): """If item is specified, returns 1 or 0 depending on whether the specified item has the given tagname. Otherwise, returns a list of all items which have the specified tag. * Availability: Tk 8.6""" if item is None: return self.tk.splitlist( self.tk.call(self._w, "tag", "has", tagname)) else: return self.tk.getboolean( self.tk.call(self._w, "tag", "has", tagname, item)) # Extensions class LabeledScale(Frame): """A Ttk Scale widget with a Ttk Label widget indicating its current value. The Ttk Scale can be accessed through instance.scale, and Ttk Label can be accessed through instance.label""" def __init__(self, master=None, variable=None, from_=0, to=10, **kw): """Construct a horizontal LabeledScale with parent master, a variable to be associated with the Ttk Scale widget and its range. If variable is not specified, a tkinter.IntVar is created. WIDGET-SPECIFIC OPTIONS compound: 'top' or 'bottom' Specifies how to display the label relative to the scale. Defaults to 'top'. """ self._label_top = kw.pop('compound', 'top') == 'top' Frame.__init__(self, master, **kw) self._variable = variable or tkinter.IntVar(master) self._variable.set(from_) self._last_valid = from_ self.label = Label(self) self.scale = Scale(self, variable=self._variable, from_=from_, to=to) self.scale.bind('<>', self._adjust) # position scale and label according to the compound option scale_side = 'bottom' if self._label_top else 'top' label_side = 'top' if scale_side == 'bottom' else 'bottom' self.scale.pack(side=scale_side, fill='x') # Dummy required to make frame correct height dummy = Label(self) dummy.pack(side=label_side) dummy.lower() self.label.place(anchor='n' if label_side == 'top' else 's') # update the label as scale or variable changes self.__tracecb = self._variable.trace_variable('w', self._adjust) self.bind('', self._adjust) self.bind('', self._adjust) def destroy(self): """Destroy this widget and possibly its associated variable.""" try: self._variable.trace_vdelete('w', self.__tracecb) except AttributeError: pass else: del self._variable super().destroy() self.label = None self.scale = None def _adjust(self, *args): """Adjust the label position according to the scale.""" def adjust_label(): self.update_idletasks() # "force" scale redraw x, y = self.scale.coords() if self._label_top: y = self.scale.winfo_y() - self.label.winfo_reqheight() else: y = self.scale.winfo_reqheight() + self.label.winfo_reqheight() self.label.place_configure(x=x, y=y) from_ = _to_number(self.scale['from']) to = _to_number(self.scale['to']) if to < from_: from_, to = to, from_ newval = self._variable.get() if not from_ <= newval <= to: # value outside range, set value back to the last valid one self.value = self._last_valid return self._last_valid = newval self.label['text'] = newval self.after_idle(adjust_label) @property def value(self): """Return current scale value.""" return self._variable.get() @value.setter def value(self, val): """Set new scale value.""" self._variable.set(val) class OptionMenu(Menubutton): """Themed OptionMenu, based after tkinter's OptionMenu, which allows the user to select a value from a menu.""" def __init__(self, master, variable, default=None, *values, **kwargs): """Construct a themed OptionMenu widget with master as the parent, the resource textvariable set to variable, the initially selected value specified by the default parameter, the menu values given by *values and additional keywords. WIDGET-SPECIFIC OPTIONS style: stylename Menubutton style. direction: 'above', 'below', 'left', 'right', or 'flush' Menubutton direction. command: callback A callback that will be invoked after selecting an item. """ kw = {'textvariable': variable, 'style': kwargs.pop('style', None), 'direction': kwargs.pop('direction', None)} Menubutton.__init__(self, master, **kw) self['menu'] = tkinter.Menu(self, tearoff=False) self._variable = variable self._callback = kwargs.pop('command', None) if kwargs: raise tkinter.TclError('unknown option -%s' % ( next(iter(kwargs.keys())))) self.set_menu(default, *values) def __getitem__(self, item): if item == 'menu': return self.nametowidget(Menubutton.__getitem__(self, item)) return Menubutton.__getitem__(self, item) def set_menu(self, default=None, *values): """Build a new menu of radiobuttons with *values and optionally a default value.""" menu = self['menu'] menu.delete(0, 'end') for val in values: menu.add_radiobutton(label=val, command=tkinter._setit(self._variable, val, self._callback), variable=self._variable) if default: self._variable.set(default) def destroy(self): """Destroy this widget and its associated variable.""" try: del self._variable except AttributeError: pass super().destroy() PK!q __main__.pynu["""Main entry point""" import sys if sys.argv[0].endswith("__main__.py"): sys.argv[0] = "python -m tkinter" from . import _test as main main() PK!@@font.pynu[# Tkinter font wrapper # # written by Fredrik Lundh, February 1998 # __version__ = "0.9" import itertools import tkinter # weight/slant NORMAL = "normal" ROMAN = "roman" BOLD = "bold" ITALIC = "italic" def nametofont(name): """Given the name of a tk named font, returns a Font representation. """ return Font(name=name, exists=True) class Font: """Represents a named font. Constructor options are: font -- font specifier (name, system font, or (family, size, style)-tuple) name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new named font if False, points to the existing font if True. Raises _tkinter.TclError if the assertion is false. the following are ignored if font is specified: family -- font 'family', e.g. Courier, Times, Helvetica size -- font size in points weight -- font thickness: NORMAL, BOLD slant -- font slant: ROMAN, ITALIC underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) """ counter = itertools.count(1) def _set(self, kw): options = [] for k, v in kw.items(): options.append("-"+k) options.append(str(v)) return tuple(options) def _get(self, args): options = [] for k in args: options.append("-"+k) return tuple(options) def _mkdict(self, args): options = {} for i in range(0, len(args), 2): options[args[i][1:]] = args[i+1] return options def __init__(self, root=None, font=None, name=None, exists=False, **options): if not root: root = tkinter._get_default_root('use font') tk = getattr(root, 'tk', root) if font: # get actual settings corresponding to the given font font = tk.splitlist(tk.call("font", "actual", font)) else: font = self._set(options) if not name: name = "font" + str(next(self.counter)) self.name = name if exists: self.delete_font = False # confirm font exists if self.name not in tk.splitlist(tk.call("font", "names")): raise tkinter._tkinter.TclError( "named font %s does not already exist" % (self.name,)) # if font config info supplied, apply it if font: tk.call("font", "configure", self.name, *font) else: # create new font (raises TclError if the font exists) tk.call("font", "create", self.name, *font) self.delete_font = True self._tk = tk self._split = tk.splitlist self._call = tk.call def __str__(self): return self.name def __eq__(self, other): if not isinstance(other, Font): return NotImplemented return self.name == other.name and self._tk == other._tk def __getitem__(self, key): return self.cget(key) def __setitem__(self, key, value): self.configure(**{key: value}) def __del__(self): try: if self.delete_font: self._call("font", "delete", self.name) except Exception: pass def copy(self): "Return a distinct copy of the current font" return Font(self._tk, **self.actual()) def actual(self, option=None, displayof=None): "Return actual font attributes" args = () if displayof: args = ('-displayof', displayof) if option: args = args + ('-' + option, ) return self._call("font", "actual", self.name, *args) else: return self._mkdict( self._split(self._call("font", "actual", self.name, *args))) def cget(self, option): "Get font attribute" return self._call("font", "config", self.name, "-"+option) def config(self, **options): "Modify font attributes" if options: self._call("font", "config", self.name, *self._set(options)) else: return self._mkdict( self._split(self._call("font", "config", self.name))) configure = config def measure(self, text, displayof=None): "Return text width" args = (text,) if displayof: args = ('-displayof', displayof, text) return self._tk.getint(self._call("font", "measure", self.name, *args)) def metrics(self, *options, **kw): """Return font metrics. For best performance, create a dummy widget using this font before calling this method.""" args = () displayof = kw.pop('displayof', None) if displayof: args = ('-displayof', displayof) if options: args = args + self._get(options) return self._tk.getint( self._call("font", "metrics", self.name, *args)) else: res = self._split(self._call("font", "metrics", self.name, *args)) options = {} for i in range(0, len(res), 2): options[res[i][1:]] = self._tk.getint(res[i+1]) return options def families(root=None, displayof=None): "Get font families (as a tuple)" if not root: root = tkinter._get_default_root('use font.families()') args = () if displayof: args = ('-displayof', displayof) return root.tk.splitlist(root.tk.call("font", "families", *args)) def names(root=None): "Get names of defined fonts (as a tuple)" if not root: root = tkinter._get_default_root('use font.names()') return root.tk.splitlist(root.tk.call("font", "names")) # -------------------------------------------------------------------- # test stuff if __name__ == "__main__": root = tkinter.Tk() # create a font f = Font(family="times", size=30, weight=NORMAL) print(f.actual()) print(f.actual("family")) print(f.actual("weight")) print(f.config()) print(f.cget("family")) print(f.cget("weight")) print(names()) print(f.measure("hello"), f.metrics("linespace")) print(f.metrics(displayof=root)) f = Font(font=("Courier", 20, "bold")) print(f.measure("hello"), f.metrics("linespace", displayof=root)) w = tkinter.Label(root, text="Hello, world", font=f) w.pack() w = tkinter.Button(root, text="Quit!", command=root.destroy) w.pack() fb = Font(font=w["font"]).copy() fb.config(weight=BOLD) w.config(font=fb) tkinter.mainloop() PK!U}} messagebox.pynu[# tk common message boxes # # this module provides an interface to the native message boxes # available in Tk 4.2 and newer. # # written by Fredrik Lundh, May 1997 # # # options (all have default values): # # - default: which button to make default (one of the reply codes) # # - icon: which icon to display (see below) # # - message: the message to display # # - parent: which window to place the dialog on top of # # - title: dialog title # # - type: dialog type; that is, which buttons to display (see below) # from tkinter.commondialog import Dialog # # constants # icons ERROR = "error" INFO = "info" QUESTION = "question" WARNING = "warning" # types ABORTRETRYIGNORE = "abortretryignore" OK = "ok" OKCANCEL = "okcancel" RETRYCANCEL = "retrycancel" YESNO = "yesno" YESNOCANCEL = "yesnocancel" # replies ABORT = "abort" RETRY = "retry" IGNORE = "ignore" OK = "ok" CANCEL = "cancel" YES = "yes" NO = "no" # # message dialog class class Message(Dialog): "A message box" command = "tk_messageBox" # # convenience stuff # Rename _icon and _type options to allow overriding them in options def _show(title=None, message=None, _icon=None, _type=None, **options): if _icon and "icon" not in options: options["icon"] = _icon if _type and "type" not in options: options["type"] = _type if title: options["title"] = title if message: options["message"] = message res = Message(**options).show() # In some Tcl installations, yes/no is converted into a boolean. if isinstance(res, bool): if res: return YES return NO # In others we get a Tcl_Obj. return str(res) def showinfo(title=None, message=None, **options): "Show an info message" return _show(title, message, INFO, OK, **options) def showwarning(title=None, message=None, **options): "Show a warning message" return _show(title, message, WARNING, OK, **options) def showerror(title=None, message=None, **options): "Show an error message" return _show(title, message, ERROR, OK, **options) def askquestion(title=None, message=None, **options): "Ask a question" return _show(title, message, QUESTION, YESNO, **options) def askokcancel(title=None, message=None, **options): "Ask if operation should proceed; return true if the answer is ok" s = _show(title, message, QUESTION, OKCANCEL, **options) return s == OK def askyesno(title=None, message=None, **options): "Ask a question; return true if the answer is yes" s = _show(title, message, QUESTION, YESNO, **options) return s == YES def askyesnocancel(title=None, message=None, **options): "Ask a question; return true if the answer is yes, None if cancelled." s = _show(title, message, QUESTION, YESNOCANCEL, **options) # s might be a Tcl index object, so convert it to a string s = str(s) if s == CANCEL: return None return s == YES def askretrycancel(title=None, message=None, **options): "Ask if operation should be retried; return true if the answer is yes" s = _show(title, message, WARNING, RETRYCANCEL, **options) return s == RETRY # -------------------------------------------------------------------- # test stuff if __name__ == "__main__": print("info", showinfo("Spam", "Egg Information")) print("warning", showwarning("Spam", "Egg Warning")) print("error", showerror("Spam", "Egg Alert")) print("question", askquestion("Spam", "Question?")) print("proceed", askokcancel("Spam", "Proceed?")) print("yes/no", askyesno("Spam", "Got it?")) print("yes/no/cancel", askyesnocancel("Spam", "Want it?")) print("try again", askretrycancel("Spam", "Try again?")) PK!s88 filedialog.pynu["""File selection dialog classes. Classes: - FileDialog - LoadFileDialog - SaveFileDialog This module also presents tk common file dialogues, it provides interfaces to the native file dialogues available in Tk 4.2 and newer, and the directory dialogue available in Tk 8.3 and newer. These interfaces were written by Fredrik Lundh, May 1997. """ from tkinter import * from tkinter.dialog import Dialog from tkinter import commondialog from tkinter.simpledialog import _setup_dialog import os import fnmatch dialogstates = {} class FileDialog: """Standard file selection dialog -- no checks on selected file. Usage: d = FileDialog(master) fname = d.go(dir_or_file, pattern, default, key) if fname is None: ...canceled... else: ...open file... All arguments to go() are optional. The 'key' argument specifies a key in the global dictionary 'dialogstates', which keeps track of the values for the directory and pattern arguments, overriding the values passed in (it does not keep track of the default argument!). If no key is specified, the dialog keeps no memory of previous state. Note that memory is kept even when the dialog is canceled. (All this emulates the behavior of the Macintosh file selection dialogs.) """ title = "File Selection Dialog" def __init__(self, master, title=None): if title is None: title = self.title self.master = master self.directory = None self.top = Toplevel(master) self.top.title(title) self.top.iconname(title) _setup_dialog(self.top) self.botframe = Frame(self.top) self.botframe.pack(side=BOTTOM, fill=X) self.selection = Entry(self.top) self.selection.pack(side=BOTTOM, fill=X) self.selection.bind('', self.ok_event) self.filter = Entry(self.top) self.filter.pack(side=TOP, fill=X) self.filter.bind('', self.filter_command) self.midframe = Frame(self.top) self.midframe.pack(expand=YES, fill=BOTH) self.filesbar = Scrollbar(self.midframe) self.filesbar.pack(side=RIGHT, fill=Y) self.files = Listbox(self.midframe, exportselection=0, yscrollcommand=(self.filesbar, 'set')) self.files.pack(side=RIGHT, expand=YES, fill=BOTH) btags = self.files.bindtags() self.files.bindtags(btags[1:] + btags[:1]) self.files.bind('', self.files_select_event) self.files.bind('', self.files_double_event) self.filesbar.config(command=(self.files, 'yview')) self.dirsbar = Scrollbar(self.midframe) self.dirsbar.pack(side=LEFT, fill=Y) self.dirs = Listbox(self.midframe, exportselection=0, yscrollcommand=(self.dirsbar, 'set')) self.dirs.pack(side=LEFT, expand=YES, fill=BOTH) self.dirsbar.config(command=(self.dirs, 'yview')) btags = self.dirs.bindtags() self.dirs.bindtags(btags[1:] + btags[:1]) self.dirs.bind('', self.dirs_select_event) self.dirs.bind('', self.dirs_double_event) self.ok_button = Button(self.botframe, text="OK", command=self.ok_command) self.ok_button.pack(side=LEFT) self.filter_button = Button(self.botframe, text="Filter", command=self.filter_command) self.filter_button.pack(side=LEFT, expand=YES) self.cancel_button = Button(self.botframe, text="Cancel", command=self.cancel_command) self.cancel_button.pack(side=RIGHT) self.top.protocol('WM_DELETE_WINDOW', self.cancel_command) # XXX Are the following okay for a general audience? self.top.bind('', self.cancel_command) self.top.bind('', self.cancel_command) def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None): if key and key in dialogstates: self.directory, pattern = dialogstates[key] else: dir_or_file = os.path.expanduser(dir_or_file) if os.path.isdir(dir_or_file): self.directory = dir_or_file else: self.directory, default = os.path.split(dir_or_file) self.set_filter(self.directory, pattern) self.set_selection(default) self.filter_command() self.selection.focus_set() self.top.wait_visibility() # window needs to be visible for the grab self.top.grab_set() self.how = None self.master.mainloop() # Exited by self.quit(how) if key: directory, pattern = self.get_filter() if self.how: directory = os.path.dirname(self.how) dialogstates[key] = directory, pattern self.top.destroy() return self.how def quit(self, how=None): self.how = how self.master.quit() # Exit mainloop() def dirs_double_event(self, event): self.filter_command() def dirs_select_event(self, event): dir, pat = self.get_filter() subdir = self.dirs.get('active') dir = os.path.normpath(os.path.join(self.directory, subdir)) self.set_filter(dir, pat) def files_double_event(self, event): self.ok_command() def files_select_event(self, event): file = self.files.get('active') self.set_selection(file) def ok_event(self, event): self.ok_command() def ok_command(self): self.quit(self.get_selection()) def filter_command(self, event=None): dir, pat = self.get_filter() try: names = os.listdir(dir) except OSError: self.master.bell() return self.directory = dir self.set_filter(dir, pat) names.sort() subdirs = [os.pardir] matchingfiles = [] for name in names: fullname = os.path.join(dir, name) if os.path.isdir(fullname): subdirs.append(name) elif fnmatch.fnmatch(name, pat): matchingfiles.append(name) self.dirs.delete(0, END) for name in subdirs: self.dirs.insert(END, name) self.files.delete(0, END) for name in matchingfiles: self.files.insert(END, name) head, tail = os.path.split(self.get_selection()) if tail == os.curdir: tail = '' self.set_selection(tail) def get_filter(self): filter = self.filter.get() filter = os.path.expanduser(filter) if filter[-1:] == os.sep or os.path.isdir(filter): filter = os.path.join(filter, "*") return os.path.split(filter) def get_selection(self): file = self.selection.get() file = os.path.expanduser(file) return file def cancel_command(self, event=None): self.quit() def set_filter(self, dir, pat): if not os.path.isabs(dir): try: pwd = os.getcwd() except OSError: pwd = None if pwd: dir = os.path.join(pwd, dir) dir = os.path.normpath(dir) self.filter.delete(0, END) self.filter.insert(END, os.path.join(dir or os.curdir, pat or "*")) def set_selection(self, file): self.selection.delete(0, END) self.selection.insert(END, os.path.join(self.directory, file)) class LoadFileDialog(FileDialog): """File selection dialog which checks that the file exists.""" title = "Load File Selection Dialog" def ok_command(self): file = self.get_selection() if not os.path.isfile(file): self.master.bell() else: self.quit(file) class SaveFileDialog(FileDialog): """File selection dialog which checks that the file may be created.""" title = "Save File Selection Dialog" def ok_command(self): file = self.get_selection() if os.path.exists(file): if os.path.isdir(file): self.master.bell() return d = Dialog(self.top, title="Overwrite Existing File Question", text="Overwrite existing file %r?" % (file,), bitmap='questhead', default=1, strings=("Yes", "Cancel")) if d.num != 0: return else: head, tail = os.path.split(file) if not os.path.isdir(head): self.master.bell() return self.quit(file) # For the following classes and modules: # # options (all have default values): # # - defaultextension: added to filename if not explicitly given # # - filetypes: sequence of (label, pattern) tuples. the same pattern # may occur with several patterns. use "*" as pattern to indicate # all files. # # - initialdir: initial directory. preserved by dialog instance. # # - initialfile: initial file (ignored by the open dialog). preserved # by dialog instance. # # - parent: which window to place the dialog on top of # # - title: dialog title # # - multiple: if true user may select more than one file # # options for the directory chooser: # # - initialdir, parent, title: see above # # - mustexist: if true, user must pick an existing directory # class _Dialog(commondialog.Dialog): def _fixoptions(self): try: # make sure "filetypes" is a tuple self.options["filetypes"] = tuple(self.options["filetypes"]) except KeyError: pass def _fixresult(self, widget, result): if result: # keep directory and filename until next time # convert Tcl path objects to strings try: result = result.string except AttributeError: # it already is a string pass path, file = os.path.split(result) self.options["initialdir"] = path self.options["initialfile"] = file self.filename = result # compatibility return result # # file dialogs class Open(_Dialog): "Ask for a filename to open" command = "tk_getOpenFile" def _fixresult(self, widget, result): if isinstance(result, tuple): # multiple results: result = tuple([getattr(r, "string", r) for r in result]) if result: path, file = os.path.split(result[0]) self.options["initialdir"] = path # don't set initialfile or filename, as we have multiple of these return result if not widget.tk.wantobjects() and "multiple" in self.options: # Need to split result explicitly return self._fixresult(widget, widget.tk.splitlist(result)) return _Dialog._fixresult(self, widget, result) class SaveAs(_Dialog): "Ask for a filename to save as" command = "tk_getSaveFile" # the directory dialog has its own _fix routines. class Directory(commondialog.Dialog): "Ask for a directory" command = "tk_chooseDirectory" def _fixresult(self, widget, result): if result: # convert Tcl path objects to strings try: result = result.string except AttributeError: # it already is a string pass # keep directory until next time self.options["initialdir"] = result self.directory = result # compatibility return result # # convenience stuff def askopenfilename(**options): "Ask for a filename to open" return Open(**options).show() def asksaveasfilename(**options): "Ask for a filename to save as" return SaveAs(**options).show() def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 return Open(**options).show() # FIXME: are the following perhaps a bit too convenient? def askopenfile(mode = "r", **options): "Ask for a filename to open, and returned the opened file" filename = Open(**options).show() if filename: return open(filename, mode) return None def askopenfiles(mode = "r", **options): """Ask for multiple filenames and return the open file objects returns a list of open file objects or an empty list if cancel selected """ files = askopenfilenames(**options) if files: ofiles=[] for filename in files: ofiles.append(open(filename, mode)) files=ofiles return files def asksaveasfile(mode = "w", **options): "Ask for a filename to save as, and returned the opened file" filename = SaveAs(**options).show() if filename: return open(filename, mode) return None def askdirectory (**options): "Ask for a directory, and return the file name" return Directory(**options).show() # -------------------------------------------------------------------- # test stuff def test(): """Simple test program.""" root = Tk() root.withdraw() fd = LoadFileDialog(root) loadfile = fd.go(key="test") fd = SaveFileDialog(root) savefile = fd.go(key="test") print(loadfile, savefile) # Since the file name may contain non-ASCII characters, we need # to find an encoding that likely supports the file name, and # displays correctly on the terminal. # Start off with UTF-8 enc = "utf-8" import sys # See whether CODESET is defined try: import locale locale.setlocale(locale.LC_ALL,'') enc = locale.nl_langinfo(locale.CODESET) except (ImportError, AttributeError): pass # dialog for opening files openfilename=askopenfilename(filetypes=[("all files", "*")]) try: fp=open(openfilename,"r") fp.close() except: print("Could not open File: ") print(sys.exc_info()[1]) print("open", openfilename.encode(enc)) # dialog for saving files saveasfilename=asksaveasfilename() print("saveas", saveasfilename.encode(enc)) if __name__ == '__main__': test() PK!&--simpledialog.pynu[# # An Introduction to Tkinter # # Copyright (c) 1997 by Fredrik Lundh # # This copyright applies to Dialog, askinteger, askfloat and asktring # # fredrik@pythonware.com # http://www.pythonware.com # """This modules handles dialog boxes. It contains the following public symbols: SimpleDialog -- A simple but flexible modal dialog box Dialog -- a base class for dialogs askinteger -- get an integer from the user askfloat -- get a float from the user askstring -- get a string from the user """ from tkinter import * from tkinter import messagebox, _get_default_root class SimpleDialog: def __init__(self, master, text='', buttons=[], default=None, cancel=None, title=None, class_=None): if class_: self.root = Toplevel(master, class_=class_) else: self.root = Toplevel(master) if title: self.root.title(title) self.root.iconname(title) _setup_dialog(self.root) self.message = Message(self.root, text=text, aspect=400) self.message.pack(expand=1, fill=BOTH) self.frame = Frame(self.root) self.frame.pack() self.num = default self.cancel = cancel self.default = default self.root.bind('', self.return_event) for num in range(len(buttons)): s = buttons[num] b = Button(self.frame, text=s, command=(lambda self=self, num=num: self.done(num))) if num == default: b.config(relief=RIDGE, borderwidth=8) b.pack(side=LEFT, fill=BOTH, expand=1) self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window) self._set_transient(master) def _set_transient(self, master, relx=0.5, rely=0.3): widget = self.root widget.withdraw() # Remain invisible while we figure out the geometry widget.transient(master) widget.update_idletasks() # Actualize geometry information if master.winfo_ismapped(): m_width = master.winfo_width() m_height = master.winfo_height() m_x = master.winfo_rootx() m_y = master.winfo_rooty() else: m_width = master.winfo_screenwidth() m_height = master.winfo_screenheight() m_x = m_y = 0 w_width = widget.winfo_reqwidth() w_height = widget.winfo_reqheight() x = m_x + (m_width - w_width) * relx y = m_y + (m_height - w_height) * rely if x+w_width > master.winfo_screenwidth(): x = master.winfo_screenwidth() - w_width elif x < 0: x = 0 if y+w_height > master.winfo_screenheight(): y = master.winfo_screenheight() - w_height elif y < 0: y = 0 widget.geometry("+%d+%d" % (x, y)) widget.deiconify() # Become visible at the desired location def go(self): self.root.wait_visibility() self.root.grab_set() self.root.mainloop() self.root.destroy() return self.num def return_event(self, event): if self.default is None: self.root.bell() else: self.done(self.default) def wm_delete_window(self): if self.cancel is None: self.root.bell() else: self.done(self.cancel) def done(self, num): self.num = num self.root.quit() class Dialog(Toplevel): '''Class to open dialogs. This class is intended as a base class for custom dialogs ''' def __init__(self, parent, title = None): '''Initialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title ''' master = parent if not master: master = _get_default_root('create dialog window') Toplevel.__init__(self, master) self.withdraw() # remain invisible for now # If the parent is not viewable, don't # make the child transient, or else it # would be opened withdrawn if parent is not None and parent.winfo_viewable(): self.transient(parent) if title: self.title(title) _setup_dialog(self) self.parent = parent self.result = None body = Frame(self) self.initial_focus = self.body(body) body.pack(padx=5, pady=5) self.buttonbox() if not self.initial_focus: self.initial_focus = self self.protocol("WM_DELETE_WINDOW", self.cancel) if parent is not None: self.geometry("+%d+%d" % (parent.winfo_rootx()+50, parent.winfo_rooty()+50)) self.deiconify() # become visible now self.initial_focus.focus_set() # wait for window to appear on screen before calling grab_set self.wait_visibility() self.grab_set() self.wait_window(self) def destroy(self): '''Destroy the window''' self.initial_focus = None Toplevel.destroy(self) # # construction hooks def body(self, master): '''create dialog body. return widget that should have initial focus. This method should be overridden, and is called by the __init__ method. ''' pass def buttonbox(self): '''add standard button box. override if you do not want the standard buttons ''' box = Frame(self) w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE) w.pack(side=LEFT, padx=5, pady=5) w = Button(box, text="Cancel", width=10, command=self.cancel) w.pack(side=LEFT, padx=5, pady=5) self.bind("", self.ok) self.bind("", self.cancel) box.pack() # # standard button semantics def ok(self, event=None): if not self.validate(): self.initial_focus.focus_set() # put focus back return self.withdraw() self.update_idletasks() try: self.apply() finally: self.cancel() def cancel(self, event=None): # put focus back to the parent window if self.parent is not None: self.parent.focus_set() self.destroy() # # command hooks def validate(self): '''validate the data This method is called automatically to validate the data before the dialog is destroyed. By default, it always validates OK. ''' return 1 # override def apply(self): '''process the data This method is called automatically to process the data, *after* the dialog is destroyed. By default, it does nothing. ''' pass # override def _setup_dialog(w): if w._windowingsystem == "aqua": w.tk.call("::tk::unsupported::MacWindowStyle", "style", w, "moveableModal", "") elif w._windowingsystem == "x11": w.wm_attributes("-type", "dialog") # -------------------------------------------------------------------- # convenience dialogues class _QueryDialog(Dialog): def __init__(self, title, prompt, initialvalue=None, minvalue = None, maxvalue = None, parent = None): self.prompt = prompt self.minvalue = minvalue self.maxvalue = maxvalue self.initialvalue = initialvalue Dialog.__init__(self, parent, title) def destroy(self): self.entry = None Dialog.destroy(self) def body(self, master): w = Label(master, text=self.prompt, justify=LEFT) w.grid(row=0, padx=5, sticky=W) self.entry = Entry(master, name="entry") self.entry.grid(row=1, padx=5, sticky=W+E) if self.initialvalue is not None: self.entry.insert(0, self.initialvalue) self.entry.select_range(0, END) return self.entry def validate(self): try: result = self.getresult() except ValueError: messagebox.showwarning( "Illegal value", self.errormessage + "\nPlease try again", parent = self ) return 0 if self.minvalue is not None and result < self.minvalue: messagebox.showwarning( "Too small", "The allowed minimum value is %s. " "Please try again." % self.minvalue, parent = self ) return 0 if self.maxvalue is not None and result > self.maxvalue: messagebox.showwarning( "Too large", "The allowed maximum value is %s. " "Please try again." % self.maxvalue, parent = self ) return 0 self.result = result return 1 class _QueryInteger(_QueryDialog): errormessage = "Not an integer." def getresult(self): return self.getint(self.entry.get()) def askinteger(title, prompt, **kw): '''get an integer from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is an integer ''' d = _QueryInteger(title, prompt, **kw) return d.result class _QueryFloat(_QueryDialog): errormessage = "Not a floating point value." def getresult(self): return self.getdouble(self.entry.get()) def askfloat(title, prompt, **kw): '''get a float from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a float ''' d = _QueryFloat(title, prompt, **kw) return d.result class _QueryString(_QueryDialog): def __init__(self, *args, **kw): if "show" in kw: self.__show = kw["show"] del kw["show"] else: self.__show = None _QueryDialog.__init__(self, *args, **kw) def body(self, master): entry = _QueryDialog.body(self, master) if self.__show is not None: entry.configure(show=self.__show) return entry def getresult(self): return self.entry.get() def askstring(title, prompt, **kw): '''get a string from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a string ''' d = _QueryString(title, prompt, **kw) return d.result if __name__ == '__main__': def test(): root = Tk() def doit(root=root): d = SimpleDialog(root, text="This is a test dialog. " "Would this have been an actual dialog, " "the buttons below would have been glowing " "in soft pink light.\n" "Do you believe this?", buttons=["Yes", "No", "Cancel"], default=0, cancel=2, title="Test Dialog") print(d.go()) print(askinteger("Spam", "Egg count", initialvalue=12*12)) print(askfloat("Spam", "Egg weight\n(in tons)", minvalue=1, maxvalue=100)) print(askstring("Spam", "Egg label")) t = Button(root, text='Test', command=doit) t.pack() q = Button(root, text='Quit', command=t.quit) q.pack() t.mainloop() test() PK!jxx*__pycache__/constants.cpython-38.opt-1.pycnu[U e5d@s8dZZZdZZZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Zd;Z?dZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIS)JnsweZnwswneZsensZewZnsewcenterZnonexyZbothlefttoprightZbottomZraisedZsunkenZflatZridgeZgrooveZsolidZ horizontalZverticalnumericcharZwordZbaselineZinsideZoutsideZselz sel.firstzsel.lastendinsertZcurrentZanchorallZnormalZdisabledZactiveZhiddenZcascadeZ checkbuttonZcommandZ radiobuttonZ separatorZsingleZbrowseZmultipleZextendedZdotboxZ underlineZpiesliceZchordZarcfirstZlastZbuttZ projectingroundZbevelZmiterZmovetoZscrollZunitsZpagesN)MZNOZFALSEZOFFZYESZTRUEZONNSWEZNWZSWZNEZSEZNSZEWZNSEWZCENTERZNONEXYZBOTHZLEFTZTOPZRIGHTZBOTTOMZRAISEDZSUNKENZFLATZRIDGEZGROOVEZSOLIDZ HORIZONTALZVERTICALZNUMERICZCHARZWORDZBASELINEZINSIDEZOUTSIDEZSELZ SEL_FIRSTZSEL_LASTZENDZINSERTZCURRENTZANCHORZALLZNORMALZDISABLEDZACTIVEZHIDDENZCASCADEZ CHECKBUTTONZCOMMANDZ RADIOBUTTONZ SEPARATORZSINGLEZBROWSEZMULTIPLEZEXTENDEDZDOTBOXZ UNDERLINEZPIESLICEZCHORDZARCZFIRSTZLASTZBUTTZ PROJECTINGZROUNDZBEVELZMITERZMOVETOZSCROLLZUNITSZPAGESrr)/usr/lib64/python3.8/tkinter/constants.pys  PK!00%__pycache__/filedialog.cpython-38.pycnu[U e5d8@sdZddlTddlmZddlmZddlmZddlZddlZiZ GdddZ Gd d d e Z Gd d d e Z Gd ddejZ Gddde ZGddde ZGdddejZddZddZddZd(ddZd)ddZd*d!d"Zd#d$Zd%d&Zed'kr edS)+aUFile selection dialog classes. Classes: - FileDialog - LoadFileDialog - SaveFileDialog This module also presents tk common file dialogues, it provides interfaces to the native file dialogues available in Tk 4.2 and newer, and the directory dialogue available in Tk 8.3 and newer. These interfaces were written by Fredrik Lundh, May 1997. )*)Dialog) commondialog) _setup_dialogNc@seZdZdZdZd$ddZejdddfdd Zd%d d Z d d Z ddZ ddZ ddZ ddZddZd&ddZddZddZd'ddZd d!Zd"d#ZdS)( FileDialogaStandard file selection dialog -- no checks on selected file. Usage: d = FileDialog(master) fname = d.go(dir_or_file, pattern, default, key) if fname is None: ...canceled... else: ...open file... All arguments to go() are optional. The 'key' argument specifies a key in the global dictionary 'dialogstates', which keeps track of the values for the directory and pattern arguments, overriding the values passed in (it does not keep track of the default argument!). If no key is specified, the dialog keeps no memory of previous state. Note that memory is kept even when the dialog is canceled. (All this emulates the behavior of the Macintosh file selection dialogs.) zFile Selection DialogNcCs|dkr|j}||_d|_t||_|j||j|t|jt|j|_|jj t t dt |j|_ |j j t t d|j d|jt |j|_|jj tt d|jd|jt|j|_|jj ttdt|j|_|jj ttdt|jd|jdfd|_|jj tttd|j}|j|dd|dd|jd |j|jd |j|jj|jd fd t|j|_ |j j t!tdt|jd|j dfd|_"|j"j t!ttd|j j|j"d fd |j"}|j"|dd|dd|j"d |j#|j"d |j$t%|jd |j&d|_'|j'j t!dt%|jd|jd|_(|j(j t!tdt%|jd|j)d|_*|j*j td|j+d|j)|jd|j)|jd|j)dS)N)sidefillz)expandrrset)ZexportselectionZyscrollcommand)rr rzzZyview)commandZOK)textr )rZFilter)rr CancelZWM_DELETE_WINDOWzz),titlemaster directoryZTopleveltopZiconnamerZFrameZbotframeZpackZBOTTOMXZEntry selectionZbindok_eventfilterZTOPfilter_commandZmidframeZYESZBOTHZ ScrollbarZfilesbarZRIGHTYZListboxfilesZbindtagsfiles_select_eventfiles_double_eventZconfigZdirsbarZLEFTdirsdirs_select_eventdirs_double_eventZButton ok_commandZ ok_buttonZ filter_buttoncancel_commandZ cancel_buttonZprotocol)selfrrZbtagsr"*/usr/lib64/python3.8/tkinter/filedialog.py__init__4st              zFileDialog.__init__rcCs|r|tkrt|\|_}n2tj|}tj|r<||_ntj|\|_}||j|||| |j |j |j d|_|j|r|\}}|jrtj|j}||ft|<|j |jSN) dialogstatesrospath expanduserisdirsplit set_filter set_selectionrrZ focus_setrZwait_visibilityZgrab_sethowrZmainloop get_filterdirnameZdestroy)r!Z dir_or_filepatterndefaultkeyrr"r"r#gots*           z FileDialog.gocCs||_|jdSr&)r/rquit)r!r/r"r"r#r6szFileDialog.quitcCs |dSr&)rr!eventr"r"r#rszFileDialog.dirs_double_eventcCs@|\}}|jd}tjtj|j|}|||dSNZactive) r0rgetr(r)normpathjoinrr-)r!r8dirpatZsubdirr"r"r#rs  zFileDialog.dirs_select_eventcCs |dSr&rr7r"r"r#rszFileDialog.files_double_eventcCs|jd}||dSr9)rr:r.)r!r8filer"r"r#rs zFileDialog.files_select_eventcCs |dSr&r?r7r"r"r#rszFileDialog.ok_eventcCs||dSr&)r6 get_selectionr!r"r"r#rszFileDialog.ok_commandc Cs&|\}}zt|}Wn tk r:|jYdSX||_||||tj g}g}|D]@}tj ||}tj |r| |qft||rf| |qf|jdt|D]}|jt|q|jdt|D]}|jt|qtj |\} } | tjkrd} || dS)Nrr%)r0r(listdirOSErrorrbellrr-sortpardirr)r<r+appendfnmatchrdeleteENDinsertrr,rAcurdirr.) r!r8r=r>namesZsubdirsZ matchingfilesnamefullnameheadtailr"r"r#rs6        zFileDialog.filter_commandcCsN|j}tj|}|ddtjks4tj|rBtj|d}tj|S)Nr) rr:r(r)r*sepr+r<r,)r!rr"r"r#r0s   zFileDialog.get_filtercCs|j}tj|}|Sr&)rr:r(r)r*r!r@r"r"r#rAs  zFileDialog.get_selectioncCs |dSr&)r6r7r"r"r#r szFileDialog.cancel_commandcCstj|sPz t}Wntk r0d}YnX|rPtj||}tj|}|jdt |j t tj|pttj |pzddS)Nrr) r(r)isabsgetcwdrDr<r;rrJrKrLrM)r!r=r>pwdr"r"r#r-s    zFileDialog.set_filtercCs,|jdt|jttj|j|dS)Nr)rrJrKrLr(r)r<rrUr"r"r#r.szFileDialog.set_selection)N)N)N)N)__name__ __module__ __qualname____doc__rr$r(rMr5r6rrrrrrrr0rAr r-r.r"r"r"r#rs" @    rc@seZdZdZdZddZdS)LoadFileDialogz8File selection dialog which checks that the file exists.zLoad File Selection DialogcCs.|}tj|s |jn ||dSr&)rAr(r)isfilerrEr6rUr"r"r#rs  zLoadFileDialog.ok_commandNrYrZr[r\rrr"r"r"r#r]sr]c@seZdZdZdZddZdS)SaveFileDialogz@File selection dialog which checks that the file may be created.zSave File Selection DialogcCs|}tj|rZtj|r.|jdSt|jdd|fdddd}|j dkrdSn*tj |\}}tj|s|jdS| |dS)Nz Overwrite Existing File QuestionzOverwrite existing file %r?Z questheadr )ZYesr)rr Zbitmapr3Zstringsr) rAr(r)existsr+rrErrZnumr,r6)r!r@drQrRr"r"r#rs&      zSaveFileDialog.ok_commandNr_r"r"r"r#r`sr`c@seZdZddZddZdS)_DialogcCs2zt|jd|jd<Wntk r,YnXdS)N filetypes)tupleoptionsKeyErrorrBr"r"r# _fixoptions,sz_Dialog._fixoptionscCsR|rHz |j}Wntk r"YnXtj|\}}||jd<||jd<||_|S)N initialdirZ initialfile)stringAttributeErrorr(r)r,rffilenamer!widgetresultr)r@r"r"r# _fixresult3s   z_Dialog._fixresultN)rYrZr[rhrpr"r"r"r#rc*srcc@seZdZdZdZddZdS)OpenAsk for a filename to openZtk_getOpenFilecCsxt|trBtdd|D}|r>tj|d\}}||jd<|S|jsjd|jkrj|||j |St |||S)NcSsg|]}t|d|qS)rj)getattr).0rr"r"r# Nsz#Open._fixresult..rrimultiple) isinstancerer(r)r,rfZtkZ wantobjectsrpZ splitlistrcrmr"r"r#rpKs  zOpen._fixresultNrYrZr[r\r rpr"r"r"r#rqFsrqc@seZdZdZdZdS)SaveAsAsk for a filename to save asZtk_getSaveFileN)rYrZr[r\r r"r"r"r#rzZsrzc@seZdZdZdZddZdS) DirectoryzAsk for a directoryZtk_chooseDirectorycCs8|r.z |j}Wntk r"YnX||jd<||_|S)Nri)rjrkrfr)r!rnror"r"r#rpfs  zDirectory._fixresultNryr"r"r"r#r|asr|cKstf|S)rrrqshowrfr"r"r#askopenfilenamewsrcKstf|S)r{)rzr~rr"r"r#asksaveasfilename}srcKsd|d<tf|S)ztAsk for multiple filenames to open Returns a list of filenames or empty list if cancel button selected r rwr}rr"r"r#askopenfilenamessrrucKs tf|}|rt||SdS)z8Ask for a filename to open, and returned the opened fileN)rqr~openmoderfrlr"r"r# askopenfiles rcKs4tf|}|r0g}|D]}|t||q|}|S)zAsk for multiple filenames and return the open file objects returns a list of open file objects or an empty list if cancel selected )rrHr)rrfrZofilesrlr"r"r# askopenfiless rwcKs tf|}|rt||SdS)z;Ask for a filename to save as, and returned the opened fileN)rzr~rrr"r"r# asksaveasfiles rcKstf|S)z-Ask for a directory, and return the file name)r|r~rr"r"r# askdirectorysrc Cst}|t|}|jdd}t|}|jdd}t||d}ddl}z&ddl}||j d| |j }Wnt t fk rYnXtdgd}zt|d }|Wn$td t|d YnXtd ||t} td | |dS)zSimple test program.test)r4zutf-8rNr%)z all filesr)rdruzCould not open File: r rZsaveas)ZTkZwithdrawr]r5r`printsyslocale setlocaleLC_ALL nl_langinfoCODESET ImportErrorrkrrcloseexc_infoencoder) rootfdZloadfileZsavefileencrrZ openfilenamefpZsaveasfilenamer"r"r#rs2      r__main__)ru)ru)r)r\ZtkinterZtkinter.dialogrrZtkinter.simpledialogrr(rIr'rr]r`rcrqrzr|rrrrrrrrrYr"r"r"r#s2   I9  , PK!z`,,$__pycache__/dnd.cpython-38.opt-1.pycnu[U e5d,@sXdZddlZddZGdddZGdddZGd d d Zd d Zed krTedS)aFDrag-and-drop support for Tkinter. This is very preliminary. I currently only support dnd *within* one application, between different windows (or within the same window). I am trying to make this as generic as possible -- not dependent on the use of a particular widget or icon type, etc. I also hope that this will work with Pmw. To enable an object to be dragged, you must create an event binding for it that starts the drag-and-drop process. Typically, you should bind to a callback function that you write. The function should call Tkdnd.dnd_start(source, event), where 'source' is the object to be dragged, and 'event' is the event that invoked the call (the argument to your callback function). Even though this is a class instantiation, the returned instance should not be stored -- it will be kept alive automatically for the duration of the drag-and-drop. When a drag-and-drop is already in process for the Tk interpreter, the call is *ignored*; this normally averts starting multiple simultaneous dnd processes, e.g. because different button callbacks all dnd_start(). The object is *not* necessarily a widget -- it can be any application-specific object that is meaningful to potential drag-and-drop targets. Potential drag-and-drop targets are discovered as follows. Whenever the mouse moves, and at the start and end of a drag-and-drop move, the Tk widget directly under the mouse is inspected. This is the target widget (not to be confused with the target object, yet to be determined). If there is no target widget, there is no dnd target object. If there is a target widget, and it has an attribute dnd_accept, this should be a function (or any callable object). The function is called as dnd_accept(source, event), where 'source' is the object being dragged (the object passed to dnd_start() above), and 'event' is the most recent event object (generally a event; it can also be or ). If the dnd_accept() function returns something other than None, this is the new dnd target object. If dnd_accept() returns None, or if the target widget has no dnd_accept attribute, the target widget's parent is considered as the target widget, and the search for a target object is repeated from there. If necessary, the search is repeated all the way up to the root widget. If none of the target widgets can produce a target object, there is no target object (the target object is None). The target object thus produced, if any, is called the new target object. It is compared with the old target object (or None, if there was no old target widget). There are several cases ('source' is the source object, and 'event' is the most recent event object): - Both the old and new target objects are None. Nothing happens. - The old and new target objects are the same object. Its method dnd_motion(source, event) is called. - The old target object was None, and the new target object is not None. The new target object's method dnd_enter(source, event) is called. - The new target object is None, and the old target object is not None. The old target object's method dnd_leave(source, event) is called. - The old and new target objects differ and neither is None. The old target object's method dnd_leave(source, event), and then the new target object's method dnd_enter(source, event) is called. Once this is done, the new target object replaces the old one, and the Tk mainloop proceeds. The return value of the methods mentioned above is ignored; if they raise an exception, the normal exception handling mechanisms take over. The drag-and-drop processes can end in two ways: a final target object is selected, or no final target object is selected. When a final target object is selected, it will always have been notified of the potential drop by a call to its dnd_enter() method, as described above, and possibly one or more calls to its dnd_motion() method; its dnd_leave() method has not been called since the last call to dnd_enter(). The target is notified of the drop by a call to its method dnd_commit(source, event). If no final target object is selected, and there was an old target object, its dnd_leave(source, event) method is called to complete the dnd sequence. Finally, the source object is notified that the drag-and-drop process is over, by a call to source.dnd_end(target, event), specifying either the selected target object, or None if no target object was selected. The source object can use this to implement the commit action; this is sometimes simpler than to do it in the target's dnd_commit(). The target's dnd_commit() method could then simply be aliased to dnd_leave(). At any time during a dnd sequence, the application can cancel the sequence by calling the cancel() method on the object returned by dnd_start(). This will call dnd_leave() if a target is currently active; it will never call dnd_commit(). NcCst||}|jr|SdSdSN) DndHandlerroot)sourceeventhr#/usr/lib64/python3.8/tkinter/dnd.py dnd_startls r c@sDeZdZdZddZddZddZdd Zdd d Zdd dZ dS)rNcCs|jdkrdS|j}z |jWdStk rD||_||_YnX||_d|_|j|_}|j|_ }d||f|_ |dpd|_ | |j |j | d|jd|d<dS)NzcursorZhand2)ZnumwidgetZ_root_DndHandler__dndAttributeErrorrrtargetZinitial_buttoninitial_widgetrelease_pattern save_cursorbind on_release on_motion)selfrrrZbuttonrrrr __init__zs$     zDndHandler.__init__cCs2|j}d|_|r.z|`Wntk r,YnXdSr)rrrrrrrr __del__szDndHandler.__del__c Cs|j|j}}|j||}|j}d}|rbz |j}Wntk rHYnX|||}|rZqb|j}q&|j}||kr|r| ||n,|rd|_| |||r| ||||_dSr) x_rooty_rootrZwinfo_containingr dnd_acceptrZmasterr dnd_motion dnd_leave dnd_enter) rrxyZ target_widgetr new_targetattrZ old_targetrrr rs.    zDndHandler.on_motioncCs||ddS)Nfinishrrrrr rszDndHandler.on_releasecCs||ddS)Nrr(r*rrr cancelszDndHandler.cancelrc Cs|j}|j}|j}|j}zf|`|j|j|jd|j|d<d|_|_|_|_|r||rp| ||n | ||W5|||XdS)Nrr ) rrrrdnd_endrZunbindrr dnd_commitr!)rrZcommitrrrrrrr r)s  zDndHandler.finish)N)r) __name__ __module__ __qualname__rrrrrr+r)rrrr rvs  rc@sNeZdZddZdddZddZdd Zd d Zd d ZddZ ddZ dS)IconcCs||_d|_|_|_dSr)namecanvaslabelid)rr2rrr rsz Icon.__init__ cCs||jkr |j|j||dS|jr.||s6dStj||jddd}|j|||dd}||_||_||_| d|j dS)NZraised)textZ borderwidthZreliefZnw)ZwindowZanchorz ) r3coordsr5detachtkinterZLabelr2Z create_windowr4rpress)rr3r#r$r4r5rrr attachs   z Icon.attachcCsB|j}|sdS|j}|j}d|_|_|_|||dSr)r3r5r4deleteZdestroy)rr3r5r4rrr r:s z Icon.detachcCs4t||r0|j|_|j|_|j|j\|_|_ dSr) r r#x_offr$y_offr3r9r5x_origy_origr*rrr r<s z Icon.presscCs(||j|\}}|j|j||dSr)wherer3r9r5)rrr#r$rrr movesz Icon.movecCs|j|j|j|jdSr)r3r9r5rArB)rrrr putbacksz Icon.putbackcCs8|}|}|j|}|j|}||j||jfSr)Z winfo_rootxZ winfo_rootyrrr?r@)rr3rZx_orgZy_orgr#r$rrr rCs   z Icon.wherecCsdSrr)rrrrrr r,sz Icon.dnd_endN)r6r6) r.r/r0rr=r:r<rDrErCr,rrrr r1s   r1c@s<eZdZddZddZddZddZd d Zd d Zd S)TestercCs>t||_tj|jddd|_|jjddd|j|j_dS)Nd)widthZheightZbothr')Zfillexpand)r;ZTopleveltopZCanvasr3packrrrrr rs zTester.__init__cCs|Srrrrrrrr rszTester.dnd_acceptc Csp|j||j|\}}|j|j\}}}}||||} } |j|||| || |_|||dSr)r3 focus_setrCbboxr5Zcreate_rectangledndidr ) rrrr#r$x1y1x2y2ZdxZdyrrr r"s  zTester.dnd_enterc CsF||j|\}}|j|j\}}}}|j|j||||dSr)rCr3rNrOrD) rrrr#r$rPrQrRrSrrr r szTester.dnd_motioncCs"|j|j|jd|_dSr)rJrMr3r>rOrLrrr r!$s zTester.dnd_leavecCs2|||||j|\}}||j||dSr)r!rCr3r=)rrrr#r$rrr r-)s zTester.dnd_commitN) r.r/r0rrr"r r!r-rrrr rF s rFcCst}|dtj|jddt|}|jdt|}|jdt|}|jdtd}td}td }| |j | |j | |j | dS) Nz+1+1ZQuit)Zcommandr8z+1+60z+120+60z+240+60ZICON1ZICON2ZICON3) r;ZTkZgeometryZButtonquitrKrFrJr1r=r3Zmainloop)rt1t2Zt3Zi1Zi2Zi3rrr test/s        rW__main__)__doc__r;r rr1rFrWr.rrrr sf Y=#PK!s-__pycache__/scrolledtext.cpython-38.opt-1.pycnu[U e5d@sldZdgZddlmZmZmZmZmZmZddl m Z m Z m Z m Z GdddeZddZedkrhed S) aA ScrolledText widget feels like a text widget but also has a vertical scroll bar on its right. (Later, options may be added to add a horizontal bar as well, to make the bars disappear automatically when not needed, to move them to the other side of the window, etc.) Configuration options are passed to the Text widget. A Frame widget is inserted between the master and the text, to hold the Scrollbar widget. Most methods calls are inherited from the Text widget; Pack, Grid and Place methods are redirected to the Frame widget however. ScrolledText)FrameText ScrollbarPackGridPlace)RIGHTLEFTYBOTHc@seZdZdddZddZdS)rNcKst||_t|j|_|jjttd|d|jjit j ||jf||jt t dd|j |jd<tt }ttttBttB}||}|D]4}|ddkr|dkr|d krt||t|j|qdS) N)sidefillZyscrollcommandT)r rexpandZcommandr_ZconfigZ configure)rframerZvbarpackr r updatesetr__init__r r Zyviewvarskeysrrr differencesetattrgetattr)selfZmasterkwZ text_methsmethodsmr,/usr/lib64/python3.8/tkinter/scrolledtext.pyrs    $ zScrolledText.__init__cCs t|jS)N)strr)rrrr __str__)szScrolledText.__str__)N)__name__ __module__ __qualname__rr"rrrr rs cCsHddlm}tddd}||t|jttdd|| dS)Nr)ENDZwhite )ZbgZheightT)rr r) tkinter.constantsr&rinsert__doc__rr r Z focus_setZmainloop)r&Zstextrrr example-s    r+__main__N)r*__all__Ztkinterrrrrrrr(r r r r rr+r#rrrr s   PK!ҧ'__pycache__/dialog.cpython-38.opt-2.pycnu[U e5d@srddlTddlmZdZGdddeZddZedkrned d d d eeiiZ ed d d d e j eiiZ e d S))*) _cnfmergeZ questheadc@s"eZdZdifddZddZdS)DialogNc Kst||f}d|_t||||j|jjd|j|d|d|d|df|d|_zt |Wnt k r~YnXdS)NZ __dialog__Z tk_dialogtitletextbitmapdefaultstrings) rZ widgetNameWidget_setupZtkZgetintZcallZ_wnumdestroyZTclError)selfZmasterZcnfkwr&/usr/lib64/python3.8/tkinter/dialog.py__init__ s& zDialog.__init__cCsdS)Nr)rrrrr zDialog.destroy)__name__ __module__ __qualname__rr rrrrr s rcCs$tdddtddd}t|jdS)Nz File ModifiedzzFile "Python.h" has been modified since the last time it was saved. Do you want to save it before exiting the application.r)z Save FilezDiscard ChangeszReturn to Editor)rrrrr )r DIALOG_ICONprintr )drrr_tests r__main__NrZTestZcommandZQuit) Ztkinterrrr rrrZButtonZPacktquitqZmainlooprrrrs$ PK!D@**'__pycache__/simpledialog.cpython-38.pycnu[U e5d-@sdZddlTddlmZmZGdddZGdddeZdd ZGd d d eZGd d d eZ ddZ GdddeZ ddZ GdddeZ ddZedkrddZedS)a&This modules handles dialog boxes. It contains the following public symbols: SimpleDialog -- A simple but flexible modal dialog box Dialog -- a base class for dialogs askinteger -- get an integer from the user askfloat -- get a float from the user askstring -- get a string from the user )*) messagebox_get_default_rootc@sLeZdZdgddddfddZdddZd d Zd d Zd dZddZdS) SimpleDialogNc Cs|rt||d|_n t||_|r:|j||j|t|jt|j|dd|_|jjdtdt |j|_ |j ||_ ||_ ||_ |jd|jtt|D]L}||} t|j | ||fddd } ||kr| jtd d | jttdd q|jd |j||dS)N)class_i)textZaspect)expandfillcSs ||SN)doneselfnumr,/usr/lib64/python3.8/tkinter/simpledialog.py8z'SimpleDialog.__init__..rcommand)ZreliefZ borderwidth)sider r WM_DELETE_WINDOW)ToplevelroottitleZiconname _setup_dialogZMessagemessagepackZBOTHFrameframercanceldefaultbind return_eventrangelenButtonZconfigZRIDGELEFTprotocolwm_delete_window_set_transient) rmasterrbuttonsr$r#rrrsbrrr__init__ s2       zSimpleDialog.__init__?333333?c Cs|j}|||||rJ|}|}|}|}n| }| }d}}| } | } ||| |} ||| |} | | | kr| | } n | dkrd} | | | kr| | } n | dkrd} | d| | f|dS)Nr+%d+%d)rwithdraw transientupdate_idletasksZwinfo_ismappedZ winfo_widthZ winfo_height winfo_rootx winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheightgeometry deiconify) rr.ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_heightxyrrrr-?s4  zSimpleDialog._set_transientcCs.|j|j|j|j|jSr )rwait_visibilitygrab_setmainloopdestroyrrrrrgo\s     zSimpleDialog.gocCs&|jdkr|jn ||jdSr )r$rbellrrZeventrrrr&cs  zSimpleDialog.return_eventcCs&|jdkr|jn ||jdSr )r#rrErrCrrrr,is  zSimpleDialog.wm_delete_windowcCs||_|jdSr )rrquitrrrrroszSimpleDialog.done)r3r4) __name__ __module__ __qualname__r2r-rDr&r,rrrrrrs  rc@sVeZdZdZdddZddZddZd d Zdd d Zdd dZ ddZ ddZ dS)DialogzZClass to open dialogs. This class is intended as a base class for custom dialogs NcCs|}|std}t||||dk r>|r>|||rL||t|||_d|_ t |}| ||_ |j ddd||j s||_ |d|j|dk r|d|d|df||j ||||dS)zInitialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title zcreate dialog windowN)padxpadyrr52)rrr2r6Zwinfo_viewabler7rrparentresultr!body initial_focusr buttonboxr+r#r;r9r:r< focus_setr?r@Z wait_window)rrPrr.rRrrrr2{s8       zDialog.__init__cCsd|_t|dS)zDestroy the windowN)rSrrBrCrrrrBszDialog.destroycCsdS)zcreate dialog body. return widget that should have initial focus. This method should be overridden, and is called by the __init__ method. Nr)rr.rrrrRsz Dialog.bodycCsvt|}t|dd|jtd}|jtdddt|dd|jd}|jtddd|d|j|d |j|d S) z[add standard button box. override if you do not want the standard buttons ZOK )rwidthrr$rL)rrMrNCancel)rrWrr zN)r!r)okZACTIVEr r*r#r%)rZboxwrrrrTszDialog.buttonboxcCsB|s|jdS||z |W5|XdSr )validaterSrUr6r8r#applyrFrrrrYs  z Dialog.okcCs |jdk r|j|dSr )rPrUrBrFrrrr#s  z Dialog.cancelcCsdS)zvalidate the data This method is called automatically to validate the data before the dialog is destroyed. By default, it always validates OK. r rrCrrrr[szDialog.validatecCsdS)zprocess the data This method is called automatically to process the data, *after* the dialog is destroyed. By default, it does nothing. NrrCrrrr\sz Dialog.apply)N)N)N) rHrIrJ__doc__r2rBrRrTrYr#r[r\rrrrrKts 7    rKcCs:|jdkr |jdd|ddn|jdkr6|dddS) NZaquaz!::tk::unsupported::MacWindowStyleZstyleZ moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkZcallZ wm_attributes)rZrrrrs   rc@s.eZdZd ddZddZddZdd ZdS) _QueryDialogNcCs*||_||_||_||_t|||dSr )promptminvaluemaxvalue initialvaluerKr2)rrr_rbr`rarPrrrr2s z_QueryDialog.__init__cCsd|_t|dSr )entryrKrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdk rl|j d|j|j dt |jS)N)rZjustifyrrL)rowrMZstickyrc)namer ) ZLabelr_r*ZgridWZEntryrcErbinsertZ select_rangeZEND)rr.rZrrrrR s z_QueryDialog.bodycCsz |}Wn,tk r8tjd|jd|dYdSX|jdk rh||jkrhtjdd|j|ddS|jdk r||jkrtjdd|j|ddS||_d S) Nz Illegal valuez Please try again)rPrz Too smallz2The allowed minimum value is %s. Please try again.z Too largez2The allowed maximum value is %s. Please try again.r ) getresult ValueErrorr showwarning errormessager`rarQ)rrQrrrr[.s: z_QueryDialog.validate)NNNN)rHrIrJr2rBrRr[rrrrr^ s r^c@seZdZdZddZdS) _QueryIntegerzNot an integer.cCs||jSr )ZgetintrcgetrCrrrriSsz_QueryInteger.getresultNrHrIrJrlrirrrrrmPsrmcKst||f|}|jS)zget an integer from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is an integer )rmrQrr_kwdrrr askintegerWs rsc@seZdZdZddZdS) _QueryFloatzNot a floating point value.cCs||jSr )Z getdoublercrnrCrrrriisz_QueryFloat.getresultNrorrrrrtfsrtcKst||f|}|jS)zget a float from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a float )rtrQrprrraskfloatms ruc@s$eZdZddZddZddZdS) _QueryStringcOs6d|kr|d|_|d=nd|_tj|f||dS)Nshow)_QueryString__showr^r2)rargsrqrrrr2}s  z_QueryString.__init__cCs(t||}|jdk r$|j|jd|S)N)rw)r^rRrxZ configure)rr.rcrrrrRs  z_QueryString.bodycCs |jSr )rcrnrCrrrrisz_QueryString.getresultN)rHrIrJr2rRrirrrrrv|srvcKst||f|}|jS)zget a string from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a string )rvrQrprrr askstrings rz__main__cCsLt}|fdd}t|d|d}|t|d|jd}||dS)NcSs^t|ddddgdddd}t|ttd d d d ttd d dddttd ddS)NzThis is a test dialog. Would this have been an actual dialog, the buttons below would have been glowing in soft pink light. Do you believe this?ZYesZNorXrz Test Dialog)rr/r$r#rZSpamz Egg count)rbzEgg weight (in tons)r d)r`raz Egg label)rprintrDrsrurz)rrrrrrdoits  ztest..doitZTestrZQuit)ZTkr)r rGrA)rrtqrrrtests rN)r]ZtkinterrrrrrKrr^rmrsrtrurvrzrHrrrrr s V CPK!(1616__pycache__/tix.cpython-38.pycnu[U e5d-,@sLddlZddlZddlTddlmZddlZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZGdd d Z Gd!d"d"ej!e Z!Gd#d$d$Z"ej#j$e"fej#_$Gd%d&d&ej#Z%Gd'd(d(e%Z&Gd)d*d*Z'Gd+d,d,e%Z(Gd-d.d.e%Z)Gd/d0d0e%Z*Gd1d2d2e%Z+Gd3d4d4e%Z,Gd5d6d6e%Z-Gd7d8d8e%Z.Gd9d:d:e%Z/Gd;d<dd>e%Z1Gd?d@d@e%Z2GdAdBdBe%Z3GdCdDdDe%Z4GdEdFdFe%e5e6Z7GdGdHdHe%Z8GdIdJdJe%Z9GdKdLdLe%Z:GdMdNdNe%Z;GdOdPdPe%ZGdUdVdVe%Z?GdWdXdXe%Z@GdYdZdZe%ZAGd[d\d\e%ZBGd]d^d^e%ZCGd_d`d`e%ZDGdadbdbe%ZEGdcdddde%ZFGdedfdfe%ZGGdgdhdhe%ZHGdidjdje%ZIGdkdldle%ZJGdmdndne%ZKGdodpdpe%e5e6ZLGdqdrdre%ZMGdsdtdte%ZNGdudvdveOe&ZPGdwdxdxeQe&ZRGdydzdzeSe&ZTGd{d|d|eUe&ZVGd}d~d~eWe&ZXGdddeYe&ZZGddde[e&Z\Gddde]e&Z^Gddde_e&Z`Gdddeae&ZbGdddeDe&ZcGddde7e&ZdGdddeCe&ZeGdddeLe&ZfGddde*e&ZgGddde,e&ZhGddde.e&ZiGddde/e&ZjGddde2e&ZkGddde*e&ZlGdddeKe&ZmGddde>e&ZnGddde@e&ZoddZpddZqGddde%ZrGddde%e5e6ZsGdddesZtdS)N)*) _cnfmergewindowtextZstatusZ immediateimageZ imagetextZballoonautoZ acrosstopasciiZcellcolumnZ decreasingZ increasingZintegermainmaxrealrowzs-regionzx-regionzy-region c@sVeZdZdZddZddZdddZdd d Zd d Zd dZ ddZ dddZ dS) tixCommandaThe tix commands provide access to miscellaneous elements of Tix's internal state and the Tix application context. Most of the information manipulated by these commands pertains to the application as a whole, or to a screen or display, rather than to a particular window. This is a mixin class, assumed to be mixed to Tkinter.Tk that supports the self.tk.call method. cCs|jdd|S)aTix maintains a list of directories under which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap directory is $TIX_LIBRARY/bitmaps. The addbitmapdir command adds directory into this list. By using this command, the image files of an applications can also be located using the tix_getimage or tix_getbitmap command. tixZ addbitmapdirtkcall)selfZ directoryr#/usr/lib64/python3.8/tkinter/tix.pytix_addbitmapdirRs ztixCommand.tix_addbitmapdircCs|jdd|S)zReturns the current value of the configuration option given by option. Option may be any of the options described in the CONFIGURATION OPTIONS section. rcgetrroptionrrrtix_cget^sztixCommand.tix_cgetNcKsd|rt||f}n |rt|}|dkr2|ddSt|trN|ddd|S|jd||S)aQuery or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the configuration options. Nr configure-)rr )r _getconfigure isinstancestrZ_getconfigure1rr_optionsrcnfkwrrr tix_configurees   ztixCommand.tix_configurecCs*|dk r|jdd|S|jddSdS)aReturns the file selection dialog that may be shared among different calls from this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix_filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are tix FileSelectDialog or tixExFileSelectDialog. NrZ filedialogr)rZdlgclassrrrtix_filedialog{s ztixCommand.tix_filedialogcCs|jdd|S)aLocates a bitmap file of the name name.xpm or name in one of the bitmap directories (see the tix_addbitmapdir command above). By using tix_getbitmap, you can avoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets. rZ getbitmaprrnamerrr tix_getbitmaps ztixCommand.tix_getbitmapcCs|jdd|S)aLocates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directories (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix_ getimage, you can avoid hard coding the pathnames of the image files in your application. When successful, this command returns the name of the newly created image, which can be used to configure the -image option of the Tk and Tix widgets. rZgetimagerr+rrr tix_getimages ztixCommand.tix_getimagecCs|jddd|S)a@Gets the options maintained by the Tix scheme mechanism. Available options include: active_bg active_fg bg bold_font dark1_bg dark1_fg dark2_bg dark2_fg disabled_fg fg fixed_font font inactive_bg inactive_fg input1_bg input2_bg italic_font light1_bg light1_fg light2_bg light2_fg menu_font output1_bg output2_bg select_bg select_fg selector rrgetrr+rrrtix_option_getsztixCommand.tix_option_getcCs2|dk r|jdd|||S|jdd||SdS)aResets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetoptions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to reset the priority level of the Tk options set by the Tix schemes. Because of the way Tk handles the X option database, after Tix has been has imported and inited, it is not possible to reset the color schemes and font sets using the tix config command. Instead, the tix_resetoptions command must be used. NrZ resetoptionsr)rZ newSchemeZ newFontSetZ newScmPriorrrtix_resetoptionssztixCommand.tix_resetoptions)N)N)N) __name__ __module__ __qualname____doc__rrr)r*r-r.r0r1rrrrrGs     rc@s"eZdZdZdddZddZdS) Tkz{Toplevel widget of Tix which represents mostly the main window of an application. It has an associated Tcl interpreter.NTixcCsbtj||||tjd}|jd|dk rR|jd||jd||jddS)NZ TIX_LIBRARYzs z Tk.destroy)NNr7r2r3r4r5r9r>rrrrr6s r6c@sTeZdZdZifddZeZddZddZdd Zdd d Z dddZ ddZ d S)FormzThe Tix Form geometry manager Widgets can be arranged by specifying attachments to other widgets. See Tix documentation for complete detailscKs"|jjd|jf|||dS)NtixFormrr_wr%r&rrrconfigsz Form.configcCst|||idSN)rAformrkeyvaluerrr __setitem__szForm.__setitem__cCs|jdd|jS)NrBcheckrrrDr?rrrrLsz Form.checkcCs|jdd|jdS)NrBforgetrMr?rrrrNsz Form.forgetrcCs`|sJ|sJ|jdd|j}|j|}d}|D]}||j|f}q.|S|jdd|j||S)NrBgridr)rrrD splitlistZgetint)rZxsizeZysizexyzrrrrOs z Form.gridNcCs>|s|jdd|jS|ddkr*d|}|jdd|j|S)NrBinforr!rMrrrrrTs  z Form.infocs(fddjjddjDS)Ncsg|]}|qSr) _nametowidget.0rQr?rr szForm.slaves..rBslavesrrPrrDr?rr?rrYs z Form.slaves)rr)N) r2r3r4r5rErGrKrLrNrOrTrYrrrrrAs  rAc@sreZdZdZdddiifddZddZddZd d Zd d Zd dZ ddZ ddZ idfddZ ddZ dS) TixWidgetaQA TixWidget class is used to package all (or most) Tix widgets. Widget initialization is extended in two ways: 1) It is possible to give a list of options which must be part of the creation command (so called Tix 'static' options). These cannot be given as a 'config' command later. 2) It is possible to give the name of an existing TK widget. These are child widgets created automatically by a Tix mega-widget. The Tk call to create these widgets is therefore bypassed in TixWidget.__init__ Both options are for use by subclasses only. Nc Cs|rt||f}nt|}d}|r.|dndg}t|D]&\}}||kr@|d||f}||=q@||_t||||r|jj||j f||rt ||i|_ dS)Nroptionsr!) rappendlistitems widgetNameWidget_setuprrrDrEsubwidget_list) rmasterr`Zstatic_optionsr'r(Zextrakvrrrr9s$  zTixWidget.__init__cCs ||jkr|j|St|dSrF)rcAttributeErrorr+rrr __getattr__Gs  zTixWidget.__getattr__cCs|jd|j|dS)z1Set a variable without calling its action routineZ tixSetSilentNrM)rrJrrr set_silentLszTixWidget.set_silentcCsD||}|s$td|d|j|t|jdd}||S)zSReturn the named subwidget (which must have been created by the sub-class).z Subwidget z not child of N)_subwidget_nameTclError_namelenrDrU)rr,nrrr subwidgetPs  zTixWidget.subwidgetcCsZ|}|sgSg}|D]<}|t|jdd}z|||WqYqXq|S)zReturn all subwidgets.rjN)_subwidget_namesrnrDr]rU)rnamesZretlistr,rrrsubwidgets_allZszTixWidget.subwidgets_allcCs0z|j|jd|WStk r*YdSXdS)z7Get a subwidget name (returns a String, not a Widget !)rpN)rrrDrlr+rrrrkiszTixWidget._subwidget_namecCs<z |j|jdd}|j|WStk r6YdSXdS)z"Return the name of all subwidgets.Z subwidgetsz-allN)rrrDrPrl)rrQrrrrqps zTixWidget._subwidget_namescCs\|dkr dSt|tst|}t|ts0t|}|}|D]}|j|dd||q) r^childrenvaluesr>rmrdrcr~rrrDrcrrrr>s   zTixSubWidget.destroyN)rjrjr@rrrrr|s  r|c@sVeZdZdZifddddZddZdd Zd d Zd d ZifddZ ddZ dS) DisplayStylezRDisplayStyle - handle configuration options shared by (multiple) Display ItemsN)rdcKs\|s2d|kr|d}nd|kr(|d}n td}|j|_|jjd|f||||_dS)NZ refwindowzcreate display styleZtixDisplayStyle)r8Z_get_default_rootrrr% stylename)ritemtyper'rdr(rrrr9s     zDisplayStyle.__init__cCs|jSrF)rr?rrr__str__szDisplayStyle.__str__cCsH|r|rt||f}n|r|}d}|D]\}}|d||f}q*|S)Nrr!)rr_)rr'r(Zoptsrerfrrrr%szDisplayStyle._optionscCs|j|jddSNrzrrrr?rrrrzszDisplayStyle.deletecCs|j|jdd||dS)Nr -%srrHrrrrKszDisplayStyle.__setitem__cKs|j|jdf|||S)Nr )r"rr%r&rrrrEs  zDisplayStyle.configcCs|j|jdd|S)Nrrr)rrIrrr __getitem__szDisplayStyle.__getitem__) r2r3r4r5r9rr%rzrKrErrrrrrs   rc@s2eZdZdZdifddZifddZddZdS) BalloonzBalloon help widget. Subwidget Class --------- ----- label Label message MessageNcKsNdddddg}t||d|||t|ddd |jd<t|d dd |jd <dS) Nr\ZinstallcolormapZinitwaitZ statusbarZcursorZ tixBalloonlabelrr~messager[r9 _dummyLabelrcrrdr'r(Zstaticrrrr9 s zBalloon.__init__cKs&|jj|jd|jf|||dS)zkBind balloon widget to another. One balloon widget may be bound to several widgets at the same timebindNrC)rwidgetr'r(rrr bind_widgetszBalloon.bind_widgetcCs|j|jd|jdSNZunbindrMrrrrr unbind_widgetszBalloon.unbind_widget)r2r3r4r5r9rrrrrrrs rc@s2eZdZdZdifddZifddZddZdS) ButtonBoxzgButtonBox - A container for pushbuttons. Subwidgets are the buttons added with the add method. NcKst||dddg||dS)NZ tixButtonBox orientationr\r[r9rrdr'r(rrrr9s  zButtonBox.__init__cKs4|jj|jd|f|||}t|||j|<|S)z$Add a button with given name to box.addrrrDr% _dummyButtonrc)rr,r'r(Zbtnrrrr#s z ButtonBox.addcCs ||jkr|j|jd|dSNinvokercrrrDr+rrrr*s zButtonBox.invoker2r3r4r5r9rrrrrrrs rc@s>eZdZdZdifddZddZddZd d Zd d ZdS) ComboBoxaComboBox - an Entry field with a dropdown menu. The user can select a choice by either typing in the entry subwidget or selecting from the listbox subwidget. Subwidget Class --------- ----- entry Entry arrow Button slistbox ScrolledListBox tick Button cross Button : present if created with the fancy optionNc Kst||dddddg||t|d|jd<t|d|jd<t|d|jd<t|d |jd <z$t|d |jd <t|d |jd <Wntk rYnXdS) NZ tixComboBoxZeditableZdropdownfancyr\rentryarrowslistboxtickcross)r[r9rrc _dummyEntryr_dummyScrolledListBox TypeErrorrrrrr9<s    zComboBox.__init__cCs|j|jd|dS)NZ addhistoryrMrr$rrr add_historyNszComboBox.add_historycCs|j|jd|dS)NZ appendhistoryrMrrrrappend_historyQszComboBox.append_historycCs|j|jd||dSNinsertrM)rindexr$rrrrTszComboBox.insertcCs|j|jd|dS)NpickrMrrrrrrWsz ComboBox.pick) r2r3r4r5r9rrrrrrrrr.s  rc@s>eZdZdZdifddZddZddZd d Zd d ZdS) ControlaControl - An entry field with value change arrows. The user can adjust the value by pressing the two arrow buttons or by entering the value directly into the entry. The new value will be checked against the user-defined upper and lower limits. Subwidget Class --------- ----- incr Button decr Button entry Entry label LabelNcKsZt||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZ tixControlr\incrdecrrr)r[r9rrcrrrrrrr9hs zControl.__init__cCs|j|jddS)NrrMr?rrr decrementoszControl.decrementcCs|j|jddS)NrrMr?rrr incrementrszControl.incrementcCs|j|jddSrrMr?rrrruszControl.invokecCs|j|jddS)NupdaterMr?rrrrxszControl.update) r2r3r4r5r9rrrrrrrrrZs  rc@s$eZdZdZifddZddZdS)DirListaRDirList - displays a list view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb ScrollbarcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixDirListr\hlistvsbhsbr[r9 _dummyHListrc_dummyScrollbarrrrrr9szDirList.__init__cCs|j|jd|dSNchdirrMrdirrrrrsz DirList.chdirNr2r3r4r5r9rrrrrr{s rc@s$eZdZdZifddZddZdS)DirTreeaDirTree - Directory Listing in a hierarchical view. Displays a tree view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb ScrollbarcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixDirTreer\rrrrrrrrr9szDirTree.__init__cCs|j|jd|dSrrMrrrrrsz DirTree.chdirNrrrrrrs rc@seZdZdZifddZdS) DirSelectBoxaDirSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBoxcKs:t||ddg||t|d|jd<t|d|jd<dS)NZtixDirSelectBoxr\dirlistdircbx)r[r9 _dummyDirListrc_dummyFileComboBoxrrrrr9szDirSelectBox.__init__Nr2r3r4r5r9rrrrrs rc@s,eZdZdZifddZddZddZdS) ExFileSelectBoxaExFileSelectBox - MS Windows style file select box. It provides a convenient method for the user to select files. Subwidget Class --------- ----- cancel Button ok Button hidden Checkbutton types ComboBox dir ComboBox file ComboBox dirlist ScrolledListBox filelist ScrolledListBoxcKst||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d |jd <t|d |jd <dS) NZtixExFileSelectBoxr\cancelokhiddentypesrrfilefilelist)r[r9rrc_dummyCheckbutton_dummyComboBoxrrrrrrr9szExFileSelectBox.__init__cCs|j|jddSNfilterrMr?rrrrszExFileSelectBox.filtercCs|j|jddSrrMr?rrrrszExFileSelectBox.invokeN)r2r3r4r5r9rrrrrrrs rc@s,eZdZdZifddZddZddZdS) DirSelectDialoga#The DirSelectDialog widget presents the directories in the file system in a dialog window. The user can use this dialog window to navigate through the file system to select the desired directory. Subwidgets Class ---------- ----- dirbox DirSelectDialogcKs*t||ddg||t|d|jd<dS)NZtixDirSelectDialogr\Zdirbox)r[r9_dummyDirSelectBoxrcrrrrr9s  zDirSelectDialog.__init__cCs|j|jddSNpopuprMr?rrrrszDirSelectDialog.popupcCs|j|jddSNpopdownrMr?rrrrszDirSelectDialog.popdownNr2r3r4r5r9rrrrrrrs rc@s,eZdZdZifddZddZddZdS) ExFileSelectDialogzExFileSelectDialog - MS Windows style file select dialog. It provides a convenient method for the user to select files. Subwidgets Class ---------- ----- fsbox ExFileSelectBoxcKs*t||ddg||t|d|jd<dS)NZtixExFileSelectDialogr\fsbox)r[r9_dummyExFileSelectBoxrcrrrrr9s  zExFileSelectDialog.__init__cCs|j|jddSrrMr?rrrrszExFileSelectDialog.popupcCs|j|jddSrrMr?rrrrszExFileSelectDialog.popdownNrrrrrrs rc@s,eZdZdZifddZddZddZdS) FileSelectBoxaExFileSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBoxcKsZt||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZtixFileSelectBoxr\rrr selection)r[r9rrcrrrrrr9s zFileSelectBox.__init__cCs|j|jddSrrMr?rrr apply_filterszFileSelectBox.apply_filtercCs|j|jddSrrMr?rrrrszFileSelectBox.invokeN)r2r3r4r5r9rrrrrrrs rc@s,eZdZdZifddZddZddZdS) FileSelectDialogzFileSelectDialog - Motif style file select dialog. Subwidgets Class ---------- ----- btns StdButtonBox fsbox FileSelectBoxcKs:t||ddg||t|d|jd<t|d|jd<dS)NZtixFileSelectDialogr\Zbtnsr)r[r9_dummyStdButtonBoxrc_dummyFileSelectBoxrrrrr9,s zFileSelectDialog.__init__cCs|j|jddSrrMr?rrrr2szFileSelectDialog.popupcCs|j|jddSrrMr?rrrr5szFileSelectDialog.popdownNrrrrrr#s rc@s,eZdZdZifddZddZddZdS) FileEntrya_FileEntry - Entry field with button that invokes a FileSelectDialog. The user can type in the filename manually. Alternatively, the user can press the button widget that sits next to the entry, which will bring up a file selection dialog. Subwidgets Class ---------- ----- button Button entry EntrycKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixFileEntryZ dialogtyper\Zbuttonr)r[r9rrcrrrrrr9Ds zFileEntry.__init__cCs|j|jddSrrMr?rrrrJszFileEntry.invokecCsdSrFrr?rrr file_dialogMszFileEntry.file_dialogN)r2r3r4r5r9rrrrrrr8s rc@seZdZdZdifddZifddZdifddZd d Zd d ZdlddZ ddZ ddZ ddZ ddZ ddZddZddZddZifd d!Zifd"d#Zd$d%Zd&d'ZeZd(d)Zd*d+Zd,d-Zifd.d/Zifd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,ifdTdUZ-ifdVdWZ.dXdYZ/dZd[Z0d\d]Z1ifd^d_Z2d`daZ3dbdcZ4ifdddeZ5dfdgZ6dndhdiZ7djdkZ8dS)oHListaHList - Hierarchy display widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy. Subwidgets - NoneNcKst||dddg||dS)NZtixHListcolumnsr\rrrrrr9Ys  zHList.__init__cKs |jj|jd|f|||SNrrCrrr'r(rrrr]sz HList.addcKs(|sd}|jj|jd|f|||S)Nr=ZaddchildrC)rrr'r(rrr add_child`s zHList.add_childcCs|j|jdd|dSNanchorsetrMrrrrr anchor_setfszHList.anchor_setcCs|j|jdddSNrclearrMr?rrr anchor_cleariszHList.anchor_clearrcCs6|s|j|jdd||S|j|jdd|d|SdS)Nr widthz-charrM)rcolrcharsrrr column_widthls zHList.column_widthcCs|j|jdddS)NrzallrMr?rrr delete_allsszHList.delete_allcCs|j|jdd|dS)NrzrrMrrrr delete_entryvszHList.delete_entrycCs|j|jdd|dS)NrzZ offspringsrMrrrrdelete_offspringsyszHList.delete_offspringscCs|j|jdd|dS)NrzZsiblingsrMrrrrdelete_siblings|szHList.delete_siblingscCs|j|jdd|dSNdragsiterrMrrrr dragsite_setszHList.dragsite_setcCs|j|jdddSNr rrMr?rrrdragsite_clearszHList.dragsite_clearcCs|j|jdd|dSNdropsiterrMrrrr dropsite_setszHList.dropsite_setcCs|j|jdddSNrrrMr?rrrdropsite_clearszHList.dropsite_clearcKs&|jj|jdd|f|||dS)NheaderrvrCrrr'r(rrr header_createszHList.header_createcKs@|dkr||jdd|S|jj|jdd|f|||dS)Nrr r"rDrrr%rrrrheader_configures  zHList.header_configurecCs|j|jdd||S)NrrrM)rroptrrr header_cgetszHList.header_cgetcCs|j|j|jdd|S)NrZexist)rZ getbooleanrrDrrrrr header_existsszHList.header_existscCs|j|jdd|dS)NrrzrMrrrr header_deleteszHList.header_deletecCs|j|jdd|S)NrsizerMrrrr header_sizeszHList.header_sizecCs|j|jdd|dS)NhiderrMrrrr hide_entryszHList.hide_entrycKs&|jj|jdd|f|||dS)N indicatorrvrCrrrrindicator_creates zHList.indicator_createcKs@|dkr||jdd|S|jj|jdd|f|||dS)Nr#r rrrrrindicator_configures zHList.indicator_configurecCs|j|jdd||S)Nr#rrMrrrrrrindicator_cgetszHList.indicator_cgetcCs|j|jdd|S)Nr#existsrMrrrrindicator_existsszHList.indicator_existscCs|j|jdd|dS)Nr#rzrMrrrrindicator_deleteszHList.indicator_deletecCs|j|jdd|S)Nr#rrMrrrrindicator_sizeszHList.indicator_sizecCs|j|jddSNrTrrMr?rrr info_anchorszHList.info_anchorcCs||j|jdd|pdSNrTZbbox)_getintsrrrDrrrr info_bboxs zHList.info_bboxcCs |j|jdd|}|j|S)NrTrrrrDrP)rrrrrr info_childrenszHList.info_childrencCs|j|jdd|S)NrTdatarMrrrr info_dataszHList.info_datacCs|j|jddS)NrTr rMr?rrr info_dragsiteszHList.info_dragsitecCs|j|jddS)NrTrrMr?rrr info_dropsiteszHList.info_dropsitecCs|j|jdd|S)NrTr(rMrrrr info_existsszHList.info_existscCs|j|jdd|S)NrTrrMrrrr info_hiddenszHList.info_hiddencCs|j|jdd|S)NrTnextrMrrrr info_nextszHList.info_nextcCs|j|jdd|S)NrTrrMrrrr info_parentszHList.info_parentcCs|j|jdd|S)NrTprevrMrrrr info_prevszHList.info_prevcCs|j|jdd}|j|SNrTrr1rrrrinfo_selectionszHList.info_selectioncCs|j|jdd|||S)NitemrrM)rrrrrrr item_cgetszHList.item_cgetcKsD|dkr||jdd||S|jj|jdd||f|||dS)Nr@r rrrrr'r(rrritem_configures  zHList.item_configurecKs(|jj|jdd||f|||dS)Nr@rvrCrBrrr item_creates zHList.item_createcCs|j|jdd||S)Nr@r(rMrrrrrr item_existsszHList.item_existscCs|j|jdd||dS)Nr@rzrMrErrr item_deleteszHList.item_deletecCs|j|jd||S)N entrycgetrMr&rrrrHszHList.entrycgetcKs<|dkr||jd|S|jj|jd|f|||dSNentryconfigurerrrrrrJs  zHList.entryconfigurecCs|j|jd|SNnearestrM)rrRrrrrLsz HList.nearestcCs|j|jd|dSNseerMrrrrrNsz HList.seecKs$|jj|jddf|||dSNrrrCr&rrrselection_clearszHList.selection_clearcCs|j|jdd|SNrZincludesrMrrrrselection_includes szHList.selection_includescCs|j|jdd||dSNrrrMrfirstZlastrrr selection_set szHList.selection_setcCs|j|jdd|S)NshowrrMrrrr show_entryszHList.show_entry)rNN)N)N)9r2r3r4r5r9rrrrrrrr r r rrrrrrrZ header_existrr r"r$r%r'r)r*r+r-r0r2r4r5r6r7r8r:r;r=r?rArCrDrFrGrHrJrLrNrPrRrVrXrrrrrQsl            rc@seZdZdZdifddZdS) InputOnlyz?InputOnly - Invisible widget. Unix only. Subwidgets - NoneNcKst||dd||dS)NZ tixInputOnlyrrrrrr9szInputOnly.__init__rrrrrrYsrYc@seZdZdZdifddZdS) LabelEntryaLabelEntry - Entry field with label. Packages an entry widget and a label into one mega widget. It can be used to simplify the creation of ``entry-form'' type of interface. Subwidgets Class ---------- ----- label Label entry EntryNcKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixLabelEntry labelsider\rr)r[r9rrcrrrrrr9%s zLabelEntry.__init__rrrrrrZs rZc@seZdZdZdifddZdS) LabelFrameaeLabelFrame - Labelled Frame container. Packages a frame widget and a label into one mega widget. To create widgets inside a LabelFrame widget, one creates the new widgets relative to the frame subwidget and manage them inside the frame subwidget. Subwidgets Class ---------- ----- label Label frame FrameNcKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixLabelFramer[r\rframe)r[r9rrc _dummyFramerrrrr96s zLabelFrame.__init__rrrrrr\+s r\c@s@eZdZdZifddZifddZddZdd Zd d Zd S) ListNoteBookaA ListNoteBook widget is very similar to the TixNoteBook widget: it can be used to display many windows in a limited space using a notebook metaphor. The notebook is divided into a stack of pages (windows). At one time only one of these pages can be shown. The user can navigate through these pages by choosing the name of the desired page in the hlist subwidget.cKsNt||ddg||t|ddd|jd<t|d|jd<t|d|jd<dS)NZtixListNoteBookr\ZpanerrrZshlist)r[r9_dummyPanedWindowrcr_dummyScrolledHListrrrrr9Es  zListNoteBook.__init__cKs:|jj|jd|f|||t|||j|<|j|SrrrrDr%r|rcrr,r'r(rrrrMs zListNoteBook.addcCs ||SrFrpr+rrrpageRszListNoteBook.pagecCs:|j|j|jd}g}|D]}|||q |SNpagesrrPrrDr]rprrrZretrQrrrrgUs zListNoteBook.pagescCs|j|jd|dSNraiserMr+rrr raise_page]szListNoteBook.raise_pageN) r2r3r4r5r9rrergrlrrrrr_=s   r_c@seZdZdZdifddZdS)MeterzuThe Meter widget can be used to show the progress of a background job which may take a long time to execute. NcKst||ddg||dS)NZtixMeterr\rrrrrr9es  zMeter.__init__rrrrrrm`srmc@sReZdZdZdifddZifddZddZd d Zd d Zd dZ ddZ dS)NoteBookzNoteBook - Multi-page container widget (tabbed notebook metaphor). Subwidgets Class ---------- ----- nbframe NoteBookFrame page widgets added dynamically with the add methodNcKs.t||ddg||t|ddd|jd<dS)NZ tixNoteBookr\Znbframerr)r[r9r|rcrrrrr9qszNoteBook.__init__cKs:|jj|jd|f|||t|||j|<|j|Srrbrcrrrrvs z NoteBook.addcCs,|j|jd||j||j|=dSrrrrDrcr>r+rrrrz{szNoteBook.deletecCs ||SrFrdr+rrrresz NoteBook.pagecCs:|j|j|jd}g}|D]}|||q |Srfrhrirrrrgs zNoteBook.pagescCs|j|jd|dSrjrMr+rrrrlszNoteBook.raise_pagecCs|j|jdS)NraisedrMr?rrrrpszNoteBook.raised) r2r3r4r5r9rrzrergrlrprrrrrnis rnc@s eZdZdS) NoteBookFrameN)r2r3r4rrrrrqsrqc@sLeZdZdZifddZifddZifddZdd Zd d Zd d Z dS) OptionMenuzOptionMenu - creates a menu button of options. Subwidget Class --------- ----- menubutton Menubutton menu MenucKs:t||ddg||t|d|jd<t|d|jd<dS)NZ tixOptionMenur\ menubuttonmenur[r9_dummyMenubuttonrc _dummyMenurrrrr9szOptionMenu.__init__cKs&|jj|jdd|f|||dS)NrcommandrCrcrrr add_commandszOptionMenu.add_commandcKs&|jj|jdd|f|||dS)NrZ separatorrCrcrrr add_separatorszOptionMenu.add_separatorcCs|j|jd|dSrrMr+rrrrzszOptionMenu.deletecCs|j|jd|dS)NdisablerMr+rrrr{szOptionMenu.disablecCs|j|jd|dS)NenablerMr+rrrr|szOptionMenu.enableN) r2r3r4r5r9ryrzrzr{r|rrrrrrs   rrc@sTeZdZdZifddZifddZddZdd Zd d Zifd d Z ddZ dS) PanedWindowaPanedWindow - Multi-pane container widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.The user changes the sizes of the panes by dragging the resize handle between two panes. Subwidgets Class ---------- ----- g/p widgets added dynamically with the add method.cKst||dddg||dS)NZtixPanedWindowrr\rrrrrr9szPanedWindow.__init__cKs>|jj|jd|f|||t||dd|j|<|j|S)Nrr)rrbrcrrrrs   zPanedWindow.addcCs,|j|jd||j||j|=dSrror+rrrrzszPanedWindow.deletecCs|j|jd|dS)NrNrMr+rrrrNszPanedWindow.forgetcCs|j|jd||S)NpanecgetrMr&rrrr~szPanedWindow.panecgetcKs<|dkr||jd|S|jj|jd|f|||dS)N paneconfigurerrrrrrszPanedWindow.paneconfigurecs*jjjd}fdd|DS)Npanescsg|]}|qSrrdrVr?rrrXsz%PanedWindow.panes..rZ)rrrrr?rrszPanedWindow.panesN) r2r3r4r5r9rrzrNr~rrrrrrr}s   r}c@s4eZdZdZifddZddZddZdd Zd S) PopupMenuaPopupMenu widget can be used as a replacement of the tk_popup command. The advantage of the Tix PopupMenu widget is it requires less application code to manipulate. Subwidgets Class ---------- ----- menubutton Menubutton menu MenucKs:t||ddg||t|d|jd<t|d|jd<dS)NZ tixPopupMenur\rsrtrurrrrr9szPopupMenu.__init__cCs|j|jd|jdS)NrrMrrrrrszPopupMenu.bind_widgetcCs|j|jd|jdSrrMrrrrrszPopupMenu.unbind_widgetcCs|j|jd|j||dS)NZpostrM)rrrQrRrrr post_widgetszPopupMenu.post_widgetN)r2r3r4r5r9rrrrrrrrs  rc@s<eZdZdZifddZddZddZdd Zd d Zd S) ResizeHandlez;Internal widget to draw resize handles on Scrolled widgets.c Ks.ddddddddd g }t||d |||dS) Nr\rxZcursorfgZcursorbgZ handlesizeZ hintcolorZ hintwidthrQrRZtixResizeHandler)rrdr'r(flagsrrrr9s zResizeHandle.__init__cCs|j|jd|jdS)NZ attachwidgetrMrrrr attach_widgetszResizeHandle.attach_widgetcCs|j|jd|jdS)NZ detachwidgetrMrrrr detach_widgetszResizeHandle.detach_widgetcCs|j|jd|jdS)Nr!rMrrrrr!szResizeHandle.hidecCs|j|jd|jdS)NrWrMrrrrrW szResizeHandle.showN) r2r3r4r5r9rrr!rWrrrrrs  rc@seZdZdZifddZdS) ScrolledHListz0ScrolledHList - HList with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledHListr\rrrrrrrrr9szScrolledHList.__init__Nrrrrrr src@seZdZdZifddZdS)ScrolledListBoxz4ScrolledListBox - Listbox with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledListBoxr\listboxrr)r[r9 _dummyListboxrcrrrrrr9szScrolledListBox.__init__Nrrrrrrsrc@seZdZdZifddZdS) ScrolledTextz.ScrolledText - Text with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledTextr\rrr)r[r9 _dummyTextrcrrrrrr9%szScrolledText.__init__Nrrrrrr!src@seZdZdZifddZdS) ScrolledTListz0ScrolledTList - TList with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledTListr\Ztlistrr)r[r9 _dummyTListrcrrrrrr9/szScrolledTList.__init__Nrrrrrr+src@seZdZdZifddZdS)ScrolledWindowz2ScrolledWindow - Window with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledWindowr\rrr)r[r9r^rcrrrrrr9:szScrolledWindow.__init__Nrrrrrr6src@s0eZdZdZifddZifddZddZdS) SelectzSelect - Container of button subwidgets. It can be used to provide radio-box or check-box style of selection options for the user. Subwidgets are buttons added dynamically using the add method.c Ks2t||ddddddg||t|d|jd<dS)NZ tixSelectZ allowzeroradiorr[r\rrrrrrr9Gs zSelect.__init__cKs:|jj|jd|f|||t|||j|<|j|SrrrcrrrrNs z Select.addcCs|j|jd|dSrrMr+rrrrSsz Select.invokeNrrrrrr@s  rc@seZdZdZdifddZdS)Shellz'Toplevel window. Subwidgets - NoneNcKst||dddg||dS)NZtixShellr\titlerrrrrr9[szShell.__init__rrrrrrVsrc@s6eZdZdZdifddZddZddZd d ZdS) DialogShellzToplevel window, with popup popdown and center methods. It tells the window manager that it is a dialog window and should be treated specially. The exact treatment depends on the treatment of the window manager. Subwidgets - NoneNc Ks&t||ddddddddg||dS) NZtixDialogShellr\rZmappedZ minheightZminwidthrZ transientrrrrrr9gszDialogShell.__init__cCs|j|jddSrrMr?rrrrnszDialogShell.popdowncCs|j|jddSrrMr?rrrrqszDialogShell.popupcCs|j|jddS)NcenterrMr?rrrrtszDialogShell.center)r2r3r4r5r9rrrrrrrr^s rc@s&eZdZdZdifddZddZdS) StdButtonBoxz@StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) NcKs\t||dddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZtixStdButtonBoxrr\rapplyrhelp)r[r9rrcrrrrr9zs zStdButtonBox.__init__cCs ||jkr|j|jd|dSrrr+rrrrs zStdButtonBox.invoke)r2r3r4r5r9rrrrrrwsrc@seZdZdZdifddZddZddZd d Zd d Zd3d dZ ddZ ddZ ddZ ddZ ifddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zifd-d.Zd/d0Zd4d1d2ZdS)5TListaTList - Hierarchy display widget which can be used to display data in a tabular format. The list entries of a TList widget are similar to the entries in the Tk listbox widget. The main differences are (1) the TList widget can display the list entries in a two dimensional format and (2) you can use graphical images as well as multiple colors and fonts for the list entries. Subwidgets - NoneNcKst||ddg||dS)NZtixTListr\rrrrrr9szTList.__init__cCs|j|jdd|dS)NactiverrMrrrr active_setszTList.active_setcCs|j|jdddS)NrrrMr?rrr active_clearszTList.active_clearcCs|j|jdd|dSrrMrrrrrszTList.anchor_setcCs|j|jdddSrrMr?rrrrszTList.anchor_clearcCs|j|jd||dSrrMrfrom_torrrrzsz TList.deletecCs|j|jdd|dSr rMrrrrr szTList.dragsite_setcCs|j|jdddSrrMr?rrrrszTList.dragsite_clearcCs|j|jdd|dSrrMrrrrrszTList.dropsite_setcCs|j|jdddSrrMr?rrrrszTList.dropsite_clearcKs$|jj|jd|f|||dSrrC)rrr'r(rrrrsz TList.insertcCs|j|jddS)NrTrrMr?rrr info_activeszTList.info_activecCs|j|jddSr,rMr?rrrr-szTList.info_anchorcCs|j|jdd|S)NrTZdownrMrrrr info_downszTList.info_downcCs|j|jdd|S)NrTleftrMrrrr info_leftszTList.info_leftcCs|j|jdd|S)NrTrightrMrrrr info_rightszTList.info_rightcCs|j|jdd}|j|Sr>r1rrrrr?szTList.info_selectioncCs|j|jddS)NrTrrMr?rrr info_sizeszTList.info_sizecCs|j|jdd|S)NrTZuprMrrrrinfo_upsz TList.info_upcCs|j|jd||SrKrMrrQrRrrrrLsz TList.nearestcCs|j|jd|dSrMrMrrrrrNsz TList.seecKs$|jj|jddf|||dSrOrCr&rrrrPszTList.selection_clearcCs|j|jdd|SrQrMrrrrrRszTList.selection_includescCs|j|jdd||dSrSrMrTrrrrVszTList.selection_set)N)N)r2r3r4r5r9rrrrrzr rrrrrr-rrrr?rrrLrNrPrRrVrrrrrs2    rc@sHeZdZdZdifddZddZddZd d Zd d ZdddZ dS)TreezTree - The tixTree widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree.NcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixTreer\rrrrrrrrr9s z Tree.__init__cCs|j|jddSa This command calls the setmode method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to none. Otherwise, if the entry has any hidden child entries, its mode is set to open; otherwise its mode is set to close. autosetmodeNrMr?rrrrszTree.autosetmodecCs|j|jd|dSz8Close the entry given by entryPath if its mode is close.closeNrMr entrypathrrrrsz Tree.closecCs|j|jd|Sz9Returns the current mode of the entry given by entryPath.getmoderMrrrrrsz Tree.getmodecCs|j|jd|dSz6Open the entry given by entryPath if its mode is open.openNrMrrrrrsz Tree.opennonecCs|j|jd||dS)aThis command is used to indicate whether the entry given by entryPath has children entries and whether the children are visible. mode must be one of open, close or none. If mode is set to open, a (+) indicator is drawn next the entry. If mode is set to close, a (-) indicator is drawn next the entry. If mode is set to none, no indicators will be drawn for this entry. The default mode is none. The open mode indicates the entry has hidden children and this entry can be opened by the user. The close mode indicates that all the children of the entry are now visible and the entry can be closed by the user.setmodeNrMrrmoderrrrs z Tree.setmode)r) r2r3r4r5r9rrrrrrrrrrsrc@sZeZdZdZdifddZddZddZd d Zd d ZdddZ ddZ dddZ dS) CheckListzThe CheckList widget displays a list of items to be selected by the user. CheckList acts similarly to the Tk checkbutton or radiobutton widgets, except it is capable of handling many more items than checkbuttons or radiobuttons. NcKsLt||dddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixCheckListr\rrrrrrrrrr9s zCheckList.__init__cCs|j|jddSrrMr?rrrrszCheckList.autosetmodecCs|j|jd|dSrrMrrrrrszCheckList.closecCs|j|jd|SrrMrrrrr szCheckList.getmodecCs|j|jd|dSrrMrrrrr$szCheckList.openoncCs|j|j|jd|S)zReturns a list of items whose status matches status. If status is not specified, the list of items in the "on" status will be returned. Mode can be on, off, default getselectionrZ)rrrrrr(szCheckList.getselectioncCs|j|jd|S)z(Returns the current status of entryPath. getstatusrMrrrrr.szCheckList.getstatuscCs|j|jd||dS)z~Sets the status of entryPath to be status. A bitmap will be displayed next to the entry its status is on, off or default. setstatusNrMrrrrr2szCheckList.setstatus)r)r) r2r3r4r5r9rrrrrrrrrrrrs rc@seZdZdddZdS)rrjcCst||||dSrFr|r9rrdr,r~rrrr9>sz_dummyButton.__init__N)rjr2r3r4r9rrrrr=src@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Bsz_dummyCheckbutton.__init__N)rjrrrrrrAsrc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Fsz_dummyEntry.__init__N)rjrrrrrrEsrc@seZdZdddZdS)r^rjcCst||||dSrFrrrrrr9Jsz_dummyFrame.__init__N)rjrrrrrr^Isr^c@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Nsz_dummyLabel.__init__N)rjrrrrrrMsrc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Rsz_dummyListbox.__init__N)rjrrrrrrQsrc@seZdZdddZdS)rwrjcCst||||dSrFrrrrrr9Vsz_dummyMenu.__init__N)rjrrrrrrwUsrwc@seZdZdddZdS)rvrjcCst||||dSrFrrrrrr9Zsz_dummyMenubutton.__init__N)rjrrrrrrvYsrvc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9^sz_dummyScrollbar.__init__N)rjrrrrrr]src@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9bsz_dummyText.__init__N)rjrrrrrrasrc@seZdZdddZdS)rrjcCsDt||||t|d|jd<t|d|jd<t|d|jd<dS)Nrrr)r|r9rrcrrrrrr9fsz_dummyScrolledListBox.__init__N)rjrrrrrresrc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9msz_dummyHList.__init__N)rjrrrrrrlsrc@seZdZdddZdS)rarjcCsDt||||t|d|jd<t|d|jd<t|d|jd<dSNrrrr|r9rrcrrrrrr9qsz_dummyScrolledHList.__init__N)rjrrrrrrapsrac@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9xsz_dummyTList.__init__N)rjrrrrrrwsrc@seZdZdddZdS)rrjcCst|||d|gt|d|jd<t|d|jd<t|d|jd<t|d|jd<z$t|d|jd<t|d|jd<Wntk rYnXdS)Nrrrrrrr)r|r9rrcrrrrrrrrr9|s z_dummyComboBox.__init__N)rjrrrrrr{src@seZdZdddZdS)rrjcCsDt||||t|d|jd<t|d|jd<t|d|jd<dSrrrrrrr9sz_dummyDirList.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCs4t||||t|d|jd<t|d|jd<dS)Nrr)r|r9rrcrrrrrr9sz_dummyDirSelectBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCst||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS) Nrrrrrrrr)r|r9rrcrrrrrrrr9sz_dummyExFileSelectBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCsTt||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)Nrrrr)r|r9rrcrrrrrr9s z_dummyFileSelectBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCs$t||||t|d|jd<dS)Nr)r|r9rrcrrrrr9sz_dummyFileComboBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCsTt||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)Nrrrr)r|r9rrcrrrrr9s z_dummyStdButtonBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)_dummyNoteBookFramercCst||||dSrFrrrrrr9sz_dummyNoteBookFrame.__init__N)rrrrrrrsrc@seZdZdddZdS)r`rjcCst||||dSrFrrrrrr9sz_dummyPanedWindow.__init__N)rjrrrrrr`sr`cCs|jd|jS)zzReturns the qualified path name for the widget. Normally used to set default options for subwidgets. See tixwidgets.pyZ tixOptionNamerM)rrrr OptionNamesrcCs:d}|D](}|d|d|d||d}q |S)Nr=z{{z} {z - z}} )keys)dictstyperrr FileTypeLists &rc@seZdZdZdS)CObjViewaBThis file implements the Canvas Object View widget. This is a base class of IconView. It implements automatic placement/adjustment of the scrollbars according to the canvas objects inside the canvas subwidget. The scrollbars are adjusted so that the canvas is just large enough to see all the objects. N)r2r3r4r5rrrrrsrc@seZdZdZdifddZddZddZd d Zd)d d Zd*d dZ ddZ ddZ ddZ d+ddZ ddZddZddZddZdd Zd,d!d"Zd#d$Zd%d&Zd'd(ZdS)-Grida}The Tix Grid command creates a new window and makes it into a tixGrid widget. Additional options, may be specified on the command line or in the option database to configure aspects such as its cursor and relief. A Grid widget displays its contents in a two dimensional grid of cells. Each cell may contain one Tix display item, which may be in text, graphics or other formats. See the DisplayStyle class for more information about Tix display items. Individual cells, or groups of cells, can be formatted with a wide range of attributes, such as its color, relief and border. Subwidgets - NoneNcKs"g}||_t||d|||dS)NZtixGridr'r[r9rrrrr9sz Grid.__init__cCs|j|dddS)zRemoves the selection anchor.rrNrr?rrrrszGrid.anchor_clearcCs||j|ddS)z3Get the (x,y) coordinate of the current anchor cellrr/r/rrr?rrr anchor_getszGrid.anchor_getcCs|j|dd||dS)z/Set the selection anchor to the cell at (x, y).rrNrrrrrrszGrid.anchor_setcCs4|dkr|j|dd|n|j|dd||dS)zdDelete rows between from_ and to inclusive. If to is not provided, delete only row at from_Nrzr rrrrr delete_row szGrid.delete_rowcCs4|dkr|j|dd|n|j|dd||dS)zjDelete columns between from_ and to inclusive. If to is not provided, delete only column at from_Nrzr rrrrr delete_columnszGrid.delete_columncCs|j|dddS)zUIf any cell is being edited, de-highlight the cell and applies the changes.editrNrr?rrr edit_applyszGrid.edit_applycCs|j|dd||dS)zmHighlights the cell at (x, y) for editing, if the -editnotify command returns True for this cell.rrNrrrrredit_set!sz Grid.edit_setcCs,|r|ddkrd|}|j|d|||S)z&Get the option value for cell at (x,y)rr!rHr)rrQrRrrrrrH&szGrid.entrycgetcKs|d||f||SrI)Z _configure)rrQrRr'r(rrrrJ,szGrid.entryconfigurec Cs||j|dd||S)z+Return True if display item exists at (x,y)rTr()Z _getbooleanrrrrrrr72szGrid.info_existscCs|j|dd||Sr.rrrrrr06szGrid.info_bboxcCs|j|dd|||dS)zMoves the range of columns from position FROM through TO by the distance indicated by OFFSET. For example, move_column(2, 4, 1) moves the columns 2,3,4 to columns 3,4,5.mover Nrrrroffsetrrr move_column:szGrid.move_columncCs|j|dd|||dS)zMoves the range of rows from position FROM through TO by the distance indicated by OFFSET. For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.rr Nrrrrrmove_row@sz Grid.move_rowcCs||j|d||S)z8Return coordinate of cell nearest pixel coordinate (x,y)rLrrrrrrLFsz Grid.nearestcKs>||j|}|dk r"d|f|}|jj|d||f|dS)Nz -itemtyper)r%r'rr)rrQrRrr(argsrrrrPs zGrid.setcKs*|j|jj|jdd|f|i|S)aQueries or sets the size of the column given by INDEX. INDEX may be any non-negative integer that gives the position of a given column. INDEX can also be the string "default"; in this case, this command queries or sets the default size of all columns. When no option-value pair is given, this command returns a tuple containing the current size setting of the given column. When option-value pairs are given, the corresponding options of the size setting of the given column are changed. Options may be one of the following: pad0 pixels Specifies the paddings to the left of a column. pad1 pixels Specifies the paddings to the right of a column. size val Specifies the width of a column. Val may be: "auto" -- the width of the column is set to the width of the widest cell in the column; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the width of the column to the given number of characters.rr )rrPrrDr%rrr(rrr size_columnVs zGrid.size_columncKs(|j|jj|dd|f|i|S)aQueries or sets the size of the row given by INDEX. INDEX may be any non-negative integer that gives the position of a given row . INDEX can also be the string "default"; in this case, this command queries or sets the default size of all rows. When no option-value pair is given, this command returns a list con- taining the current size setting of the given row . When option-value pairs are given, the corresponding options of the size setting of the given row are changed. Options may be one of the following: pad0 pixels Specifies the paddings to the top of a row. pad1 pixels Specifies the paddings to the bottom of a row. size val Specifies the height of a row. Val may be: "auto" -- the height of the row is set to the height of the highest cell in the row; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the height of the row to the given number of characters.rr )rrPrr%rrrrsize_rowps  z Grid.size_rowcCs|j|jd||dS)z7Clears the cell at (x, y) by removing its display item.unsetNrMrrrrrsz Grid.unset)N)N)N)N)r2r3r4r5r9rrrrrrrrHrJr7r0rrrLrrrrrrrrrs(     rc@seZdZdZdifddZdS) ScrolledGridzScrolled Grid widgetsNcKs"g}||_t||d|||dS)NZtixScrolledGridrrrrrr9szScrolledGrid.__init__rrrrrrsr)ur:r8rZ_tkinterZWINDOWZTEXTZSTATUSZ IMMEDIATEZIMAGEZ IMAGETEXTZBALLOONZAUTOZ ACROSSTOPASCIIZCELLZCOLUMNZ DECREASINGZ INCREASINGZINTEGERZMAINMAXZREALZROWZS_REGIONZX_REGIONZY_REGIONZ TCL_DONT_WAITZTCL_WINDOW_EVENTSZTCL_FILE_EVENTSZTCL_TIMER_EVENTSZTCL_IDLE_EVENTSZTCL_ALL_EVENTSrr6rAra __bases__r[r|rrrrrrrrrrrrrrZXViewZYViewrrYrZr\r_rmrnrqrrr}rrrrrrrrrrrrrrZButtonrZ CheckbuttonrZEntryrZFramer^ZLabelrZListboxrZMenurwZ MenubuttonrvZ ScrollbarrZTextrrrrarrrrrrrrrr`rrrrrrrrrs - 8/,!"C# ()     S.6    *PK! II$__pycache__/tix.cpython-38.opt-2.pycnu[U e5d-,@sLddlZddlZddlTddlmZddlZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZGdd d Z Gd!d"d"ej!e Z!Gd#d$d$Z"ej#j$e"fej#_$Gd%d&d&ej#Z%Gd'd(d(e%Z&Gd)d*d*Z'Gd+d,d,e%Z(Gd-d.d.e%Z)Gd/d0d0e%Z*Gd1d2d2e%Z+Gd3d4d4e%Z,Gd5d6d6e%Z-Gd7d8d8e%Z.Gd9d:d:e%Z/Gd;d<dd>e%Z1Gd?d@d@e%Z2GdAdBdBe%Z3GdCdDdDe%Z4GdEdFdFe%e5e6Z7GdGdHdHe%Z8GdIdJdJe%Z9GdKdLdLe%Z:GdMdNdNe%Z;GdOdPdPe%ZGdUdVdVe%Z?GdWdXdXe%Z@GdYdZdZe%ZAGd[d\d\e%ZBGd]d^d^e%ZCGd_d`d`e%ZDGdadbdbe%ZEGdcdddde%ZFGdedfdfe%ZGGdgdhdhe%ZHGdidjdje%ZIGdkdldle%ZJGdmdndne%ZKGdodpdpe%e5e6ZLGdqdrdre%ZMGdsdtdte%ZNGdudvdveOe&ZPGdwdxdxeQe&ZRGdydzdzeSe&ZTGd{d|d|eUe&ZVGd}d~d~eWe&ZXGdddeYe&ZZGddde[e&Z\Gddde]e&Z^Gddde_e&Z`Gdddeae&ZbGdddeDe&ZcGddde7e&ZdGdddeCe&ZeGdddeLe&ZfGddde*e&ZgGddde,e&ZhGddde.e&ZiGddde/e&ZjGddde2e&ZkGddde*e&ZlGdddeKe&ZmGddde>e&ZnGddde@e&ZoddZpddZqGddde%ZrGddde%e5e6ZsGdddesZtdS)N)*) _cnfmergewindowtextZstatusZ immediateimageZ imagetextZballoonautoZ acrosstopasciiZcellcolumnZ decreasingZ increasingZintegermainmaxrealrowzs-regionzx-regionzy-region c@sReZdZddZddZdddZddd Zd d Zd d ZddZ dddZ dS) tixCommandcCs|jdd|S)NtixZ addbitmapdirtkcall)selfZ directoryr#/usr/lib64/python3.8/tkinter/tix.pytix_addbitmapdirRs ztixCommand.tix_addbitmapdircCs|jdd|S)Nrcgetrroptionrrrtix_cget^sztixCommand.tix_cgetNcKsd|rt||f}n |rt|}|dkr2|ddSt|trN|ddd|S|jd||S)Nr configure-)rr )r _getconfigure isinstancestrZ_getconfigure1rr_optionsrcnfkwrrr tix_configurees   ztixCommand.tix_configurecCs*|dk r|jdd|S|jddSdS)NrZ filedialogr)rZdlgclassrrrtix_filedialog{s ztixCommand.tix_filedialogcCs|jdd|S)NrZ getbitmaprrnamerrr tix_getbitmaps ztixCommand.tix_getbitmapcCs|jdd|S)NrZgetimagerr+rrr tix_getimages ztixCommand.tix_getimagecCs|jddd|S)Nrrgetrr+rrrtix_option_getsztixCommand.tix_option_getcCs2|dk r|jdd|||S|jdd||SdS)NrZ resetoptionsr)rZ newSchemeZ newFontSetZ newScmPriorrrtix_resetoptionssztixCommand.tix_resetoptions)N)N)N) __name__ __module__ __qualname__rrr)r*r-r.r0r1rrrrrGs     rc@seZdZdddZddZdS)TkNTixcCsbtj||||tjd}|jd|dk rR|jd||jd||jddS)NZ TIX_LIBRARYzrrrrKsz Form.checkcCs|jdd|jdS)NrAforgetrLr>rrrrMsz Form.forgetrcCs`|sJ|sJ|jdd|j}|j|}d}|D]}||j|f}q.|S|jdd|j||S)NrAgridr)rrrC splitlistZgetint)rZxsizeZysizexyzrrrrNs z Form.gridNcCs>|s|jdd|jS|ddkr*d|}|jdd|j|S)NrAinforr!rLrrrrrSs  z Form.infocs(fddjjddjDS)Ncsg|]}|qSr) _nametowidget.0rPr>rr szForm.slaves..rAslavesrrOrrCr>rr>rrXs z Form.slaves)rr)N) r2r3r4rDrFrJrKrMrNrSrXrrrrr@s  r@c@sneZdZdddiifddZddZddZdd Zd d Zd d ZddZ ddZ idfddZ ddZ dS) TixWidgetNc Cs|rt||f}nt|}d}|r.|dndg}t|D]&\}}||kr@|d||f}||=q@||_t||||r|jj||j f||rt ||i|_ dS)Nroptionsr!) rappendlistitems widgetNameWidget_setuprrrCrDsubwidget_list) rmasterr_Zstatic_optionsr'r(Zextrakvrrrr8s$  zTixWidget.__init__cCs ||jkr|j|St|dSrE)rbAttributeErrorr+rrr __getattr__Gs  zTixWidget.__getattr__cCs|jd|j|dS)NZ tixSetSilentrL)rrIrrr set_silentLszTixWidget.set_silentcCsD||}|s$td|d|j|t|jdd}||S)Nz Subwidget z not child of )_subwidget_nameTclError_namelenrCrT)rr,nrrr subwidgetPs  zTixWidget.subwidgetcCsZ|}|sgSg}|D]<}|t|jdd}z|||WqYqXq|S)Nri)_subwidget_namesrmrCr\rT)rnamesZretlistr,rrrsubwidgets_allZszTixWidget.subwidgets_allcCs0z|j|jd|WStk r*YdSXdS)Nro)rrrCrkr+rrrrjiszTixWidget._subwidget_namecCs<z |j|jdd}|j|WStk r6YdSXdS)NZ subwidgetsz-all)rrrCrOrk)rrPrrrrpps zTixWidget._subwidget_namescCs\|dkr dSt|tst|}t|ts0t|}|}|D]}|j|dd||qrrr__str__szDisplayStyle.__str__cCsH|r|rt||f}n|r|}d}|D]\}}|d||f}q*|S)Nrr!)rr^)rr'r(Zoptsrdrerrrr%szDisplayStyle._optionscCs|j|jddSNryrrrr>rrrryszDisplayStyle.deletecCs|j|jdd||dS)Nr -%srrGrrrrJszDisplayStyle.__setitem__cKs|j|jdf|||S)Nr )r"rr%r&rrrrDs  zDisplayStyle.configcCs|j|jdd|S)Nrrr)rrHrrr __getitem__szDisplayStyle.__getitem__) r2r3r4r8rr%ryrJrDrrrrrrs   rc@s.eZdZdifddZifddZddZdS)BalloonNcKsNdddddg}t||d|||t|ddd |jd<t|d dd |jd <dS) Nr[ZinstallcolormapZinitwaitZ statusbarZcursorZ tixBalloonlabelrr}messagerZr8 _dummyLabelrbrrcr'r(Zstaticrrrr8 s zBalloon.__init__cKs&|jj|jd|jf|||dSNZbindrB)rwidgetr'r(rrr bind_widgetszBalloon.bind_widgetcCs|j|jd|jdSNZunbindrLrrrrr unbind_widgetszBalloon.unbind_widget)r2r3r4r8rrrrrrrs  rc@s.eZdZdifddZifddZddZdS) ButtonBoxNcKst||dddg||dS)NZ tixButtonBox orientationr[rZr8rrcr'r(rrrr8s  zButtonBox.__init__cKs4|jj|jd|f|||}t|||j|<|SNaddrrrCr% _dummyButtonrb)rr,r'r(Zbtnrrrr#s z ButtonBox.addcCs ||jkr|j|jd|dSNinvokerbrrrCr+rrrr*s zButtonBox.invoker2r3r4r8rrrrrrrs rc@s:eZdZdifddZddZddZdd Zd d ZdS) ComboBoxNc Kst||dddddg||t|d|jd<t|d|jd<t|d|jd<t|d |jd <z$t|d |jd <t|d |jd <Wntk rYnXdS) NZ tixComboBoxZeditableZdropdownfancyr[rentryarrowslistboxtickcross)rZr8rrb _dummyEntryr_dummyScrolledListBox TypeErrorrrrrr8<s    zComboBox.__init__cCs|j|jd|dS)NZ addhistoryrLrr$rrr add_historyNszComboBox.add_historycCs|j|jd|dS)NZ appendhistoryrLrrrrappend_historyQszComboBox.append_historycCs|j|jd||dSNinsertrL)rindexr$rrrrTszComboBox.insertcCs|j|jd|dS)NpickrLrrrrrrWsz ComboBox.pick)r2r3r4r8rrrrrrrrr.s rc@s:eZdZdifddZddZddZdd Zd d ZdS) ControlNcKsZt||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZ tixControlr[incrdecrrr)rZr8rrbrrrrrrr8hs zControl.__init__cCs|j|jddS)NrrLr>rrr decrementoszControl.decrementcCs|j|jddS)NrrLr>rrr incrementrszControl.incrementcCs|j|jddSrrLr>rrrruszControl.invokecCs|j|jddS)NupdaterLr>rrrrxszControl.update)r2r3r4r8rrrrrrrrrZs rc@s eZdZifddZddZdS)DirListcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixDirListr[hlistvsbhsbrZr8 _dummyHListrb_dummyScrollbarrrrrr8szDirList.__init__cCs|j|jd|dSNchdirrLrdirrrrrsz DirList.chdirNr2r3r4r8rrrrrr{s rc@s eZdZifddZddZdS)DirTreecKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixDirTreer[rrrrrrrrr8szDirTree.__init__cCs|j|jd|dSrrLrrrrrsz DirTree.chdirNrrrrrrs rc@seZdZifddZdS) DirSelectBoxcKs:t||ddg||t|d|jd<t|d|jd<dS)NZtixDirSelectBoxr[dirlistdircbx)rZr8 _dummyDirListrb_dummyFileComboBoxrrrrr8szDirSelectBox.__init__Nr2r3r4r8rrrrrsrc@s(eZdZifddZddZddZdS)ExFileSelectBoxcKst||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d |jd <t|d |jd <dS) NZtixExFileSelectBoxr[cancelokhiddentypesrrfilefilelist)rZr8rrb_dummyCheckbutton_dummyComboBoxrrrrrrr8szExFileSelectBox.__init__cCs|j|jddSNfilterrLr>rrrrszExFileSelectBox.filtercCs|j|jddSrrLr>rrrrszExFileSelectBox.invokeN)r2r3r4r8rrrrrrrs rc@s(eZdZifddZddZddZdS)DirSelectDialogcKs*t||ddg||t|d|jd<dS)NZtixDirSelectDialogr[Zdirbox)rZr8_dummyDirSelectBoxrbrrrrr8s  zDirSelectDialog.__init__cCs|j|jddSNpopuprLr>rrrrszDirSelectDialog.popupcCs|j|jddSNpopdownrLr>rrrrszDirSelectDialog.popdownNr2r3r4r8rrrrrrrs rc@s(eZdZifddZddZddZdS)ExFileSelectDialogcKs*t||ddg||t|d|jd<dS)NZtixExFileSelectDialogr[fsbox)rZr8_dummyExFileSelectBoxrbrrrrr8s  zExFileSelectDialog.__init__cCs|j|jddSrrLr>rrrrszExFileSelectDialog.popupcCs|j|jddSrrLr>rrrrszExFileSelectDialog.popdownNrrrrrrs rc@s(eZdZifddZddZddZdS) FileSelectBoxcKsZt||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZtixFileSelectBoxr[rrr selection)rZr8rrbrrrrrr8s zFileSelectBox.__init__cCs|j|jddSrrLr>rrr apply_filterszFileSelectBox.apply_filtercCs|j|jddSrrLr>rrrrszFileSelectBox.invokeN)r2r3r4r8rrrrrrrs rc@s(eZdZifddZddZddZdS)FileSelectDialogcKs:t||ddg||t|d|jd<t|d|jd<dS)NZtixFileSelectDialogr[Zbtnsr)rZr8_dummyStdButtonBoxrb_dummyFileSelectBoxrrrrr8,s zFileSelectDialog.__init__cCs|j|jddSrrLr>rrrr2szFileSelectDialog.popupcCs|j|jddSrrLr>rrrr5szFileSelectDialog.popdownNrrrrrr#s rc@s(eZdZifddZddZddZdS) FileEntrycKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixFileEntryZ dialogtyper[Zbuttonr)rZr8rrbrrrrrr8Ds zFileEntry.__init__cCs|j|jddSrrLr>rrrrJszFileEntry.invokecCsdSrErr>rrr file_dialogMszFileEntry.file_dialogN)r2r3r4r8rrrrrrr8s rc@seZdZdifddZifddZdifddZdd Zd d Zdkd dZddZ ddZ ddZ ddZ ddZ ddZddZddZifdd Zifd!d"Zd#d$Zd%d&ZeZd'd(Zd)d*Zd+d,Zifd-d.Zifd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z dld=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+ifdSdTZ,ifdUdVZ-dWdXZ.dYdZZ/d[d\Z0ifd]d^Z1d_d`Z2dadbZ3ifdcddZ4dedfZ5dmdgdhZ6didjZ7dS)nHListNcKst||dddg||dS)NZtixHListcolumnsr[rrrrrr8Ys  zHList.__init__cKs |jj|jd|f|||SrrBrrr'r(rrrr]sz HList.addcKs(|sd}|jj|jd|f|||S)Nr<ZaddchildrB)rrr'r(rrr add_child`s zHList.add_childcCs|j|jdd|dSNanchorsetrLrrrrr anchor_setfszHList.anchor_setcCs|j|jdddSNrclearrLr>rrr anchor_cleariszHList.anchor_clearrcCs6|s|j|jdd||S|j|jdd|d|SdS)Nr widthz-charrL)rcolrcharsrrr column_widthls zHList.column_widthcCs|j|jdddS)NryallrLr>rrr delete_allsszHList.delete_allcCs|j|jdd|dS)NryrrLrrrr delete_entryvszHList.delete_entrycCs|j|jdd|dS)NryZ offspringsrLrrrrdelete_offspringsyszHList.delete_offspringscCs|j|jdd|dS)NryZsiblingsrLrrrrdelete_siblings|szHList.delete_siblingscCs|j|jdd|dSNdragsiterrLrrrr dragsite_setszHList.dragsite_setcCs|j|jdddSNr rrLr>rrrdragsite_clearszHList.dragsite_clearcCs|j|jdd|dSNdropsiterrLrrrr dropsite_setszHList.dropsite_setcCs|j|jdddSNrrrLr>rrrdropsite_clearszHList.dropsite_clearcKs&|jj|jdd|f|||dS)NheaderrurBrrr'r(rrr header_createszHList.header_createcKs@|dkr||jdd|S|jj|jdd|f|||dS)Nrr r"rCrrr%rrrrheader_configures  zHList.header_configurecCs|j|jdd||S)NrrrL)rroptrrr header_cgetszHList.header_cgetcCs|j|j|jdd|S)NrZexist)rZ getbooleanrrCrrrrr header_existsszHList.header_existscCs|j|jdd|dS)NrryrLrrrr header_deleteszHList.header_deletecCs|j|jdd|S)NrsizerLrrrr header_sizeszHList.header_sizecCs|j|jdd|dS)NhiderrLrrrr hide_entryszHList.hide_entrycKs&|jj|jdd|f|||dS)N indicatorrurBrrrrindicator_creates zHList.indicator_createcKs@|dkr||jdd|S|jj|jdd|f|||dS)Nr"r rrrrrindicator_configures zHList.indicator_configurecCs|j|jdd||S)Nr"rrLrrrrrrindicator_cgetszHList.indicator_cgetcCs|j|jdd|S)Nr"existsrLrrrrindicator_existsszHList.indicator_existscCs|j|jdd|dS)Nr"ryrLrrrrindicator_deleteszHList.indicator_deletecCs|j|jdd|S)Nr"rrLrrrrindicator_sizeszHList.indicator_sizecCs|j|jddSNrSrrLr>rrr info_anchorszHList.info_anchorcCs||j|jdd|pdSNrSZbbox)_getintsrrrCrrrr info_bboxs zHList.info_bboxcCs |j|jdd|}|j|S)NrSrrrrCrO)rrrrrr info_childrenszHList.info_childrencCs|j|jdd|S)NrSdatarLrrrr info_dataszHList.info_datacCs|j|jddS)NrSr rLr>rrr info_dragsiteszHList.info_dragsitecCs|j|jddS)NrSrrLr>rrr info_dropsiteszHList.info_dropsitecCs|j|jdd|SNrSr'rLrrrr info_existsszHList.info_existscCs|j|jdd|S)NrSrrLrrrr info_hiddenszHList.info_hiddencCs|j|jdd|S)NrSnextrLrrrr info_nextszHList.info_nextcCs|j|jdd|S)NrSrrLrrrr info_parentszHList.info_parentcCs|j|jdd|S)NrSprevrLrrrr info_prevszHList.info_prevcCs|j|jdd}|j|SNrSrr0rrrrinfo_selectionszHList.info_selectioncCs|j|jdd|||S)NitemrrL)rrrrrrr item_cgetszHList.item_cgetcKsD|dkr||jdd||S|jj|jdd||f|||dS)Nr@r rrrrr'r(rrritem_configures  zHList.item_configurecKs(|jj|jdd||f|||dS)Nr@rurBrBrrr item_creates zHList.item_createcCs|j|jdd||S)Nr@r'rLrrrrrr item_existsszHList.item_existscCs|j|jdd||dS)Nr@ryrLrErrr item_deleteszHList.item_deletecCs|j|jd||S)N entrycgetrLr%rrrrHszHList.entrycgetcKs<|dkr||jd|S|jj|jd|f|||dSNentryconfigurerrrrrrJs  zHList.entryconfigurecCs|j|jd|SNnearestrL)rrQrrrrLsz HList.nearestcCs|j|jd|dSNseerLrrrrrNsz HList.seecKs$|jj|jddf|||dSNrrrBr&rrrselection_clearszHList.selection_clearcCs|j|jdd|SNrZincludesrLrrrrselection_includes szHList.selection_includescCs|j|jdd||dSNrrrLrfirstZlastrrr selection_set szHList.selection_setcCs|j|jdd|S)NshowrrLrrrr show_entryszHList.show_entry)rNN)N)N)8r2r3r4r8rrrrrrrrr r rrrrrrrZ header_existrrr!r#r$r&r(r)r*r,r/r1r3r4r5r7r8r:r;r=r?rArCrDrFrGrHrJrLrNrPrRrVrXrrrrrQsj            rc@seZdZdifddZdS) InputOnlyNcKst||dd||dS)NZ tixInputOnlyrrrrrr8szInputOnly.__init__rrrrrrYsrYc@seZdZdifddZdS) LabelEntryNcKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixLabelEntry labelsider[rr)rZr8rrbrrrrrr8%s zLabelEntry.__init__rrrrrrZs rZc@seZdZdifddZdS) LabelFrameNcKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixLabelFramer[r[rframe)rZr8rrb _dummyFramerrrrr86s zLabelFrame.__init__rrrrrr\+s r\c@s<eZdZifddZifddZddZddZd d Zd S) ListNoteBookcKsNt||ddg||t|ddd|jd<t|d|jd<t|d|jd<dS)NZtixListNoteBookr[ZpanerrrZshlist)rZr8_dummyPanedWindowrbr_dummyScrolledHListrrrrr8Es  zListNoteBook.__init__cKs:|jj|jd|f|||t|||j|<|j|SrrrrCr%r{rbrr,r'r(rrrrMs zListNoteBook.addcCs ||SrEror+rrrpageRszListNoteBook.pagecCs:|j|j|jd}g}|D]}|||q |SNpagesrrOrrCr\rorrqZretrPrrrrgUs zListNoteBook.pagescCs|j|jd|dSNraiserLr+rrr raise_page]szListNoteBook.raise_pageN)r2r3r4r8rrergrlrrrrr_=s   r_c@seZdZdifddZdS)MeterNcKst||ddg||dS)NZtixMeterr[rrrrrr8es  zMeter.__init__rrrrrrm`srmc@sNeZdZdifddZifddZddZdd Zd d Zd d ZddZ dS)NoteBookNcKs.t||ddg||t|ddd|jd<dS)NZ tixNoteBookr[Znbframerr)rZr8r{rbrrrrr8qszNoteBook.__init__cKs:|jj|jd|f|||t|||j|<|j|Srrbrcrrrrvs z NoteBook.addcCs,|j|jd||j||j|=dSrrrrCrbr=r+rrrry{szNoteBook.deletecCs ||SrErdr+rrrresz NoteBook.pagecCs:|j|j|jd}g}|D]}|||q |Srfrhrirrrrgs zNoteBook.pagescCs|j|jd|dSrjrLr+rrrrlszNoteBook.raise_pagecCs|j|jdS)NraisedrLr>rrrrpszNoteBook.raised) r2r3r4r8rryrergrlrprrrrrnis rnc@s eZdZdS) NoteBookFrameNr2r3r4rrrrrqsrqc@sHeZdZifddZifddZifddZddZd d Zd d Zd S) OptionMenucKs:t||ddg||t|d|jd<t|d|jd<dS)NZ tixOptionMenur[ menubuttonmenurZr8_dummyMenubuttonrb _dummyMenurrrrr8szOptionMenu.__init__cKs&|jj|jdd|f|||dS)NrcommandrBrcrrr add_commandszOptionMenu.add_commandcKs&|jj|jdd|f|||dS)NrZ separatorrBrcrrr add_separatorszOptionMenu.add_separatorcCs|j|jd|dSrrLr+rrrryszOptionMenu.deletecCs|j|jd|dS)NdisablerLr+rrrr|szOptionMenu.disablecCs|j|jd|dS)NenablerLr+rrrr}szOptionMenu.enableN) r2r3r4r8rzr{ryr|r}rrrrrss    rsc@sPeZdZifddZifddZddZddZd d Zifd d Zd dZ dS) PanedWindowcKst||dddg||dS)NZtixPanedWindowrr[rrrrrr8szPanedWindow.__init__cKs>|jj|jd|f|||t||dd|j|<|j|S)Nrr)r~rbrcrrrrs   zPanedWindow.addcCs,|j|jd||j||j|=dSrror+rrrryszPanedWindow.deletecCs|j|jd|dS)NrMrLr+rrrrMszPanedWindow.forgetcCs|j|jd||S)NpanecgetrLr%rrrrszPanedWindow.panecgetcKs<|dkr||jd|S|jj|jd|f|||dS)N paneconfigurerrrrrrszPanedWindow.paneconfigurecs*jjjd}fdd|DS)Npanescsg|]}|qSrrdrUr>rrrWsz%PanedWindow.panes..rY)rrqrr>rrszPanedWindow.panesN) r2r3r4r8rryrMrrrrrrrr~s   r~c@s0eZdZifddZddZddZddZd S) PopupMenucKs:t||ddg||t|d|jd<t|d|jd<dS)NZ tixPopupMenur[rtrurvrrrrr8szPopupMenu.__init__cCs|j|jd|jdSrrLrrrrrszPopupMenu.bind_widgetcCs|j|jd|jdSrrLrrrrrszPopupMenu.unbind_widgetcCs|j|jd|j||dS)NZpostrL)rrrPrQrrr post_widgetszPopupMenu.post_widgetN)r2r3r4r8rrrrrrrrs rc@s8eZdZifddZddZddZddZd d Zd S) ResizeHandlec Ks.ddddddddd g }t||d |||dS) Nr[ryZcursorfgZcursorbgZ handlesizeZ hintcolorZ hintwidthrPrQZtixResizeHandler)rrcr'r(flagsrrrr8s zResizeHandle.__init__cCs|j|jd|jdS)NZ attachwidgetrLrrrr attach_widgetszResizeHandle.attach_widgetcCs|j|jd|jdS)NZ detachwidgetrLrrrr detach_widgetszResizeHandle.detach_widgetcCs|j|jd|jdS)Nr rLrrrrr szResizeHandle.hidecCs|j|jd|jdS)NrWrLrrrrrW szResizeHandle.showN)r2r3r4r8rrr rWrrrrrs  rc@seZdZifddZdS) ScrolledHListcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledHListr[rrrrrrrrr8szScrolledHList.__init__Nrrrrrr src@seZdZifddZdS)ScrolledListBoxcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledListBoxr[listboxrr)rZr8 _dummyListboxrbrrrrrr8szScrolledListBox.__init__Nrrrrrrsrc@seZdZifddZdS) ScrolledTextcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledTextr[rrr)rZr8 _dummyTextrbrrrrrr8%szScrolledText.__init__Nrrrrrr!src@seZdZifddZdS) ScrolledTListcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledTListr[Ztlistrr)rZr8 _dummyTListrbrrrrrr8/szScrolledTList.__init__Nrrrrrr+src@seZdZifddZdS)ScrolledWindowcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledWindowr[rrr)rZr8r^rbrrrrrr8:szScrolledWindow.__init__Nrrrrrr6src@s,eZdZifddZifddZddZdS)Selectc Ks2t||ddddddg||t|d|jd<dS)NZ tixSelectZ allowzeroradiorr[r[rrrrrrr8Gs zSelect.__init__cKs:|jj|jd|f|||t|||j|<|j|SrrrcrrrrNs z Select.addcCs|j|jd|dSrrLr+rrrrSsz Select.invokeNrrrrrr@s  rc@seZdZdifddZdS)ShellNcKst||dddg||dS)NZtixShellr[titlerrrrrr8[szShell.__init__rrrrrrVsrc@s2eZdZdifddZddZddZdd ZdS) DialogShellNc Ks&t||ddddddddg||dS) NZtixDialogShellr[rZmappedZ minheightZminwidthrZ transientrrrrrr8gszDialogShell.__init__cCs|j|jddSrrLr>rrrrnszDialogShell.popdowncCs|j|jddSrrLr>rrrrqszDialogShell.popupcCs|j|jddS)NcenterrLr>rrrrtszDialogShell.center)r2r3r4r8rrrrrrrr^s rc@s"eZdZdifddZddZdS) StdButtonBoxNcKs\t||dddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZtixStdButtonBoxrr[rapplyrhelp)rZr8rrbrrrrr8zs zStdButtonBox.__init__cCs ||jkr|j|jd|dSrrr+rrrrs zStdButtonBox.invoke)r2r3r4r8rrrrrrwsrc@seZdZdifddZddZddZdd Zd d Zd2d d ZddZ ddZ ddZ ddZ ifddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zifd,d-Zd.d/Zd3d0d1ZdS)4TListNcKst||ddg||dS)NZtixTListr[rrrrrr8szTList.__init__cCs|j|jdd|dS)NactiverrLrrrr active_setszTList.active_setcCs|j|jdddS)NrrrLr>rrr active_clearszTList.active_clearcCs|j|jdd|dSrrLrrrrrszTList.anchor_setcCs|j|jdddSrrLr>rrrrszTList.anchor_clearcCs|j|jd||dSrrLrfrom_torrrrysz TList.deletecCs|j|jdd|dSr rLrrrrr szTList.dragsite_setcCs|j|jdddSr rLr>rrrrszTList.dragsite_clearcCs|j|jdd|dSrrLrrrrrszTList.dropsite_setcCs|j|jdddSrrLr>rrrrszTList.dropsite_clearcKs$|jj|jd|f|||dSrrB)rrr'r(rrrrsz TList.insertcCs|j|jddS)NrSrrLr>rrr info_activeszTList.info_activecCs|j|jddSr+rLr>rrrr,szTList.info_anchorcCs|j|jdd|S)NrSZdownrLrrrr info_downszTList.info_downcCs|j|jdd|S)NrSleftrLrrrr info_leftszTList.info_leftcCs|j|jdd|S)NrSrightrLrrrr info_rightszTList.info_rightcCs|j|jdd}|j|Sr>r0rrrrr?szTList.info_selectioncCs|j|jddS)NrSrrLr>rrr info_sizeszTList.info_sizecCs|j|jdd|S)NrSZuprLrrrrinfo_upsz TList.info_upcCs|j|jd||SrKrLrrPrQrrrrLsz TList.nearestcCs|j|jd|dSrMrLrrrrrNsz TList.seecKs$|jj|jddf|||dSrOrBr&rrrrPszTList.selection_clearcCs|j|jdd|SrQrLrrrrrRszTList.selection_includescCs|j|jdd||dSrSrLrTrrrrVszTList.selection_set)N)N)r2r3r4r8rrrrryr rrrrrr,rrrr?rrrLrNrPrRrVrrrrrs0    rc@sDeZdZdifddZddZddZdd Zd d Zdd dZdS)TreeNcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixTreer[rrrrrrrrr8s z Tree.__init__cCs|j|jddSN autosetmoderLr>rrrrszTree.autosetmodecCs|j|jd|dSNcloserLr entrypathrrrrsz Tree.closecCs|j|jd|SNgetmoderLrrrrrsz Tree.getmodecCs|j|jd|dSNopenrLrrrrrsz Tree.opennonecCs|j|jd||dS)NsetmoderLrrmoderrrrs z Tree.setmode)r) r2r3r4r8rrrrrrrrrrs rc@sVeZdZdifddZddZddZdd Zd d Zdd dZddZ dddZ dS) CheckListNcKsLt||dddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixCheckListr[rrrrrrrrrr8s zCheckList.__init__cCs|j|jddSrrLr>rrrrszCheckList.autosetmodecCs|j|jd|dSrrLrrrrrszCheckList.closecCs|j|jd|SrrLrrrrr szCheckList.getmodecCs|j|jd|dSrrLrrrrr$szCheckList.openoncCs|j|j|jd|S)N getselectionrY)rrrrrr(szCheckList.getselectioncCs|j|jd|S)N getstatusrLrrrrr.szCheckList.getstatuscCs|j|jd||dS)N setstatusrLrrrrr2szCheckList.setstatus)r)r) r2r3r4r8rrrrrrrrrrrrs rc@seZdZdddZdS)rricCst||||dSrEr{r8rrcr,r}rrrr8>sz_dummyButton.__init__N)rirrrrrr=src@seZdZdddZdS)rricCst||||dSrErrrrrr8Bsz_dummyCheckbutton.__init__N)rirrrrrrAsrc@seZdZdddZdS)rricCst||||dSrErrrrrr8Fsz_dummyEntry.__init__N)rirrrrrrEsrc@seZdZdddZdS)r^ricCst||||dSrErrrrrr8Jsz_dummyFrame.__init__N)rirrrrrr^Isr^c@seZdZdddZdS)rricCst||||dSrErrrrrr8Nsz_dummyLabel.__init__N)rirrrrrrMsrc@seZdZdddZdS)rricCst||||dSrErrrrrr8Rsz_dummyListbox.__init__N)rirrrrrrQsrc@seZdZdddZdS)rxricCst||||dSrErrrrrr8Vsz_dummyMenu.__init__N)rirrrrrrxUsrxc@seZdZdddZdS)rwricCst||||dSrErrrrrr8Zsz_dummyMenubutton.__init__N)rirrrrrrwYsrwc@seZdZdddZdS)rricCst||||dSrErrrrrr8^sz_dummyScrollbar.__init__N)rirrrrrr]src@seZdZdddZdS)rricCst||||dSrErrrrrr8bsz_dummyText.__init__N)rirrrrrrasrc@seZdZdddZdS)rricCsDt||||t|d|jd<t|d|jd<t|d|jd<dS)Nrrr)r{r8rrbrrrrrr8fsz_dummyScrolledListBox.__init__N)rirrrrrresrc@seZdZdddZdS)rricCst||||dSrErrrrrr8msz_dummyHList.__init__N)rirrrrrrlsrc@seZdZdddZdS)raricCsDt||||t|d|jd<t|d|jd<t|d|jd<dSNrrrr{r8rrbrrrrrr8qsz_dummyScrolledHList.__init__N)rirrrrrrapsrac@seZdZdddZdS)rricCst||||dSrErrrrrr8xsz_dummyTList.__init__N)rirrrrrrwsrc@seZdZdddZdS)rricCst|||d|gt|d|jd<t|d|jd<t|d|jd<t|d|jd<z$t|d|jd<t|d|jd<Wntk rYnXdS)Nrrrrrrr)r{r8rrbrrrrrrrrr8|s z_dummyComboBox.__init__N)rirrrrrr{src@seZdZdddZdS)rricCsDt||||t|d|jd<t|d|jd<t|d|jd<dSrrrrrrr8sz_dummyDirList.__init__N)rirrrrrrsrc@seZdZdddZdS)rricCs4t||||t|d|jd<t|d|jd<dS)Nrr)r{r8rrbrrrrrr8sz_dummyDirSelectBox.__init__N)rirrrrrrsrc@seZdZdddZdS)rricCst||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS) Nrrrrrrrr)r{r8rrbrrrrrrrr8sz_dummyExFileSelectBox.__init__N)rirrrrrrsrc@seZdZdddZdS)rricCsTt||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)Nrrrr)r{r8rrbrrrrrr8s z_dummyFileSelectBox.__init__N)rirrrrrrsrc@seZdZdddZdS)rricCs$t||||t|d|jd<dS)Nr)r{r8rrbrrrrr8sz_dummyFileComboBox.__init__N)rirrrrrrsrc@seZdZdddZdS)rricCsTt||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)Nrrrr)r{r8rrbrrrrr8s z_dummyStdButtonBox.__init__N)rirrrrrrsrc@seZdZdddZdS)_dummyNoteBookFramercCst||||dSrErrrrrr8sz_dummyNoteBookFrame.__init__N)rrrrrrrsrc@seZdZdddZdS)r`ricCst||||dSrErrrrrr8sz_dummyPanedWindow.__init__N)rirrrrrr`sr`cCs|jd|jS)NZ tixOptionNamerL)rrrr OptionNamesrcCs:d}|D](}|d|d|d||d}q |S)Nr<z{{z} {z - z}} )keys)dictstyperrr FileTypeLists &rc@s eZdZdS)CObjViewNrrrrrrrsrc@seZdZdifddZddZddZdd Zd(d d Zd)d d ZddZ ddZ ddZ d*ddZ ddZ ddZddZddZddZd+d d!Zd"d#Zd$d%Zd&d'ZdS),GridNcKs"g}||_t||d|||dS)NZtixGridr'rZr8rrrrr8sz Grid.__init__cCs|j|dddSrrr>rrrrszGrid.anchor_clearcCs||j|ddS)Nrr/r.rrr>rrr anchor_getszGrid.anchor_getcCs|j|dd||dSrrrrrrrszGrid.anchor_setcCs4|dkr|j|dd|n|j|dd||dS)Nryr rrrrr delete_row szGrid.delete_rowcCs4|dkr|j|dd|n|j|dd||dS)Nryr rrrrr delete_columnszGrid.delete_columncCs|j|dddS)Neditrrr>rrr edit_applyszGrid.edit_applycCs|j|dd||dS)Nrrrrrrredit_set!sz Grid.edit_setcCs,|r|ddkrd|}|j|d|||S)Nrr!rHr)rrPrQrrrrrH&szGrid.entrycgetcKs|d||f||SrI)Z _configure)rrPrQr'r(rrrrJ,szGrid.entryconfigurec Cs||j|dd||Sr6)Z _getbooleanrrrrrrr72szGrid.info_existscCs|j|dd||Sr-rrrrrr/6szGrid.info_bboxcCs|j|dd|||dS)Nmover rrrroffsetrrr move_column:szGrid.move_columncCs|j|dd|||dS)Nrr rrrrrmove_row@sz Grid.move_rowcCs||j|d||SrKrrrrrrLFsz Grid.nearestcKs>||j|}|dk r"d|f|}|jj|d||f|dS)Nz -itemtyper)r%r'rr)rrPrQrr(argsrrrrPs zGrid.setcKs*|j|jj|jdd|f|i|S)Nrr )rrOrrCr%rrr(rrr size_columnVs zGrid.size_columncKs(|j|jj|dd|f|i|S)Nrr )rrOrr%rrrrsize_rowps  z Grid.size_rowcCs|j|jd||dS)NunsetrLrrrrrsz Grid.unset)N)N)N)N)r2r3r4r8rrrrrrrrHrJr7r/rrrLrrrrrrrrrs&     rc@seZdZdifddZdS) ScrolledGridNcKs"g}||_t||d|||dS)NZtixScrolledGridrrrrrr8szScrolledGrid.__init__rrrrrrsr)ur9r7rZ_tkinterZWINDOWZTEXTZSTATUSZ IMMEDIATEZIMAGEZ IMAGETEXTZBALLOONZAUTOZ ACROSSTOPASCIIZCELLZCOLUMNZ DECREASINGZ INCREASINGZINTEGERZMAINMAXZREALZROWZS_REGIONZX_REGIONZY_REGIONZ TCL_DONT_WAITZTCL_WINDOW_EVENTSZTCL_FILE_EVENTSZTCL_TIMER_EVENTSZTCL_IDLE_EVENTSZTCL_ALL_EVENTSrr5r@r` __bases__rZr{rrrrrrrrrrrrrrZXViewZYViewrrYrZr\r_rmrnrqrsr~rrrrrrrrrrrrrrZButtonrZ CheckbuttonrZEntryrZFramer^ZLabelrZListboxrZMenurxZ MenubuttonrwZ ScrollbarrZTextrrrrarrrrrrrrrr`rrrrrrrrrs - 8/,!"C# ()     S.6    *PK!寉CC-__pycache__/colorchooser.cpython-38.opt-2.pycnu[U e5dA @s>ddlmZGdddeZd ddZedkr:ededS) )Dialogc@s eZdZdZddZddZdS)ChooserZtk_chooseColorcCs@z&|jd}t|tr$d||jd<Wntk r:YnXdS)N initialcolorz #%02x%02x%02x)options isinstancetupleKeyError)selfcolorr ,/usr/lib64/python3.8/tkinter/colorchooser.py _fixoptions!s   zChooser._fixoptionscCs>|r t|sdS||\}}}|d|d|dft|fS)N)NN)strZ winfo_rgb)r Zwidgetresultrgbr r r _fixresult.s zChooser._fixresultN)__name__ __module__ __qualname__Zcommandr rr r r r rs rNcKs"|r|}||d<tf|S)Nr)copyrZshow)r rr r r askcolorBsr__main__r )N)Ztkinter.commondialogrrrrprintr r r r  s 3 PK!xx$__pycache__/constants.cpython-38.pycnu[U e5d@s8dZZZdZZZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Zd;Z?dZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIS)JnsweZnwswneZsensZewZnsewcenterZnonexyZbothlefttoprightZbottomZraisedZsunkenZflatZridgeZgrooveZsolidZ horizontalZverticalZnumericcharZwordZbaselineZinsideZoutsideZselz sel.firstzsel.lastendinsertZcurrentZanchorallZnormalZdisabledZactiveZhiddenZcascadeZ checkbuttonZcommandZ radiobuttonZ separatorZsingleZbrowseZmultipleZextendedZdotboxZ underlineZpiesliceZchordZarcfirstZlastZbuttZ projectingroundZbevelZmiterZmovetoZscrollZunitsZpagesN)MZNOZFALSEZOFFZYESZTRUEZONNSWEZNWZSWZNEZSEZNSZEWZNSEWZCENTERZNONEXYZBOTHZLEFTZTOPZRIGHTZBOTTOMZRAISEDZSUNKENZFLATZRIDGEZGROOVEZSOLIDZ HORIZONTALZVERTICALZNUMERICZCHARZWORDZBASELINEZINSIDEZOUTSIDEZSELZ SEL_FIRSTZSEL_LASTZENDZINSERTZCURRENTZANCHORZALLZNORMALZDISABLEDZACTIVEZHIDDENZCASCADEZ CHECKBUTTONZCOMMANDZ RADIOBUTTONZ SEPARATORZSINGLEZBROWSEZMULTIPLEZEXTENDEDZDOTBOXZ UNDERLINEZPIESLICEZCHORDZARCZFIRSTZLASTZBUTTZ PROJECTINGZROUNDZBEVELZMITERZMOVETOZSCROLLZUNITSZPAGESrr)/usr/lib64/python3.8/tkinter/constants.pys  PK!VFi%__pycache__/font.cpython-38.opt-2.pycnu[U e5d@@szdZddlZddlZdZdZdZdZddZGd d d Zd d d Z d!d dZ e dkrve Z eddedZeeeedeedeeeedeedee eededeeje deddZeedejde deje dedZeeje de jdZeeeddZejedejededS)"z0.9NZnormalZromanboldZitaliccCs t|ddS)NT)nameexists)Fontrr$/usr/lib64/python3.8/tkinter/font.py nametofontsr c@seZdZedZddZddZddZd"d d Z d d Z ddZ ddZ ddZ ddZddZd#ddZddZddZeZd$ddZd d!ZdS)%rcCs:g}|D]$\}}|d||t|q t|SN-)itemsappendstrtuple)selfkwoptionskvrrr_set1s z Font._setcCs$g}|D]}|d|qt|Sr )rr)rargsrrrrr_get8sz Font._getcCs:i}tdt|dD] }||d|||dd<q|S)Nrr )rangelen)rrrirrr_mkdict>sz Font._mkdictNFcKs|std}t|d|}|r4||dd|}n ||}|sTdtt|j}||_ |rd|_ |j ||ddkrtj d|j f|r|jdd|j f|n|jdd |j f|d |_ ||_ |j|_|j|_dS) Nzuse fonttkfontactualFnamesz$named font %s does not already exist configureZcreateT)tkinter_get_default_rootgetattr splitlistcallrrnextcounterr delete_fontZ_tkinterZTclError_tk_split_call)rrootrrrrrrrr__init__Ds,    z Font.__init__cCs|jSNrrrrr__str__csz Font.__str__cCs&t|tstS|j|jko$|j|jkSr0) isinstancerNotImplementedrr+)rotherrrr__eq__fs z Font.__eq__cCs ||Sr0)cget)rkeyrrr __getitem__kszFont.__getitem__cCs|jf||idSr0)r")rr8valuerrr __setitem__nszFont.__setitem__cCs4z|jr|dd|jWntk r.YnXdS)Nrdelete)r*r-r Exceptionr1rrr__del__qs z Font.__del__cCst|jf|Sr0)rr+r r1rrrcopyxsz Font.copycCs^d}|rd|f}|r8|d|f}|jdd|jf|S|||jdd|jf|SdS)Nr -displayofr rr )r-rrr,)roption displayofrrrrr |sz Font.actualcCs|dd|jd|S)Nrconfigr )r-r)rrArrrr7sz Font.cgetc KsB|r"|jdd|jf||n|||dd|jSdS)NrrC)r-rrrr,)rrrrrrCsz Font.configcCs2|f}|rd||f}|j|jdd|jf|S)Nr@rmeasure)r+getintr-r)rtextrBrrrrrDs z Font.measurecOsd}|dd}|rd|f}|rL|||}|j|jdd|jf|S||jdd|jf|}i}tdt|dD](}|j||d|||dd<q||SdS) NrrBr@rmetricsrrr ) poprr+rEr-rr,rr)rrrrrBresrrrrrGs &z Font.metrics)NNNF)NN)N)__name__ __module__ __qualname__ itertoolscountr)rrrr/r2r6r9r;r>r?r r7rCr"rDrGrrrrrs"     rcCs6|std}d}|rd|f}|j|jjd|S)Nzuse font.families()rr@rfamilies)rrOr#r$rr&r')r.rBrrrrrOs  rOcCs$|std}|j|jddS)Nzuse font.names()rr!rP)r.rrrr!s r!__main__times)familysizeweightrTrVZhelloZ linespace)rB)ZCourierr)rz Hello, world)rFrzQuit!)rFZcommandr)rV)NN)N) __version__rMr#ZNORMALZROMANZBOLDZITALICr rrOr!rJZTkr.fprintr rCr7rDrGZLabelwZpackZButtonZdestroyr?ZfbZmainlooprrrrsB       PK!ҧ!__pycache__/dialog.cpython-38.pycnu[U e5d@srddlTddlmZdZGdddeZddZedkrned d d d eeiiZ ed d d d e j eiiZ e d S))*) _cnfmergeZ questheadc@s"eZdZdifddZddZdS)DialogNc Kst||f}d|_t||||j|jjd|j|d|d|d|df|d|_zt |Wnt k r~YnXdS)NZ __dialog__Z tk_dialogtitletextbitmapdefaultstrings) rZ widgetNameWidget_setupZtkZgetintZcallZ_wnumdestroyZTclError)selfZmasterZcnfkwr&/usr/lib64/python3.8/tkinter/dialog.py__init__ s& zDialog.__init__cCsdS)Nr)rrrrr zDialog.destroy)__name__ __module__ __qualname__rr rrrrr s rcCs$tdddtddd}t|jdS)Nz File ModifiedzzFile "Python.h" has been modified since the last time it was saved. Do you want to save it before exiting the application.r)z Save FilezDiscard ChangeszReturn to Editor)rrrrr )r DIALOG_ICONprintr )drrr_tests r__main__NrZTestZcommandZQuit) Ztkinterrrr rrrZButtonZPacktquitqZmainlooprrrrs$ PK!b pnn$__pycache__/ttk.cpython-38.opt-2.pycnu[U e5d@sdZdZdddddddd d d d d dddddddddddddgZddlZddlmZmZmZmZejdkrldnd Z d!d"Z dWd#d$Z dXd%d&Z d'd(Z dYd)d*ZdZd+d,Zd[d.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;ZddZd\d?dZGd@ddeZGdAdBdBejZGdCddeZGdDddeZGdEddeejZGdFddeZ GdGddeZ!GdHddeZ"GdIddeZ#e#Z$GdJd d eZ%GdKd d eZ&GdLd d eej'Z(e(Z'GdMddeZ)GdNddeZ*GdOddeej+Z+GdPddeej,Z,GdQddeZ-GdRddeZ.GdSddeZ/GdTddeej0ej1Z2GdUdde!Z3GdVdde%Z4dS)]z0.3.1z!Guilherme Polo Button CheckbuttonComboboxEntryFrameLabel Labelframe LabelFrame MenubuttonNotebook Panedwindow PanedWindow Progressbar RadiobuttonScale Scrollbar SeparatorSizegripSpinboxStyleTreeview LabeledScale OptionMenu tclobjs_to_py setup_masterN)_flatten_join _stringify _splitdictg!@TFcCsBtr>ddl}|jd}|r,|jd||jdd|_dS)NrZ TILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT) _REQUIRE_TILEosenvirongettkeval _tile_loaded)masterr Ztilelibr'#/usr/lib64/python3.8/tkinter/ttk.py _load_tile"s  r)cCs(|rt|}nt|ttfr$t|}|SN)r isinstancelisttupler)valuescriptr'r'r(_format_optvalue1s  r0cCsPg}|D]:\}}|r ||kr |d||dk r |t||q t|SN-%s)itemsappendr0r)Zoptdictr/ignoreoptsoptr.r'r'r(_format_optdict;s r8cCsXg}|D]J^}}t|dkr,|dp(d}n d|}|||dk r||q|S)Nr )lenjoinr4)r3Zopt_valstatevalr'r'r(_mapdict_valuesKs    r@cCs:g}|D]$\}}|d|tt||fq t|Sr1)r3extendr0r@r)Zmapdictr/r6r7r.r'r'r(_format_mapdict`s   rBc Osd}d}|dkr|dkrB|d}tt|dd}d||f}n2|dd\}} tt|dd} d|| | f}t||}n,|d kr|d}t|dkrt|d|f}|rd |}d |}||fS) Nr')imageZvsapirCrr9z%s %sz%s %s %sfromz{%s}r;)rr@r8r<r0r=) etyper/argskwspecr6ZinameZ imagespec class_nameZpart_idZstatemapr'r'r(_format_elemcreateqs&   rKrDc Csg}|D]}|\}}|pi}dt|dd}dd|||rDd|ndf}d|kr||d||7}t|d||\} }|| ||8}|d d|q||qd ||fS) Nr;T)childrenz%s%s%sz %sr:rLz -children {z%s} )r=r8r4_format_layoutlist) layoutindentZ indent_sizer/Z layout_elemelemr6ZfoptsheadZ newscriptr'r'r(rNs"   rNc CsXg}|D]>\}}|drFdt|dd}|d||f|drvdt|dd}|d||fd|kr|dsd}nt|d\}}|d ||f|d r |d }|d }d }|t|krt||d s|d 7}q|d |} |t|kr||r||ni} t |df| | \} }|d||| |fq d|S)N configurer;Tzttk::style configure %s %s;mapzttk::style map %s %s;rOnullzttk::style layout %s { %s }zelement createrr9r3z%ttk::style element create %s %s %s %srM) r3r"r=r8r4rBrNr<hasattrrK) settingsr/namer6s_ZeoptsrFZargcZelemargsZelemkwrIr'r'r(_script_from_settingss:     $ r[cCst|tr|Sg}t|}t||D]j\}}t|drDt|}n(t|trX|}nt|ttfsl|f}t|dr~t|}|||fq$|S)Ntypename) r+striterziprVsplitr-r,r4)Zstupleresultitr>r?r'r'r(_list_from_statespecs     rccCs||}g}d}|t|kr||}i}|||f|d7}|t|kr|||d\}}|dslq|dd}|d7}|dkrt||}|||<q@q|S)Nrr9rD-rL) splitlistr<r4 startswith_list_from_layouttuple)r#ZltupleresZindxrXr6r7r?r'r'r(rgs$       rgcGs4t|}|j||}t|dr&|St||tdS)NrD)conv)r8callr<r _tclobj_to_py)r#optionsrGrhr'r'r( _val_or_dict!s  rmc Cs2t|}z t|}Wnttfk r,YnX|Sr*)r]int ValueError TypeError)r.r'r'r(_convert_stringval1s  rqcCs(t|tr$d|krt|}nt|}|S)N.)r+r]floatrn)xr'r'r( _to_number;s   rucCs\|rFt|drFt|tsFt|ddddkr6t|}qXttt|}nt|drXt|}|S)N__len__rr\Z StateSpec)rVr+r]getattrrcr,rTrq)r?r'r'r(rkCs  rkcCs"|D]\}}t|||<q|Sr*)r3rk)Zadictr7r?r'r'r(rPscCs|dkrt}|Sr*)tkinterZ_get_default_root)r&r'r'r(rXsc@s~eZdZdZdddZdddZdddZdd d Zdd d Zd dZ ddZ ddZ d ddZ ddZ ddZd!ddZdS)"rz ttk::styleNcCs0t|}t|ddst|||_|jj|_dS)Nr%F)rrwr)r&r#)selfr&r'r'r(__init__is  zStyle.__init__cKs4|dk rd||<t|j||jd|}|s,|r0|SdS)NrS)rmr#_namerystyleZ query_optrHrar'r'r(rSts zStyle.configurec sj|dk r0jjd|d|}tj|Sjjjd|ft|}fddtj|DS)NrTr2cs"i|]\}}|tj|qSr')rcr#re).0kvryr'r( szStyle.map..)r#rjr{rcrerBrr3r|r'rr(rTs z Style.mapcCs.|rd|nd}|j|jd|d|||S)Nr;r:lookupr2)r=r#rjr{)ryr}optionr>defaultr'r'r(rs z Style.lookupcCs>d}|rt|d}n |dk r"d}t|j|j|jd||S)NrrUrO)rNrgr#rjr{)ryr}Z layoutspecZlspecr'r'r(rOs z Style.layoutcOs8t|df||\}}|jj|jdd|||f|dS)NFelementcreate)rKr#rjr{)ry elementnamerFrGrHrIr6r'r'r(element_creates zStyle.element_createc Cs(tdd|j|j|jddDS)Ncss|]}|dVqdSrdNlstrip)r~nr'r'r( sz&Style.element_names..rnamesr-r#rerjr{rr'r'r( element_namesszStyle.element_namesc Cs*tdd|j|j|jdd|DS)Ncss|]}|dVqdSrr)r~or'r'r(rsz(Style.element_options..rrlr)ryrr'r'r(element_optionsszStyle.element_optionsc CsN|r t|nd}|r2|j|jdd|d|d|n|j|jdd|d|dS)Nr:themerz-parentz -settingsr[r#rjr{)ry themenameparentrWr/r'r'r( theme_createszStyle.theme_createcCs"t|}|j|jdd||dS)NrrWr)ryrrWr/r'r'r(theme_settingsszStyle.theme_settingscCs|j|j|jddS)Nrr)r#rerjr{rr'r'r( theme_namesszStyle.theme_namescCs&|dkr|jdS|jd|dS)Nzreturn $ttk::currentThemez ttk::setTheme)r#r$rj)ryrr'r'r( theme_uses zStyle.theme_use)N)N)N)NN)N)NN)N)__name__ __module__ __qualname__r{rzrSrTrrOrrrrrrrr'r'r'r(rds  +  c@s2eZdZd ddZddZd ddZd dd ZdS) WidgetNcCs4t|}t|ddst|tjj||||ddS)Nr%F)rH)rrwr)rxrrz)ryr&Z widgetnamerHr'r'r(rzs zWidget.__init__cCs|j|jd||SNidentifyr#rj_wryrtyr'r'r(r+szWidget.identifyc Os6|j|j|jdd|}|r2|r2|||S|S)Ninstater;)r# getbooleanrjrr=)ry statespeccallbackrGrHZretr'r'r(r3s  zWidget.instatecCs0|dk rd|}|jt|j|jd|S)Nr;r>)r=r#rer]rjr)ryrr'r'r(r>Bs z Widget.state)N)N)N)rrrrzrrr>r'r'r'r(r s  rc@seZdZdddZddZdS)rNcKst||d|dS)Nz ttk::buttonrrzryr&rHr'r'r(rzSs zButton.__init__cCs|j|jdSNinvokerrr'r'r(rbsz Button.invoke)Nrrrrzrr'r'r'r(rOs c@seZdZdddZddZdS)rNcKst||d|dS)Nzttk::checkbuttonrrr'r'r(rzjs zCheckbutton.__init__cCs|j|jdSrrrr'r'r(ryszCheckbutton.invoke)Nrr'r'r'r(rgs c@s.eZdZd ddZddZddZdd ZdS) rNcKst|||pd|dS)Nz ttk::entryr)ryr&ZwidgetrHr'r'r(rzszEntry.__init__cCs||j|jd|S)NbboxZ_getintsr#rjr)ryindexr'r'r(rsz Entry.bboxcCs|j|jd||Srrrr'r'r(rszEntry.identifycCs|j|j|jdS)Nvalidater#rrjrrr'r'r(rszEntry.validate)NN)rrrrzrrrr'r'r'r(rs c@s(eZdZdddZd ddZddZdS) rNcKstj||df|dS)Nz ttk::comboboxrrzrr'r'r(rzs zCombobox.__init__cCs2|dkr |j|j|jdS|j|jd|S)Ncurrentr#Zgetintrjr)ryZnewindexr'r'r(rszCombobox.currentcCs|j|jd|dSNsetrryr.r'r'r(rsz Combobox.set)N)N)rrrrzrrr'r'r'r(rs  c@seZdZdddZdS)rNcKst||d|dS)Nz ttk::framerrr'r'r(rzs zFrame.__init__)Nrrrrzr'r'r'r(rsc@seZdZdddZdS)rNcKst||d|dS)Nz ttk::labelrrr'r'r(rzs zLabel.__init__)Nrr'r'r'r(rsc@seZdZdddZdS)rNcKst||d|dS)Nzttk::labelframerrr'r'r(rzs zLabelframe.__init__)Nrr'r'r'r(rsc@seZdZdddZdS)r NcKst||d|dS)Nzttk::menubuttonrrr'r'r(rzs zMenubutton.__init__)Nrr'r'r'r(r sc@sjeZdZdddZddZddZdd Zd d Zd d ZddZ dddZ dddZ ddZ ddZ dS)r NcKst||d|dS)Nz ttk::notebookrrr'r'r(rz"szNotebook.__init__cKs |jj|jd|ft|dSNaddr#rjrr8)rychildrHr'r'r(rBsz Notebook.addcCs|j|jd|dS)Nforgetrrytab_idr'r'r(rJszNotebook.forgetcCs|j|jd|dS)Nhiderrr'r'r(rPsz Notebook.hidecCs|j|jd||Srrrr'r'r(rYszNotebook.identifycCs|j|j|jd|SNrrrr'r'r(r_szNotebook.indexcKs"|jj|jd||ft|dSNinsertrryposrrHr'r'r(reszNotebook.insertcCs|j|jd|S)Nselectrrr'r'r(rnszNotebook.selectcKs$|dk rd||<t|j||jd|S)Ntabrmr#r)ryrrrHr'r'r(rxsz Notebook.tabcCs|j|j|jdpdS)Ntabsr'r#rerjrrr'r'r(rsz Notebook.tabscCs|jd|jdS)Nzttk::notebook::enableTraversalrrr'r'r(enable_traversalszNotebook.enable_traversal)N)N)N)rrrrzrrrrrrrrrrr'r'r'r(r s   c@s:eZdZd ddZejjZddZd ddZd dd Z dS) r NcKst||d|dS)Nzttk::panedwindowrrr'r'r(rzszPanedwindow.__init__cKs"|jj|jd||ft|dSrrrr'r'r(rszPanedwindow.insertcKs$|dk rd||<t|j||jd|S)Npaner)ryrrrHr'r'r(rszPanedwindow.panecCs|j|j|jd||S)Nsashposr)ryrZnewposr'r'r(rszPanedwindow.sashpos)N)N)N) rrrrzrxr rrrrr'r'r'r(r s   c@s2eZdZd ddZd ddZd ddZdd ZdS) r NcKst||d|dS)Nzttk::progressbarrrr'r'r(rzs zProgressbar.__init__cCs|j|jd|dS)Nstartr)ryZintervalr'r'r(rszProgressbar.startcCs|j|jd|dS)Nstepr)ryZamountr'r'r(rszProgressbar.stepcCs|j|jddS)Nstoprrr'r'r(rszProgressbar.stop)N)N)N)rrrrzrrrr'r'r'r(r s   c@seZdZdddZddZdS)rNcKst||d|dS)Nzttk::radiobuttonrrr'r'r(rz s zRadiobutton.__init__cCs|j|jdSrrrr'r'r(rszRadiobutton.invoke)Nrr'r'r'r(rs c@s*eZdZdddZd ddZd ddZdS) rNcKst||d|dS)Nz ttk::scalerrr'r'r(rz's zScale.__init__cKsTtj||f|}t|tdtfs,||td|kd|kd|kgrP|d|S)NrEfrom_to<>)rrSr+typer]updateanyZevent_generate)ryZcnfrHZretvalr'r'r(rS5s   zScale.configurecCs|j|jd||S)Nr"rrr'r'r(r"Bsz Scale.get)N)N)NN)rrrrzrSr"r'r'r'r(r#s  c@seZdZdddZdS)rNcKst||d|dS)Nzttk::scrollbarrrr'r'r(rzNs zScrollbar.__init__)Nrr'r'r'r(rKsc@seZdZdddZdS)rNcKst||d|dS)Nzttk::separatorrrr'r'r(rz`s zSeparator.__init__)Nrr'r'r'r(r\sc@seZdZdddZdS)rNcKst||d|dS)Nz ttk::sizegriprrr'r'r(rzrszSizegrip.__init__)Nrr'r'r'r(rnsc@seZdZdddZddZdS)rNcKstj||df|dS)Nz ttk::spinboxrrr'r'r(rzs zSpinbox.__init__cCs|j|jd|dSrrrr'r'r(rsz Spinbox.set)N)rrrrzrr'r'r'r(r|s c@s0eZdZdDddZdEddZdFddZdd ZdGd d Zd d ZddZ ddZ dHddZ dIddZ ddZ ddZddZddZddZd d!ZdJd"d#ZdKd$d%Zd&d'ZeZd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dLdd?Z"dNd@dAZ#dOdBdCZ$dS)PrNcKst||d|dS)Nz ttk::treeviewrrr'r'r(rzszTreeview.__init__cCs||j|jd||pdS)Nrr:r)ryitemcolumnr'r'r(rsz Treeview.bboxcCs"|j|j|jd|pdpdS)NrLr:r'rryrr'r'r( get_childrenszTreeview.get_childrencGs|j|jd||dS)NrLr)ryrZ newchildrenr'r'r( set_childrenszTreeview.set_childrencKs$|dk rd||<t|j||jd|S)Nrr)ryrrrHr'r'r(rszTreeview.columncGs|j|jd|dS)Ndeleterryr3r'r'r(rszTreeview.deletecGs|j|jd|dS)Ndetachrrr'r'r(rszTreeview.detachcCs|j|j|jd|S)Nexistsrrr'r'r(rszTreeview.existscCs|j|jd|S)Nfocusrrr'r'r(rszTreeview.focuscKsP|d}|r,t|ts,|j||j|d<|dk rt|dkr&t|dttfr&|d}|j|jd||dS)Nr9rr)r<r+r-r,r#rjr)ryZselopr3r'r'r( _selectionszTreeview._selectioncGs|d|dSrrrr'r'r( selection_setszTreeview.selection_setcGs|d|dSrrrr'r'r( selection_addszTreeview.selection_addcGs|d|dS)Nremoverrr'r'r(selection_removeszTreeview.selection_removecGs|d|dS)NZtogglerrr'r'r(selection_toggleszTreeview.selection_togglecCs@|j|jd|||}|dkr8|dkr8t|j|dtdS|SdS)NrF)Z cut_minusri)r#rjrrrk)ryrrr.rhr'r'r(rsz Treeview.setcCs |j|jdd|f||dddS)Ntagbindr)r)Z_bindr)rytagnameZsequencerr'r'r(tag_bindszTreeview.tag_bindcKs&|dk rd||<t|j||jdd|S)NrrSr)ryrrrHr'r'r( tag_configures zTreeview.tag_configurec CsF|dkr$|j|j|jdd|S|j|j|jdd||SdS)NrZhas)r#rerjrr)ryrrr'r'r(tag_hasszTreeview.tag_has)N)N)N)N)N)N)N)N)NN)NN)N)N)%rrrrzrrrrrrrrrrrrrrrrrrZreattachrrrrrrrrrrrrrrr'r'r'r(rsD              csHeZdZd ddZfddZdd Zed d Zejd d ZZ S)rNr c Ks|dddk|_tj||f||p.t||_|j|||_t ||_ t ||j||d|_ |j d|j|jr|dnd}|dkrdnd}|j j|ddt |}|j|d||j j|dkrd nd d |jd |j|_| d |j| d|jdS)NZcompoundtop)variablerrrZbottomrt)sideZfill)rrrY)Zanchorwz z)pop _label_toprrzrxZIntVar _variabler _last_validrlabelrscaler_adjustZpacklowerZplaceZtrace_variable_LabeledScale__tracecb) ryr&rrrrHZ scale_sideZ label_sideZdummyr'r'r(rzs$    zLabeledScale.__init__csHz|jd|jWntk r(YnX|`td|_d|_dS)Nr)rZ trace_vdeleter AttributeErrorsuperdestroyrr r __class__r'r(r s zLabeledScale.destroycsfdd}tjd}tjd}||kr:||}}j}||krX|ksfnj_dS|_|jd<|dS)NcsZj\}}jr2jj}njj}jj||ddS)Nrtr)Zupdate_idletasksr ZcoordsrZwinfo_yrZwinfo_reqheightZplace_configurerrr'r( adjust_labels z*LabeledScale._adjust..adjust_labelrErtext)rur rr"rr.rZ after_idle)ryrGrrrZnewvalr'rr(r s    zLabeledScale._adjustcCs |jSr*)rr"rr'r'r(r.4szLabeledScale.valuecCs|j|dSr*)rr)ryr?r'r'r(r.9s)NNrr) rrrrzrr propertyr.setter __classcell__r'r'rr(rs &  cs8eZdZd ddZddZd ddZfdd ZZS) rNcOs||dd|ddd}tj||f|tj|dd|d<||_|dd|_|rptdtt | |j |f|dS) Nr} direction)Z textvariabler}rF)Ztearoffmenurzunknown option -%s) rr rzrxZMenur _callbackZTclErrorrr^keysset_menu)ryr&rrvalueskwargsrHr'r'r(rzCs  zOptionMenu.__init__cCs&|dkr|t||St||S)Nr)Z nametowidgetr __getitem__rr'r'r(r`szOptionMenu.__getitem__cGsR|d}|dd|D]$}|j|t|j||j|jdq|rN|j|dS)Nrrend)rrr)rZadd_radiobuttonrxZ_setitrrr)ryrrrr?r'r'r(rgs zOptionMenu.set_menucs,z|`Wntk rYnXtdSr*)rr rrrrr'r(rus zOptionMenu.destroy)N)N)rrrrzrrrrr'r'rr(r?s  )F)FN)F)F)rrD)N)5 __version__ __author____all__rxrrrrZ TkVersionrr)r0r8r@rBrKrNr[rcrgrmrqrurkrrobjectrrrrrrrrrrr r r r r rrrrrrZXViewZYViewrrrr'r'r'r(s     % 1*   *B*"8*(J`PK!x2$2$-__pycache__/simpledialog.cpython-38.opt-2.pycnu[U e5d-@sddlTddlmZmZGdddZGdddeZddZGd d d eZGd d d eZd dZ GdddeZ ddZ GdddeZ ddZ edkrddZedS))*) messagebox_get_default_rootc@sLeZdZdgddddfddZdddZd d Zd d Zd dZddZdS) SimpleDialogNc Cs|rt||d|_n t||_|r:|j||j|t|jt|j|dd|_|jjdtdt |j|_ |j ||_ ||_ ||_ |jd|jtt|D]L}||} t|j | ||fddd } ||kr| jtd d | jttdd q|jd |j||dS)N)class_i)textZaspect)expandfillcSs ||SN)doneselfnumr,/usr/lib64/python3.8/tkinter/simpledialog.py8z'SimpleDialog.__init__..rcommand)ZreliefZ borderwidth)sider r WM_DELETE_WINDOW)ToplevelroottitleZiconname _setup_dialogZMessagemessagepackZBOTHFrameframercanceldefaultbind return_eventrangelenButtonZconfigZRIDGELEFTprotocolwm_delete_window_set_transient) rmasterrbuttonsr$r#rrrsbrrr__init__ s2       zSimpleDialog.__init__?333333?c Cs|j}|||||rJ|}|}|}|}n| }| }d}}| } | } ||| |} ||| |} | | | kr| | } n | dkrd} | | | kr| | } n | dkrd} | d| | f|dS)Nr+%d+%d)rwithdraw transientupdate_idletasksZwinfo_ismappedZ winfo_widthZ winfo_height winfo_rootx winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheightgeometry deiconify) rr.ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_heightxyrrrr-?s4  zSimpleDialog._set_transientcCs.|j|j|j|j|jSr )rwait_visibilitygrab_setmainloopdestroyrrrrrgo\s     zSimpleDialog.gocCs&|jdkr|jn ||jdSr )r$rbellrrZeventrrrr&cs  zSimpleDialog.return_eventcCs&|jdkr|jn ||jdSr )r#rrErrCrrrr,is  zSimpleDialog.wm_delete_windowcCs||_|jdSr )rrquitrrrrroszSimpleDialog.done)r3r4) __name__ __module__ __qualname__r2r-rDr&r,rrrrrrs  rc@sReZdZdddZddZddZdd Zdd d Zdd d ZddZ ddZ dS)DialogNcCs|}|std}t||||dk r>|r>|||rL||t|||_d|_ t |}| ||_ |j ddd||j s||_ |d|j|dk r|d|d|df||j ||||dS)Nzcreate dialog window)padxpadyrr52)rrr2r6Zwinfo_viewabler7rrparentresultr!body initial_focusr buttonboxr+r#r;r9r:r< focus_setr?r@Z wait_window)rrPrr.rRrrrr2{s8       zDialog.__init__cCsd|_t|dSr )rSrrBrCrrrrBszDialog.destroycCsdSr r)rr.rrrrRsz Dialog.bodycCsvt|}t|dd|jtd}|jtdddt|dd|jd}|jtddd|d|j|d |j|dS) NZOK )rwidthrr$rL)rrMrNCancel)rrWrr z)r!r)okZACTIVEr r*r#r%)rZboxwrrrrTszDialog.buttonboxcCsB|s|jdS||z |W5|XdSr )validaterSrUr6r8r#applyrFrrrrYs  z Dialog.okcCs |jdk r|j|dSr )rPrUrBrFrrrr#s  z Dialog.cancelcCsdS)Nr rrCrrrr[szDialog.validatecCsdSr rrCrrrr\sz Dialog.apply)N)N)N) rHrIrJr2rBrRrTrYr#r[r\rrrrrKts 7    rKcCs:|jdkr |jdd|ddn|jdkr6|dddS) NZaquaz!::tk::unsupported::MacWindowStyleZstyleZ moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkZcallZ wm_attributes)rZrrrrs   rc@s.eZdZd ddZddZddZdd ZdS) _QueryDialogNcCs*||_||_||_||_t|||dSr )promptminvaluemaxvalue initialvaluerKr2)rrr^rar_r`rPrrrr2s z_QueryDialog.__init__cCsd|_t|dSr )entryrKrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdk rl|j d|j|j dt |jS)N)rZjustifyrrL)rowrMZstickyrb)namer ) ZLabelr^r*ZgridWZEntryrbErainsertZ select_rangeZEND)rr.rZrrrrR s z_QueryDialog.bodycCsz |}Wn,tk r8tjd|jd|dYdSX|jdk rh||jkrhtjdd|j|ddS|jdk r||jkrtjdd|j|ddS||_d S) Nz Illegal valuez Please try again)rPrz Too smallz2The allowed minimum value is %s. Please try again.z Too largez2The allowed maximum value is %s. Please try again.r ) getresult ValueErrorr showwarning errormessager_r`rQ)rrQrrrr[.s: z_QueryDialog.validate)NNNN)rHrIrJr2rBrRr[rrrrr] s r]c@seZdZdZddZdS) _QueryIntegerzNot an integer.cCs||jSr )ZgetintrbgetrCrrrrhSsz_QueryInteger.getresultNrHrIrJrkrhrrrrrlPsrlcKst||f|}|jSr )rlrQrr^kwdrrr askintegerWs rrc@seZdZdZddZdS) _QueryFloatzNot a floating point value.cCs||jSr )Z getdoublerbrmrCrrrrhisz_QueryFloat.getresultNrnrrrrrsfsrscKst||f|}|jSr )rsrQrorrraskfloatms rtc@s$eZdZddZddZddZdS) _QueryStringcOs6d|kr|d|_|d=nd|_tj|f||dS)Nshow)_QueryString__showr]r2)rargsrprrrr2}s  z_QueryString.__init__cCs(t||}|jdk r$|j|jd|S)N)rv)r]rRrwZ configure)rr.rbrrrrRs  z_QueryString.bodycCs |jSr )rbrmrCrrrrhsz_QueryString.getresultN)rHrIrJr2rRrhrrrrru|srucKst||f|}|jSr )rurQrorrr askstrings ry__main__cCsLt}|fdd}t|d|d}|t|d|jd}||dS)NcSs^t|ddddgdddd}t|ttd d d d ttd d dddttd ddS)NzThis is a test dialog. Would this have been an actual dialog, the buttons below would have been glowing in soft pink light. Do you believe this?ZYesZNorXrz Test Dialog)rr/r$r#rZSpamz Egg count)razEgg weight (in tons)r d)r_r`z Egg label)rprintrDrrrtry)rrqrrrdoits  ztest..doitZTestrZQuit)ZTkr)r rGrA)rrtqrrrtests rN)ZtkinterrrrrrKrr]rlrrrsrtruryrHrrrrrsV CPK!<,22#__pycache__/__main__.cpython-38.pycnu[U e5d@s<dZddlZejddr&dejd<ddlmZedS)zMain entry pointNz __main__.pyzpython -m tkinter)_test)__doc__sysargvendswithrmainr r (/usr/lib64/python3.8/tkinter/__main__.pys   PK!(1616$__pycache__/tix.cpython-38.opt-1.pycnu[U e5d-,@sLddlZddlZddlTddlmZddlZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZGdd d Z Gd!d"d"ej!e Z!Gd#d$d$Z"ej#j$e"fej#_$Gd%d&d&ej#Z%Gd'd(d(e%Z&Gd)d*d*Z'Gd+d,d,e%Z(Gd-d.d.e%Z)Gd/d0d0e%Z*Gd1d2d2e%Z+Gd3d4d4e%Z,Gd5d6d6e%Z-Gd7d8d8e%Z.Gd9d:d:e%Z/Gd;d<dd>e%Z1Gd?d@d@e%Z2GdAdBdBe%Z3GdCdDdDe%Z4GdEdFdFe%e5e6Z7GdGdHdHe%Z8GdIdJdJe%Z9GdKdLdLe%Z:GdMdNdNe%Z;GdOdPdPe%ZGdUdVdVe%Z?GdWdXdXe%Z@GdYdZdZe%ZAGd[d\d\e%ZBGd]d^d^e%ZCGd_d`d`e%ZDGdadbdbe%ZEGdcdddde%ZFGdedfdfe%ZGGdgdhdhe%ZHGdidjdje%ZIGdkdldle%ZJGdmdndne%ZKGdodpdpe%e5e6ZLGdqdrdre%ZMGdsdtdte%ZNGdudvdveOe&ZPGdwdxdxeQe&ZRGdydzdzeSe&ZTGd{d|d|eUe&ZVGd}d~d~eWe&ZXGdddeYe&ZZGddde[e&Z\Gddde]e&Z^Gddde_e&Z`Gdddeae&ZbGdddeDe&ZcGddde7e&ZdGdddeCe&ZeGdddeLe&ZfGddde*e&ZgGddde,e&ZhGddde.e&ZiGddde/e&ZjGddde2e&ZkGddde*e&ZlGdddeKe&ZmGddde>e&ZnGddde@e&ZoddZpddZqGddde%ZrGddde%e5e6ZsGdddesZtdS)N)*) _cnfmergewindowtextZstatusZ immediateimageZ imagetextZballoonautoZ acrosstopasciiZcellcolumnZ decreasingZ increasingZintegermainmaxrealrowzs-regionzx-regionzy-region c@sVeZdZdZddZddZdddZdd d Zd d Zd dZ ddZ dddZ dS) tixCommandaThe tix commands provide access to miscellaneous elements of Tix's internal state and the Tix application context. Most of the information manipulated by these commands pertains to the application as a whole, or to a screen or display, rather than to a particular window. This is a mixin class, assumed to be mixed to Tkinter.Tk that supports the self.tk.call method. cCs|jdd|S)aTix maintains a list of directories under which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap directory is $TIX_LIBRARY/bitmaps. The addbitmapdir command adds directory into this list. By using this command, the image files of an applications can also be located using the tix_getimage or tix_getbitmap command. tixZ addbitmapdirtkcall)selfZ directoryr#/usr/lib64/python3.8/tkinter/tix.pytix_addbitmapdirRs ztixCommand.tix_addbitmapdircCs|jdd|S)zReturns the current value of the configuration option given by option. Option may be any of the options described in the CONFIGURATION OPTIONS section. rcgetrroptionrrrtix_cget^sztixCommand.tix_cgetNcKsd|rt||f}n |rt|}|dkr2|ddSt|trN|ddd|S|jd||S)aQuery or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the configuration options. Nr configure-)rr )r _getconfigure isinstancestrZ_getconfigure1rr_optionsrcnfkwrrr tix_configurees   ztixCommand.tix_configurecCs*|dk r|jdd|S|jddSdS)aReturns the file selection dialog that may be shared among different calls from this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix_filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are tix FileSelectDialog or tixExFileSelectDialog. NrZ filedialogr)rZdlgclassrrrtix_filedialog{s ztixCommand.tix_filedialogcCs|jdd|S)aLocates a bitmap file of the name name.xpm or name in one of the bitmap directories (see the tix_addbitmapdir command above). By using tix_getbitmap, you can avoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets. rZ getbitmaprrnamerrr tix_getbitmaps ztixCommand.tix_getbitmapcCs|jdd|S)aLocates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directories (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix_ getimage, you can avoid hard coding the pathnames of the image files in your application. When successful, this command returns the name of the newly created image, which can be used to configure the -image option of the Tk and Tix widgets. rZgetimagerr+rrr tix_getimages ztixCommand.tix_getimagecCs|jddd|S)a@Gets the options maintained by the Tix scheme mechanism. Available options include: active_bg active_fg bg bold_font dark1_bg dark1_fg dark2_bg dark2_fg disabled_fg fg fixed_font font inactive_bg inactive_fg input1_bg input2_bg italic_font light1_bg light1_fg light2_bg light2_fg menu_font output1_bg output2_bg select_bg select_fg selector rrgetrr+rrrtix_option_getsztixCommand.tix_option_getcCs2|dk r|jdd|||S|jdd||SdS)aResets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetoptions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to reset the priority level of the Tk options set by the Tix schemes. Because of the way Tk handles the X option database, after Tix has been has imported and inited, it is not possible to reset the color schemes and font sets using the tix config command. Instead, the tix_resetoptions command must be used. NrZ resetoptionsr)rZ newSchemeZ newFontSetZ newScmPriorrrtix_resetoptionssztixCommand.tix_resetoptions)N)N)N) __name__ __module__ __qualname____doc__rrr)r*r-r.r0r1rrrrrGs     rc@s"eZdZdZdddZddZdS) Tkz{Toplevel widget of Tix which represents mostly the main window of an application. It has an associated Tcl interpreter.NTixcCsbtj||||tjd}|jd|dk rR|jd||jd||jddS)NZ TIX_LIBRARYzs z Tk.destroy)NNr7r2r3r4r5r9r>rrrrr6s r6c@sTeZdZdZifddZeZddZddZdd Zdd d Z dddZ ddZ d S)FormzThe Tix Form geometry manager Widgets can be arranged by specifying attachments to other widgets. See Tix documentation for complete detailscKs"|jjd|jf|||dS)NtixFormrr_wr%r&rrrconfigsz Form.configcCst|||idSN)rAformrkeyvaluerrr __setitem__szForm.__setitem__cCs|jdd|jS)NrBcheckrrrDr?rrrrLsz Form.checkcCs|jdd|jdS)NrBforgetrMr?rrrrNsz Form.forgetrcCs`|sJ|sJ|jdd|j}|j|}d}|D]}||j|f}q.|S|jdd|j||S)NrBgridr)rrrD splitlistZgetint)rZxsizeZysizexyzrrrrOs z Form.gridNcCs>|s|jdd|jS|ddkr*d|}|jdd|j|S)NrBinforr!rMrrrrrTs  z Form.infocs(fddjjddjDS)Ncsg|]}|qSr) _nametowidget.0rQr?rr szForm.slaves..rBslavesrrPrrDr?rr?rrYs z Form.slaves)rr)N) r2r3r4r5rErGrKrLrNrOrTrYrrrrrAs  rAc@sreZdZdZdddiifddZddZddZd d Zd d Zd dZ ddZ ddZ idfddZ ddZ dS) TixWidgetaQA TixWidget class is used to package all (or most) Tix widgets. Widget initialization is extended in two ways: 1) It is possible to give a list of options which must be part of the creation command (so called Tix 'static' options). These cannot be given as a 'config' command later. 2) It is possible to give the name of an existing TK widget. These are child widgets created automatically by a Tix mega-widget. The Tk call to create these widgets is therefore bypassed in TixWidget.__init__ Both options are for use by subclasses only. Nc Cs|rt||f}nt|}d}|r.|dndg}t|D]&\}}||kr@|d||f}||=q@||_t||||r|jj||j f||rt ||i|_ dS)Nroptionsr!) rappendlistitems widgetNameWidget_setuprrrDrEsubwidget_list) rmasterr`Zstatic_optionsr'r(Zextrakvrrrr9s$  zTixWidget.__init__cCs ||jkr|j|St|dSrF)rcAttributeErrorr+rrr __getattr__Gs  zTixWidget.__getattr__cCs|jd|j|dS)z1Set a variable without calling its action routineZ tixSetSilentNrM)rrJrrr set_silentLszTixWidget.set_silentcCsD||}|s$td|d|j|t|jdd}||S)zSReturn the named subwidget (which must have been created by the sub-class).z Subwidget z not child of N)_subwidget_nameTclError_namelenrDrU)rr,nrrr subwidgetPs  zTixWidget.subwidgetcCsZ|}|sgSg}|D]<}|t|jdd}z|||WqYqXq|S)zReturn all subwidgets.rjN)_subwidget_namesrnrDr]rU)rnamesZretlistr,rrrsubwidgets_allZszTixWidget.subwidgets_allcCs0z|j|jd|WStk r*YdSXdS)z7Get a subwidget name (returns a String, not a Widget !)rpN)rrrDrlr+rrrrkiszTixWidget._subwidget_namecCs<z |j|jdd}|j|WStk r6YdSXdS)z"Return the name of all subwidgets.Z subwidgetsz-allN)rrrDrPrl)rrQrrrrqps zTixWidget._subwidget_namescCs\|dkr dSt|tst|}t|ts0t|}|}|D]}|j|dd||q) r^childrenvaluesr>rmrdrcr~rrrDrcrrrr>s   zTixSubWidget.destroyN)rjrjr@rrrrr|s  r|c@sVeZdZdZifddddZddZdd Zd d Zd d ZifddZ ddZ dS) DisplayStylezRDisplayStyle - handle configuration options shared by (multiple) Display ItemsN)rdcKs\|s2d|kr|d}nd|kr(|d}n td}|j|_|jjd|f||||_dS)NZ refwindowzcreate display styleZtixDisplayStyle)r8Z_get_default_rootrrr% stylename)ritemtyper'rdr(rrrr9s     zDisplayStyle.__init__cCs|jSrF)rr?rrr__str__szDisplayStyle.__str__cCsH|r|rt||f}n|r|}d}|D]\}}|d||f}q*|S)Nrr!)rr_)rr'r(Zoptsrerfrrrr%szDisplayStyle._optionscCs|j|jddSNrzrrrr?rrrrzszDisplayStyle.deletecCs|j|jdd||dS)Nr -%srrHrrrrKszDisplayStyle.__setitem__cKs|j|jdf|||S)Nr )r"rr%r&rrrrEs  zDisplayStyle.configcCs|j|jdd|S)Nrrr)rrIrrr __getitem__szDisplayStyle.__getitem__) r2r3r4r5r9rr%rzrKrErrrrrrs   rc@s2eZdZdZdifddZifddZddZdS) BalloonzBalloon help widget. Subwidget Class --------- ----- label Label message MessageNcKsNdddddg}t||d|||t|ddd |jd<t|d dd |jd <dS) Nr\ZinstallcolormapZinitwaitZ statusbarZcursorZ tixBalloonlabelrr~messager[r9 _dummyLabelrcrrdr'r(Zstaticrrrr9 s zBalloon.__init__cKs&|jj|jd|jf|||dS)zkBind balloon widget to another. One balloon widget may be bound to several widgets at the same timebindNrC)rwidgetr'r(rrr bind_widgetszBalloon.bind_widgetcCs|j|jd|jdSNZunbindrMrrrrr unbind_widgetszBalloon.unbind_widget)r2r3r4r5r9rrrrrrrs rc@s2eZdZdZdifddZifddZddZdS) ButtonBoxzgButtonBox - A container for pushbuttons. Subwidgets are the buttons added with the add method. NcKst||dddg||dS)NZ tixButtonBox orientationr\r[r9rrdr'r(rrrr9s  zButtonBox.__init__cKs4|jj|jd|f|||}t|||j|<|S)z$Add a button with given name to box.addrrrDr% _dummyButtonrc)rr,r'r(Zbtnrrrr#s z ButtonBox.addcCs ||jkr|j|jd|dSNinvokercrrrDr+rrrr*s zButtonBox.invoker2r3r4r5r9rrrrrrrs rc@s>eZdZdZdifddZddZddZd d Zd d ZdS) ComboBoxaComboBox - an Entry field with a dropdown menu. The user can select a choice by either typing in the entry subwidget or selecting from the listbox subwidget. Subwidget Class --------- ----- entry Entry arrow Button slistbox ScrolledListBox tick Button cross Button : present if created with the fancy optionNc Kst||dddddg||t|d|jd<t|d|jd<t|d|jd<t|d |jd <z$t|d |jd <t|d |jd <Wntk rYnXdS) NZ tixComboBoxZeditableZdropdownfancyr\rentryarrowslistboxtickcross)r[r9rrc _dummyEntryr_dummyScrolledListBox TypeErrorrrrrr9<s    zComboBox.__init__cCs|j|jd|dS)NZ addhistoryrMrr$rrr add_historyNszComboBox.add_historycCs|j|jd|dS)NZ appendhistoryrMrrrrappend_historyQszComboBox.append_historycCs|j|jd||dSNinsertrM)rindexr$rrrrTszComboBox.insertcCs|j|jd|dS)NpickrMrrrrrrWsz ComboBox.pick) r2r3r4r5r9rrrrrrrrr.s  rc@s>eZdZdZdifddZddZddZd d Zd d ZdS) ControlaControl - An entry field with value change arrows. The user can adjust the value by pressing the two arrow buttons or by entering the value directly into the entry. The new value will be checked against the user-defined upper and lower limits. Subwidget Class --------- ----- incr Button decr Button entry Entry label LabelNcKsZt||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZ tixControlr\incrdecrrr)r[r9rrcrrrrrrr9hs zControl.__init__cCs|j|jddS)NrrMr?rrr decrementoszControl.decrementcCs|j|jddS)NrrMr?rrr incrementrszControl.incrementcCs|j|jddSrrMr?rrrruszControl.invokecCs|j|jddS)NupdaterMr?rrrrxszControl.update) r2r3r4r5r9rrrrrrrrrZs  rc@s$eZdZdZifddZddZdS)DirListaRDirList - displays a list view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb ScrollbarcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixDirListr\hlistvsbhsbr[r9 _dummyHListrc_dummyScrollbarrrrrr9szDirList.__init__cCs|j|jd|dSNchdirrMrdirrrrrsz DirList.chdirNr2r3r4r5r9rrrrrr{s rc@s$eZdZdZifddZddZdS)DirTreeaDirTree - Directory Listing in a hierarchical view. Displays a tree view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb ScrollbarcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixDirTreer\rrrrrrrrr9szDirTree.__init__cCs|j|jd|dSrrMrrrrrsz DirTree.chdirNrrrrrrs rc@seZdZdZifddZdS) DirSelectBoxaDirSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBoxcKs:t||ddg||t|d|jd<t|d|jd<dS)NZtixDirSelectBoxr\dirlistdircbx)r[r9 _dummyDirListrc_dummyFileComboBoxrrrrr9szDirSelectBox.__init__Nr2r3r4r5r9rrrrrs rc@s,eZdZdZifddZddZddZdS) ExFileSelectBoxaExFileSelectBox - MS Windows style file select box. It provides a convenient method for the user to select files. Subwidget Class --------- ----- cancel Button ok Button hidden Checkbutton types ComboBox dir ComboBox file ComboBox dirlist ScrolledListBox filelist ScrolledListBoxcKst||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d |jd <t|d |jd <dS) NZtixExFileSelectBoxr\cancelokhiddentypesrrfilefilelist)r[r9rrc_dummyCheckbutton_dummyComboBoxrrrrrrr9szExFileSelectBox.__init__cCs|j|jddSNfilterrMr?rrrrszExFileSelectBox.filtercCs|j|jddSrrMr?rrrrszExFileSelectBox.invokeN)r2r3r4r5r9rrrrrrrs rc@s,eZdZdZifddZddZddZdS) DirSelectDialoga#The DirSelectDialog widget presents the directories in the file system in a dialog window. The user can use this dialog window to navigate through the file system to select the desired directory. Subwidgets Class ---------- ----- dirbox DirSelectDialogcKs*t||ddg||t|d|jd<dS)NZtixDirSelectDialogr\Zdirbox)r[r9_dummyDirSelectBoxrcrrrrr9s  zDirSelectDialog.__init__cCs|j|jddSNpopuprMr?rrrrszDirSelectDialog.popupcCs|j|jddSNpopdownrMr?rrrrszDirSelectDialog.popdownNr2r3r4r5r9rrrrrrrs rc@s,eZdZdZifddZddZddZdS) ExFileSelectDialogzExFileSelectDialog - MS Windows style file select dialog. It provides a convenient method for the user to select files. Subwidgets Class ---------- ----- fsbox ExFileSelectBoxcKs*t||ddg||t|d|jd<dS)NZtixExFileSelectDialogr\fsbox)r[r9_dummyExFileSelectBoxrcrrrrr9s  zExFileSelectDialog.__init__cCs|j|jddSrrMr?rrrrszExFileSelectDialog.popupcCs|j|jddSrrMr?rrrrszExFileSelectDialog.popdownNrrrrrrs rc@s,eZdZdZifddZddZddZdS) FileSelectBoxaExFileSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBoxcKsZt||ddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZtixFileSelectBoxr\rrr selection)r[r9rrcrrrrrr9s zFileSelectBox.__init__cCs|j|jddSrrMr?rrr apply_filterszFileSelectBox.apply_filtercCs|j|jddSrrMr?rrrrszFileSelectBox.invokeN)r2r3r4r5r9rrrrrrrs rc@s,eZdZdZifddZddZddZdS) FileSelectDialogzFileSelectDialog - Motif style file select dialog. Subwidgets Class ---------- ----- btns StdButtonBox fsbox FileSelectBoxcKs:t||ddg||t|d|jd<t|d|jd<dS)NZtixFileSelectDialogr\Zbtnsr)r[r9_dummyStdButtonBoxrc_dummyFileSelectBoxrrrrr9,s zFileSelectDialog.__init__cCs|j|jddSrrMr?rrrr2szFileSelectDialog.popupcCs|j|jddSrrMr?rrrr5szFileSelectDialog.popdownNrrrrrr#s rc@s,eZdZdZifddZddZddZdS) FileEntrya_FileEntry - Entry field with button that invokes a FileSelectDialog. The user can type in the filename manually. Alternatively, the user can press the button widget that sits next to the entry, which will bring up a file selection dialog. Subwidgets Class ---------- ----- button Button entry EntrycKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixFileEntryZ dialogtyper\Zbuttonr)r[r9rrcrrrrrr9Ds zFileEntry.__init__cCs|j|jddSrrMr?rrrrJszFileEntry.invokecCsdSrFrr?rrr file_dialogMszFileEntry.file_dialogN)r2r3r4r5r9rrrrrrr8s rc@seZdZdZdifddZifddZdifddZd d Zd d ZdlddZ ddZ ddZ ddZ ddZ ddZddZddZddZifd d!Zifd"d#Zd$d%Zd&d'ZeZd(d)Zd*d+Zd,d-Zifd.d/Zifd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,ifdTdUZ-ifdVdWZ.dXdYZ/dZd[Z0d\d]Z1ifd^d_Z2d`daZ3dbdcZ4ifdddeZ5dfdgZ6dndhdiZ7djdkZ8dS)oHListaHList - Hierarchy display widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy. Subwidgets - NoneNcKst||dddg||dS)NZtixHListcolumnsr\rrrrrr9Ys  zHList.__init__cKs |jj|jd|f|||SNrrCrrr'r(rrrr]sz HList.addcKs(|sd}|jj|jd|f|||S)Nr=ZaddchildrC)rrr'r(rrr add_child`s zHList.add_childcCs|j|jdd|dSNanchorsetrMrrrrr anchor_setfszHList.anchor_setcCs|j|jdddSNrclearrMr?rrr anchor_cleariszHList.anchor_clearrcCs6|s|j|jdd||S|j|jdd|d|SdS)Nr widthz-charrM)rcolrcharsrrr column_widthls zHList.column_widthcCs|j|jdddS)NrzallrMr?rrr delete_allsszHList.delete_allcCs|j|jdd|dS)NrzrrMrrrr delete_entryvszHList.delete_entrycCs|j|jdd|dS)NrzZ offspringsrMrrrrdelete_offspringsyszHList.delete_offspringscCs|j|jdd|dS)NrzZsiblingsrMrrrrdelete_siblings|szHList.delete_siblingscCs|j|jdd|dSNdragsiterrMrrrr dragsite_setszHList.dragsite_setcCs|j|jdddSNr rrMr?rrrdragsite_clearszHList.dragsite_clearcCs|j|jdd|dSNdropsiterrMrrrr dropsite_setszHList.dropsite_setcCs|j|jdddSNrrrMr?rrrdropsite_clearszHList.dropsite_clearcKs&|jj|jdd|f|||dS)NheaderrvrCrrr'r(rrr header_createszHList.header_createcKs@|dkr||jdd|S|jj|jdd|f|||dS)Nrr r"rDrrr%rrrrheader_configures  zHList.header_configurecCs|j|jdd||S)NrrrM)rroptrrr header_cgetszHList.header_cgetcCs|j|j|jdd|S)NrZexist)rZ getbooleanrrDrrrrr header_existsszHList.header_existscCs|j|jdd|dS)NrrzrMrrrr header_deleteszHList.header_deletecCs|j|jdd|S)NrsizerMrrrr header_sizeszHList.header_sizecCs|j|jdd|dS)NhiderrMrrrr hide_entryszHList.hide_entrycKs&|jj|jdd|f|||dS)N indicatorrvrCrrrrindicator_creates zHList.indicator_createcKs@|dkr||jdd|S|jj|jdd|f|||dS)Nr#r rrrrrindicator_configures zHList.indicator_configurecCs|j|jdd||S)Nr#rrMrrrrrrindicator_cgetszHList.indicator_cgetcCs|j|jdd|S)Nr#existsrMrrrrindicator_existsszHList.indicator_existscCs|j|jdd|dS)Nr#rzrMrrrrindicator_deleteszHList.indicator_deletecCs|j|jdd|S)Nr#rrMrrrrindicator_sizeszHList.indicator_sizecCs|j|jddSNrTrrMr?rrr info_anchorszHList.info_anchorcCs||j|jdd|pdSNrTZbbox)_getintsrrrDrrrr info_bboxs zHList.info_bboxcCs |j|jdd|}|j|S)NrTrrrrDrP)rrrrrr info_childrenszHList.info_childrencCs|j|jdd|S)NrTdatarMrrrr info_dataszHList.info_datacCs|j|jddS)NrTr rMr?rrr info_dragsiteszHList.info_dragsitecCs|j|jddS)NrTrrMr?rrr info_dropsiteszHList.info_dropsitecCs|j|jdd|S)NrTr(rMrrrr info_existsszHList.info_existscCs|j|jdd|S)NrTrrMrrrr info_hiddenszHList.info_hiddencCs|j|jdd|S)NrTnextrMrrrr info_nextszHList.info_nextcCs|j|jdd|S)NrTrrMrrrr info_parentszHList.info_parentcCs|j|jdd|S)NrTprevrMrrrr info_prevszHList.info_prevcCs|j|jdd}|j|SNrTrr1rrrrinfo_selectionszHList.info_selectioncCs|j|jdd|||S)NitemrrM)rrrrrrr item_cgetszHList.item_cgetcKsD|dkr||jdd||S|jj|jdd||f|||dS)Nr@r rrrrr'r(rrritem_configures  zHList.item_configurecKs(|jj|jdd||f|||dS)Nr@rvrCrBrrr item_creates zHList.item_createcCs|j|jdd||S)Nr@r(rMrrrrrr item_existsszHList.item_existscCs|j|jdd||dS)Nr@rzrMrErrr item_deleteszHList.item_deletecCs|j|jd||S)N entrycgetrMr&rrrrHszHList.entrycgetcKs<|dkr||jd|S|jj|jd|f|||dSNentryconfigurerrrrrrJs  zHList.entryconfigurecCs|j|jd|SNnearestrM)rrRrrrrLsz HList.nearestcCs|j|jd|dSNseerMrrrrrNsz HList.seecKs$|jj|jddf|||dSNrrrCr&rrrselection_clearszHList.selection_clearcCs|j|jdd|SNrZincludesrMrrrrselection_includes szHList.selection_includescCs|j|jdd||dSNrrrMrfirstZlastrrr selection_set szHList.selection_setcCs|j|jdd|S)NshowrrMrrrr show_entryszHList.show_entry)rNN)N)N)9r2r3r4r5r9rrrrrrrr r r rrrrrrrZ header_existrr r"r$r%r'r)r*r+r-r0r2r4r5r6r7r8r:r;r=r?rArCrDrFrGrHrJrLrNrPrRrVrXrrrrrQsl            rc@seZdZdZdifddZdS) InputOnlyz?InputOnly - Invisible widget. Unix only. Subwidgets - NoneNcKst||dd||dS)NZ tixInputOnlyrrrrrr9szInputOnly.__init__rrrrrrYsrYc@seZdZdZdifddZdS) LabelEntryaLabelEntry - Entry field with label. Packages an entry widget and a label into one mega widget. It can be used to simplify the creation of ``entry-form'' type of interface. Subwidgets Class ---------- ----- label Label entry EntryNcKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixLabelEntry labelsider\rr)r[r9rrcrrrrrr9%s zLabelEntry.__init__rrrrrrZs rZc@seZdZdZdifddZdS) LabelFrameaeLabelFrame - Labelled Frame container. Packages a frame widget and a label into one mega widget. To create widgets inside a LabelFrame widget, one creates the new widgets relative to the frame subwidget and manage them inside the frame subwidget. Subwidgets Class ---------- ----- label Label frame FrameNcKs<t||dddg||t|d|jd<t|d|jd<dS)NZ tixLabelFramer[r\rframe)r[r9rrc _dummyFramerrrrr96s zLabelFrame.__init__rrrrrr\+s r\c@s@eZdZdZifddZifddZddZdd Zd d Zd S) ListNoteBookaA ListNoteBook widget is very similar to the TixNoteBook widget: it can be used to display many windows in a limited space using a notebook metaphor. The notebook is divided into a stack of pages (windows). At one time only one of these pages can be shown. The user can navigate through these pages by choosing the name of the desired page in the hlist subwidget.cKsNt||ddg||t|ddd|jd<t|d|jd<t|d|jd<dS)NZtixListNoteBookr\ZpanerrrZshlist)r[r9_dummyPanedWindowrcr_dummyScrolledHListrrrrr9Es  zListNoteBook.__init__cKs:|jj|jd|f|||t|||j|<|j|SrrrrDr%r|rcrr,r'r(rrrrMs zListNoteBook.addcCs ||SrFrpr+rrrpageRszListNoteBook.pagecCs:|j|j|jd}g}|D]}|||q |SNpagesrrPrrDr]rprrrZretrQrrrrgUs zListNoteBook.pagescCs|j|jd|dSNraiserMr+rrr raise_page]szListNoteBook.raise_pageN) r2r3r4r5r9rrergrlrrrrr_=s   r_c@seZdZdZdifddZdS)MeterzuThe Meter widget can be used to show the progress of a background job which may take a long time to execute. NcKst||ddg||dS)NZtixMeterr\rrrrrr9es  zMeter.__init__rrrrrrm`srmc@sReZdZdZdifddZifddZddZd d Zd d Zd dZ ddZ dS)NoteBookzNoteBook - Multi-page container widget (tabbed notebook metaphor). Subwidgets Class ---------- ----- nbframe NoteBookFrame page widgets added dynamically with the add methodNcKs.t||ddg||t|ddd|jd<dS)NZ tixNoteBookr\Znbframerr)r[r9r|rcrrrrr9qszNoteBook.__init__cKs:|jj|jd|f|||t|||j|<|j|Srrbrcrrrrvs z NoteBook.addcCs,|j|jd||j||j|=dSrrrrDrcr>r+rrrrz{szNoteBook.deletecCs ||SrFrdr+rrrresz NoteBook.pagecCs:|j|j|jd}g}|D]}|||q |Srfrhrirrrrgs zNoteBook.pagescCs|j|jd|dSrjrMr+rrrrlszNoteBook.raise_pagecCs|j|jdS)NraisedrMr?rrrrpszNoteBook.raised) r2r3r4r5r9rrzrergrlrprrrrrnis rnc@s eZdZdS) NoteBookFrameN)r2r3r4rrrrrqsrqc@sLeZdZdZifddZifddZifddZdd Zd d Zd d Z dS) OptionMenuzOptionMenu - creates a menu button of options. Subwidget Class --------- ----- menubutton Menubutton menu MenucKs:t||ddg||t|d|jd<t|d|jd<dS)NZ tixOptionMenur\ menubuttonmenur[r9_dummyMenubuttonrc _dummyMenurrrrr9szOptionMenu.__init__cKs&|jj|jdd|f|||dS)NrcommandrCrcrrr add_commandszOptionMenu.add_commandcKs&|jj|jdd|f|||dS)NrZ separatorrCrcrrr add_separatorszOptionMenu.add_separatorcCs|j|jd|dSrrMr+rrrrzszOptionMenu.deletecCs|j|jd|dS)NdisablerMr+rrrr{szOptionMenu.disablecCs|j|jd|dS)NenablerMr+rrrr|szOptionMenu.enableN) r2r3r4r5r9ryrzrzr{r|rrrrrrs   rrc@sTeZdZdZifddZifddZddZdd Zd d Zifd d Z ddZ dS) PanedWindowaPanedWindow - Multi-pane container widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.The user changes the sizes of the panes by dragging the resize handle between two panes. Subwidgets Class ---------- ----- g/p widgets added dynamically with the add method.cKst||dddg||dS)NZtixPanedWindowrr\rrrrrr9szPanedWindow.__init__cKs>|jj|jd|f|||t||dd|j|<|j|S)Nrr)rrbrcrrrrs   zPanedWindow.addcCs,|j|jd||j||j|=dSrror+rrrrzszPanedWindow.deletecCs|j|jd|dS)NrNrMr+rrrrNszPanedWindow.forgetcCs|j|jd||S)NpanecgetrMr&rrrr~szPanedWindow.panecgetcKs<|dkr||jd|S|jj|jd|f|||dS)N paneconfigurerrrrrrszPanedWindow.paneconfigurecs*jjjd}fdd|DS)Npanescsg|]}|qSrrdrVr?rrrXsz%PanedWindow.panes..rZ)rrrrr?rrszPanedWindow.panesN) r2r3r4r5r9rrzrNr~rrrrrrr}s   r}c@s4eZdZdZifddZddZddZdd Zd S) PopupMenuaPopupMenu widget can be used as a replacement of the tk_popup command. The advantage of the Tix PopupMenu widget is it requires less application code to manipulate. Subwidgets Class ---------- ----- menubutton Menubutton menu MenucKs:t||ddg||t|d|jd<t|d|jd<dS)NZ tixPopupMenur\rsrtrurrrrr9szPopupMenu.__init__cCs|j|jd|jdS)NrrMrrrrrszPopupMenu.bind_widgetcCs|j|jd|jdSrrMrrrrrszPopupMenu.unbind_widgetcCs|j|jd|j||dS)NZpostrM)rrrQrRrrr post_widgetszPopupMenu.post_widgetN)r2r3r4r5r9rrrrrrrrs  rc@s<eZdZdZifddZddZddZdd Zd d Zd S) ResizeHandlez;Internal widget to draw resize handles on Scrolled widgets.c Ks.ddddddddd g }t||d |||dS) Nr\rxZcursorfgZcursorbgZ handlesizeZ hintcolorZ hintwidthrQrRZtixResizeHandler)rrdr'r(flagsrrrr9s zResizeHandle.__init__cCs|j|jd|jdS)NZ attachwidgetrMrrrr attach_widgetszResizeHandle.attach_widgetcCs|j|jd|jdS)NZ detachwidgetrMrrrr detach_widgetszResizeHandle.detach_widgetcCs|j|jd|jdS)Nr!rMrrrrr!szResizeHandle.hidecCs|j|jd|jdS)NrWrMrrrrrW szResizeHandle.showN) r2r3r4r5r9rrr!rWrrrrrs  rc@seZdZdZifddZdS) ScrolledHListz0ScrolledHList - HList with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledHListr\rrrrrrrrr9szScrolledHList.__init__Nrrrrrr src@seZdZdZifddZdS)ScrolledListBoxz4ScrolledListBox - Listbox with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledListBoxr\listboxrr)r[r9 _dummyListboxrcrrrrrr9szScrolledListBox.__init__Nrrrrrrsrc@seZdZdZifddZdS) ScrolledTextz.ScrolledText - Text with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledTextr\rrr)r[r9 _dummyTextrcrrrrrr9%szScrolledText.__init__Nrrrrrr!src@seZdZdZifddZdS) ScrolledTListz0ScrolledTList - TList with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledTListr\Ztlistrr)r[r9 _dummyTListrcrrrrrr9/szScrolledTList.__init__Nrrrrrr+src@seZdZdZifddZdS)ScrolledWindowz2ScrolledWindow - Window with automatic scrollbars.cKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixScrolledWindowr\rrr)r[r9r^rcrrrrrr9:szScrolledWindow.__init__Nrrrrrr6src@s0eZdZdZifddZifddZddZdS) SelectzSelect - Container of button subwidgets. It can be used to provide radio-box or check-box style of selection options for the user. Subwidgets are buttons added dynamically using the add method.c Ks2t||ddddddg||t|d|jd<dS)NZ tixSelectZ allowzeroradiorr[r\rrrrrrr9Gs zSelect.__init__cKs:|jj|jd|f|||t|||j|<|j|SrrrcrrrrNs z Select.addcCs|j|jd|dSrrMr+rrrrSsz Select.invokeNrrrrrr@s  rc@seZdZdZdifddZdS)Shellz'Toplevel window. Subwidgets - NoneNcKst||dddg||dS)NZtixShellr\titlerrrrrr9[szShell.__init__rrrrrrVsrc@s6eZdZdZdifddZddZddZd d ZdS) DialogShellzToplevel window, with popup popdown and center methods. It tells the window manager that it is a dialog window and should be treated specially. The exact treatment depends on the treatment of the window manager. Subwidgets - NoneNc Ks&t||ddddddddg||dS) NZtixDialogShellr\rZmappedZ minheightZminwidthrZ transientrrrrrr9gszDialogShell.__init__cCs|j|jddSrrMr?rrrrnszDialogShell.popdowncCs|j|jddSrrMr?rrrrqszDialogShell.popupcCs|j|jddS)NcenterrMr?rrrrtszDialogShell.center)r2r3r4r5r9rrrrrrrr^s rc@s&eZdZdZdifddZddZdS) StdButtonBoxz@StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) NcKs\t||dddg||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)NZtixStdButtonBoxrr\rapplyrhelp)r[r9rrcrrrrr9zs zStdButtonBox.__init__cCs ||jkr|j|jd|dSrrr+rrrrs zStdButtonBox.invoke)r2r3r4r5r9rrrrrrwsrc@seZdZdZdifddZddZddZd d Zd d Zd3d dZ ddZ ddZ ddZ ddZ ifddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zifd-d.Zd/d0Zd4d1d2ZdS)5TListaTList - Hierarchy display widget which can be used to display data in a tabular format. The list entries of a TList widget are similar to the entries in the Tk listbox widget. The main differences are (1) the TList widget can display the list entries in a two dimensional format and (2) you can use graphical images as well as multiple colors and fonts for the list entries. Subwidgets - NoneNcKst||ddg||dS)NZtixTListr\rrrrrr9szTList.__init__cCs|j|jdd|dS)NactiverrMrrrr active_setszTList.active_setcCs|j|jdddS)NrrrMr?rrr active_clearszTList.active_clearcCs|j|jdd|dSrrMrrrrrszTList.anchor_setcCs|j|jdddSrrMr?rrrrszTList.anchor_clearcCs|j|jd||dSrrMrfrom_torrrrzsz TList.deletecCs|j|jdd|dSr rMrrrrr szTList.dragsite_setcCs|j|jdddSrrMr?rrrrszTList.dragsite_clearcCs|j|jdd|dSrrMrrrrrszTList.dropsite_setcCs|j|jdddSrrMr?rrrrszTList.dropsite_clearcKs$|jj|jd|f|||dSrrC)rrr'r(rrrrsz TList.insertcCs|j|jddS)NrTrrMr?rrr info_activeszTList.info_activecCs|j|jddSr,rMr?rrrr-szTList.info_anchorcCs|j|jdd|S)NrTZdownrMrrrr info_downszTList.info_downcCs|j|jdd|S)NrTleftrMrrrr info_leftszTList.info_leftcCs|j|jdd|S)NrTrightrMrrrr info_rightszTList.info_rightcCs|j|jdd}|j|Sr>r1rrrrr?szTList.info_selectioncCs|j|jddS)NrTrrMr?rrr info_sizeszTList.info_sizecCs|j|jdd|S)NrTZuprMrrrrinfo_upsz TList.info_upcCs|j|jd||SrKrMrrQrRrrrrLsz TList.nearestcCs|j|jd|dSrMrMrrrrrNsz TList.seecKs$|jj|jddf|||dSrOrCr&rrrrPszTList.selection_clearcCs|j|jdd|SrQrMrrrrrRszTList.selection_includescCs|j|jdd||dSrSrMrTrrrrVszTList.selection_set)N)N)r2r3r4r5r9rrrrrzr rrrrrr-rrrr?rrrLrNrPrRrVrrrrrs2    rc@sHeZdZdZdifddZddZddZd d Zd d ZdddZ dS)TreezTree - The tixTree widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree.NcKsJt||ddg||t|d|jd<t|d|jd<t|d|jd<dS)NZtixTreer\rrrrrrrrr9s z Tree.__init__cCs|j|jddSa This command calls the setmode method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to none. Otherwise, if the entry has any hidden child entries, its mode is set to open; otherwise its mode is set to close. autosetmodeNrMr?rrrrszTree.autosetmodecCs|j|jd|dSz8Close the entry given by entryPath if its mode is close.closeNrMr entrypathrrrrsz Tree.closecCs|j|jd|Sz9Returns the current mode of the entry given by entryPath.getmoderMrrrrrsz Tree.getmodecCs|j|jd|dSz6Open the entry given by entryPath if its mode is open.openNrMrrrrrsz Tree.opennonecCs|j|jd||dS)aThis command is used to indicate whether the entry given by entryPath has children entries and whether the children are visible. mode must be one of open, close or none. If mode is set to open, a (+) indicator is drawn next the entry. If mode is set to close, a (-) indicator is drawn next the entry. If mode is set to none, no indicators will be drawn for this entry. The default mode is none. The open mode indicates the entry has hidden children and this entry can be opened by the user. The close mode indicates that all the children of the entry are now visible and the entry can be closed by the user.setmodeNrMrrmoderrrrs z Tree.setmode)r) r2r3r4r5r9rrrrrrrrrrsrc@sZeZdZdZdifddZddZddZd d Zd d ZdddZ ddZ dddZ dS) CheckListzThe CheckList widget displays a list of items to be selected by the user. CheckList acts similarly to the Tk checkbutton or radiobutton widgets, except it is capable of handling many more items than checkbuttons or radiobuttons. NcKsLt||dddg||t|d|jd<t|d|jd<t|d|jd<dS)NZ tixCheckListr\rrrrrrrrrr9s zCheckList.__init__cCs|j|jddSrrMr?rrrrszCheckList.autosetmodecCs|j|jd|dSrrMrrrrrszCheckList.closecCs|j|jd|SrrMrrrrr szCheckList.getmodecCs|j|jd|dSrrMrrrrr$szCheckList.openoncCs|j|j|jd|S)zReturns a list of items whose status matches status. If status is not specified, the list of items in the "on" status will be returned. Mode can be on, off, default getselectionrZ)rrrrrr(szCheckList.getselectioncCs|j|jd|S)z(Returns the current status of entryPath. getstatusrMrrrrr.szCheckList.getstatuscCs|j|jd||dS)z~Sets the status of entryPath to be status. A bitmap will be displayed next to the entry its status is on, off or default. setstatusNrMrrrrr2szCheckList.setstatus)r)r) r2r3r4r5r9rrrrrrrrrrrrs rc@seZdZdddZdS)rrjcCst||||dSrFr|r9rrdr,r~rrrr9>sz_dummyButton.__init__N)rjr2r3r4r9rrrrr=src@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Bsz_dummyCheckbutton.__init__N)rjrrrrrrAsrc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Fsz_dummyEntry.__init__N)rjrrrrrrEsrc@seZdZdddZdS)r^rjcCst||||dSrFrrrrrr9Jsz_dummyFrame.__init__N)rjrrrrrr^Isr^c@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Nsz_dummyLabel.__init__N)rjrrrrrrMsrc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9Rsz_dummyListbox.__init__N)rjrrrrrrQsrc@seZdZdddZdS)rwrjcCst||||dSrFrrrrrr9Vsz_dummyMenu.__init__N)rjrrrrrrwUsrwc@seZdZdddZdS)rvrjcCst||||dSrFrrrrrr9Zsz_dummyMenubutton.__init__N)rjrrrrrrvYsrvc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9^sz_dummyScrollbar.__init__N)rjrrrrrr]src@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9bsz_dummyText.__init__N)rjrrrrrrasrc@seZdZdddZdS)rrjcCsDt||||t|d|jd<t|d|jd<t|d|jd<dS)Nrrr)r|r9rrcrrrrrr9fsz_dummyScrolledListBox.__init__N)rjrrrrrresrc@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9msz_dummyHList.__init__N)rjrrrrrrlsrc@seZdZdddZdS)rarjcCsDt||||t|d|jd<t|d|jd<t|d|jd<dSNrrrr|r9rrcrrrrrr9qsz_dummyScrolledHList.__init__N)rjrrrrrrapsrac@seZdZdddZdS)rrjcCst||||dSrFrrrrrr9xsz_dummyTList.__init__N)rjrrrrrrwsrc@seZdZdddZdS)rrjcCst|||d|gt|d|jd<t|d|jd<t|d|jd<t|d|jd<z$t|d|jd<t|d|jd<Wntk rYnXdS)Nrrrrrrr)r|r9rrcrrrrrrrrr9|s z_dummyComboBox.__init__N)rjrrrrrr{src@seZdZdddZdS)rrjcCsDt||||t|d|jd<t|d|jd<t|d|jd<dSrrrrrrr9sz_dummyDirList.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCs4t||||t|d|jd<t|d|jd<dS)Nrr)r|r9rrcrrrrrr9sz_dummyDirSelectBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCst||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS) Nrrrrrrrr)r|r9rrcrrrrrrrr9sz_dummyExFileSelectBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCsTt||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)Nrrrr)r|r9rrcrrrrrr9s z_dummyFileSelectBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCs$t||||t|d|jd<dS)Nr)r|r9rrcrrrrr9sz_dummyFileComboBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)rrjcCsTt||||t|d|jd<t|d|jd<t|d|jd<t|d|jd<dS)Nrrrr)r|r9rrcrrrrr9s z_dummyStdButtonBox.__init__N)rjrrrrrrsrc@seZdZdddZdS)_dummyNoteBookFramercCst||||dSrFrrrrrr9sz_dummyNoteBookFrame.__init__N)rrrrrrrsrc@seZdZdddZdS)r`rjcCst||||dSrFrrrrrr9sz_dummyPanedWindow.__init__N)rjrrrrrr`sr`cCs|jd|jS)zzReturns the qualified path name for the widget. Normally used to set default options for subwidgets. See tixwidgets.pyZ tixOptionNamerM)rrrr OptionNamesrcCs:d}|D](}|d|d|d||d}q |S)Nr=z{{z} {z - z}} )keys)dictstyperrr FileTypeLists &rc@seZdZdZdS)CObjViewaBThis file implements the Canvas Object View widget. This is a base class of IconView. It implements automatic placement/adjustment of the scrollbars according to the canvas objects inside the canvas subwidget. The scrollbars are adjusted so that the canvas is just large enough to see all the objects. N)r2r3r4r5rrrrrsrc@seZdZdZdifddZddZddZd d Zd)d d Zd*d dZ ddZ ddZ ddZ d+ddZ ddZddZddZddZdd Zd,d!d"Zd#d$Zd%d&Zd'd(ZdS)-Grida}The Tix Grid command creates a new window and makes it into a tixGrid widget. Additional options, may be specified on the command line or in the option database to configure aspects such as its cursor and relief. A Grid widget displays its contents in a two dimensional grid of cells. Each cell may contain one Tix display item, which may be in text, graphics or other formats. See the DisplayStyle class for more information about Tix display items. Individual cells, or groups of cells, can be formatted with a wide range of attributes, such as its color, relief and border. Subwidgets - NoneNcKs"g}||_t||d|||dS)NZtixGridr'r[r9rrrrr9sz Grid.__init__cCs|j|dddS)zRemoves the selection anchor.rrNrr?rrrrszGrid.anchor_clearcCs||j|ddS)z3Get the (x,y) coordinate of the current anchor cellrr/r/rrr?rrr anchor_getszGrid.anchor_getcCs|j|dd||dS)z/Set the selection anchor to the cell at (x, y).rrNrrrrrrszGrid.anchor_setcCs4|dkr|j|dd|n|j|dd||dS)zdDelete rows between from_ and to inclusive. If to is not provided, delete only row at from_Nrzr rrrrr delete_row szGrid.delete_rowcCs4|dkr|j|dd|n|j|dd||dS)zjDelete columns between from_ and to inclusive. If to is not provided, delete only column at from_Nrzr rrrrr delete_columnszGrid.delete_columncCs|j|dddS)zUIf any cell is being edited, de-highlight the cell and applies the changes.editrNrr?rrr edit_applyszGrid.edit_applycCs|j|dd||dS)zmHighlights the cell at (x, y) for editing, if the -editnotify command returns True for this cell.rrNrrrrredit_set!sz Grid.edit_setcCs,|r|ddkrd|}|j|d|||S)z&Get the option value for cell at (x,y)rr!rHr)rrQrRrrrrrH&szGrid.entrycgetcKs|d||f||SrI)Z _configure)rrQrRr'r(rrrrJ,szGrid.entryconfigurec Cs||j|dd||S)z+Return True if display item exists at (x,y)rTr()Z _getbooleanrrrrrrr72szGrid.info_existscCs|j|dd||Sr.rrrrrr06szGrid.info_bboxcCs|j|dd|||dS)zMoves the range of columns from position FROM through TO by the distance indicated by OFFSET. For example, move_column(2, 4, 1) moves the columns 2,3,4 to columns 3,4,5.mover Nrrrroffsetrrr move_column:szGrid.move_columncCs|j|dd|||dS)zMoves the range of rows from position FROM through TO by the distance indicated by OFFSET. For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.rr Nrrrrrmove_row@sz Grid.move_rowcCs||j|d||S)z8Return coordinate of cell nearest pixel coordinate (x,y)rLrrrrrrLFsz Grid.nearestcKs>||j|}|dk r"d|f|}|jj|d||f|dS)Nz -itemtyper)r%r'rr)rrQrRrr(argsrrrrPs zGrid.setcKs*|j|jj|jdd|f|i|S)aQueries or sets the size of the column given by INDEX. INDEX may be any non-negative integer that gives the position of a given column. INDEX can also be the string "default"; in this case, this command queries or sets the default size of all columns. When no option-value pair is given, this command returns a tuple containing the current size setting of the given column. When option-value pairs are given, the corresponding options of the size setting of the given column are changed. Options may be one of the following: pad0 pixels Specifies the paddings to the left of a column. pad1 pixels Specifies the paddings to the right of a column. size val Specifies the width of a column. Val may be: "auto" -- the width of the column is set to the width of the widest cell in the column; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the width of the column to the given number of characters.rr )rrPrrDr%rrr(rrr size_columnVs zGrid.size_columncKs(|j|jj|dd|f|i|S)aQueries or sets the size of the row given by INDEX. INDEX may be any non-negative integer that gives the position of a given row . INDEX can also be the string "default"; in this case, this command queries or sets the default size of all rows. When no option-value pair is given, this command returns a list con- taining the current size setting of the given row . When option-value pairs are given, the corresponding options of the size setting of the given row are changed. Options may be one of the following: pad0 pixels Specifies the paddings to the top of a row. pad1 pixels Specifies the paddings to the bottom of a row. size val Specifies the height of a row. Val may be: "auto" -- the height of the row is set to the height of the highest cell in the row; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the height of the row to the given number of characters.rr )rrPrr%rrrrsize_rowps  z Grid.size_rowcCs|j|jd||dS)z7Clears the cell at (x, y) by removing its display item.unsetNrMrrrrrsz Grid.unset)N)N)N)N)r2r3r4r5r9rrrrrrrrHrJr7r0rrrLrrrrrrrrrs(     rc@seZdZdZdifddZdS) ScrolledGridzScrolled Grid widgetsNcKs"g}||_t||d|||dS)NZtixScrolledGridrrrrrr9szScrolledGrid.__init__rrrrrrsr)ur:r8rZ_tkinterZWINDOWZTEXTZSTATUSZ IMMEDIATEZIMAGEZ IMAGETEXTZBALLOONZAUTOZ ACROSSTOPASCIIZCELLZCOLUMNZ DECREASINGZ INCREASINGZINTEGERZMAINMAXZREALZROWZS_REGIONZX_REGIONZY_REGIONZ TCL_DONT_WAITZTCL_WINDOW_EVENTSZTCL_FILE_EVENTSZTCL_TIMER_EVENTSZTCL_IDLE_EVENTSZTCL_ALL_EVENTSrr6rAra __bases__r[r|rrrrrrrrrrrrrrZXViewZYViewrrYrZr\r_rmrnrqrrr}rrrrrrrrrrrrrrZButtonrZ CheckbuttonrZEntryrZFramer^ZLabelrZListboxrZMenurwZ MenubuttonrvZ ScrollbarrZTextrrrrarrrrrrrrrr`rrrrrrrrrs - 8/,!"C# ()     S.6    *PK!z`,,__pycache__/dnd.cpython-38.pycnu[U e5d,@sXdZddlZddZGdddZGdddZGd d d Zd d Zed krTedS)aFDrag-and-drop support for Tkinter. This is very preliminary. I currently only support dnd *within* one application, between different windows (or within the same window). I am trying to make this as generic as possible -- not dependent on the use of a particular widget or icon type, etc. I also hope that this will work with Pmw. To enable an object to be dragged, you must create an event binding for it that starts the drag-and-drop process. Typically, you should bind to a callback function that you write. The function should call Tkdnd.dnd_start(source, event), where 'source' is the object to be dragged, and 'event' is the event that invoked the call (the argument to your callback function). Even though this is a class instantiation, the returned instance should not be stored -- it will be kept alive automatically for the duration of the drag-and-drop. When a drag-and-drop is already in process for the Tk interpreter, the call is *ignored*; this normally averts starting multiple simultaneous dnd processes, e.g. because different button callbacks all dnd_start(). The object is *not* necessarily a widget -- it can be any application-specific object that is meaningful to potential drag-and-drop targets. Potential drag-and-drop targets are discovered as follows. Whenever the mouse moves, and at the start and end of a drag-and-drop move, the Tk widget directly under the mouse is inspected. This is the target widget (not to be confused with the target object, yet to be determined). If there is no target widget, there is no dnd target object. If there is a target widget, and it has an attribute dnd_accept, this should be a function (or any callable object). The function is called as dnd_accept(source, event), where 'source' is the object being dragged (the object passed to dnd_start() above), and 'event' is the most recent event object (generally a event; it can also be or ). If the dnd_accept() function returns something other than None, this is the new dnd target object. If dnd_accept() returns None, or if the target widget has no dnd_accept attribute, the target widget's parent is considered as the target widget, and the search for a target object is repeated from there. If necessary, the search is repeated all the way up to the root widget. If none of the target widgets can produce a target object, there is no target object (the target object is None). The target object thus produced, if any, is called the new target object. It is compared with the old target object (or None, if there was no old target widget). There are several cases ('source' is the source object, and 'event' is the most recent event object): - Both the old and new target objects are None. Nothing happens. - The old and new target objects are the same object. Its method dnd_motion(source, event) is called. - The old target object was None, and the new target object is not None. The new target object's method dnd_enter(source, event) is called. - The new target object is None, and the old target object is not None. The old target object's method dnd_leave(source, event) is called. - The old and new target objects differ and neither is None. The old target object's method dnd_leave(source, event), and then the new target object's method dnd_enter(source, event) is called. Once this is done, the new target object replaces the old one, and the Tk mainloop proceeds. The return value of the methods mentioned above is ignored; if they raise an exception, the normal exception handling mechanisms take over. The drag-and-drop processes can end in two ways: a final target object is selected, or no final target object is selected. When a final target object is selected, it will always have been notified of the potential drop by a call to its dnd_enter() method, as described above, and possibly one or more calls to its dnd_motion() method; its dnd_leave() method has not been called since the last call to dnd_enter(). The target is notified of the drop by a call to its method dnd_commit(source, event). If no final target object is selected, and there was an old target object, its dnd_leave(source, event) method is called to complete the dnd sequence. Finally, the source object is notified that the drag-and-drop process is over, by a call to source.dnd_end(target, event), specifying either the selected target object, or None if no target object was selected. The source object can use this to implement the commit action; this is sometimes simpler than to do it in the target's dnd_commit(). The target's dnd_commit() method could then simply be aliased to dnd_leave(). At any time during a dnd sequence, the application can cancel the sequence by calling the cancel() method on the object returned by dnd_start(). This will call dnd_leave() if a target is currently active; it will never call dnd_commit(). NcCst||}|jr|SdSdSN) DndHandlerroot)sourceeventhr#/usr/lib64/python3.8/tkinter/dnd.py dnd_startls r c@sDeZdZdZddZddZddZdd Zdd d Zdd dZ dS)rNcCs|jdkrdS|j}z |jWdStk rD||_||_YnX||_d|_|j|_}|j|_ }d||f|_ |dpd|_ | |j |j | d|jd|d<dS)NzcursorZhand2)ZnumwidgetZ_root_DndHandler__dndAttributeErrorrrtargetZinitial_buttoninitial_widgetrelease_pattern save_cursorbind on_release on_motion)selfrrrZbuttonrrrr __init__zs$     zDndHandler.__init__cCs2|j}d|_|r.z|`Wntk r,YnXdSr)rrrrrrrr __del__szDndHandler.__del__c Cs|j|j}}|j||}|j}d}|rbz |j}Wntk rHYnX|||}|rZqb|j}q&|j}||kr|r| ||n,|rd|_| |||r| ||||_dSr) x_rooty_rootrZwinfo_containingr dnd_acceptrZmasterr dnd_motion dnd_leave dnd_enter) rrxyZ target_widgetr new_targetattrZ old_targetrrr rs.    zDndHandler.on_motioncCs||ddS)Nfinishrrrrr rszDndHandler.on_releasecCs||ddS)Nrr(r*rrr cancelszDndHandler.cancelrc Cs|j}|j}|j}|j}zf|`|j|j|jd|j|d<d|_|_|_|_|r||rp| ||n | ||W5|||XdS)Nrr ) rrrrdnd_endrZunbindrr dnd_commitr!)rrZcommitrrrrrrr r)s  zDndHandler.finish)N)r) __name__ __module__ __qualname__rrrrrr+r)rrrr rvs  rc@sNeZdZddZdddZddZdd Zd d Zd d ZddZ ddZ dS)IconcCs||_d|_|_|_dSr)namecanvaslabelid)rr2rrr rsz Icon.__init__ cCs||jkr |j|j||dS|jr.||s6dStj||jddd}|j|||dd}||_||_||_| d|j dS)NZraised)textZ borderwidthZreliefZnw)ZwindowZanchorz ) r3coordsr5detachtkinterZLabelr2Z create_windowr4rpress)rr3r#r$r4r5rrr attachs   z Icon.attachcCsB|j}|sdS|j}|j}d|_|_|_|||dSr)r3r5r4deleteZdestroy)rr3r5r4rrr r:s z Icon.detachcCs4t||r0|j|_|j|_|j|j\|_|_ dSr) r r#x_offr$y_offr3r9r5x_origy_origr*rrr r<s z Icon.presscCs(||j|\}}|j|j||dSr)wherer3r9r5)rrr#r$rrr movesz Icon.movecCs|j|j|j|jdSr)r3r9r5rArB)rrrr putbacksz Icon.putbackcCs8|}|}|j|}|j|}||j||jfSr)Z winfo_rootxZ winfo_rootyrrr?r@)rr3rZx_orgZy_orgr#r$rrr rCs   z Icon.wherecCsdSrr)rrrrrr r,sz Icon.dnd_endN)r6r6) r.r/r0rr=r:r<rDrErCr,rrrr r1s   r1c@s<eZdZddZddZddZddZd d Zd d Zd S)TestercCs>t||_tj|jddd|_|jjddd|j|j_dS)Nd)widthZheightZbothr')Zfillexpand)r;ZTopleveltopZCanvasr3packrrrrr rs zTester.__init__cCs|Srrrrrrrr rszTester.dnd_acceptc Csp|j||j|\}}|j|j\}}}}||||} } |j|||| || |_|||dSr)r3 focus_setrCbboxr5Zcreate_rectangledndidr ) rrrr#r$x1y1x2y2ZdxZdyrrr r"s  zTester.dnd_enterc CsF||j|\}}|j|j\}}}}|j|j||||dSr)rCr3rNrOrD) rrrr#r$rPrQrRrSrrr r szTester.dnd_motioncCs"|j|j|jd|_dSr)rJrMr3r>rOrLrrr r!$s zTester.dnd_leavecCs2|||||j|\}}||j||dSr)r!rCr3r=)rrrr#r$rrr r-)s zTester.dnd_commitN) r.r/r0rrr"r r!r-rrrr rF s rFcCst}|dtj|jddt|}|jdt|}|jdt|}|jdtd}td}td }| |j | |j | |j | dS) Nz+1+1ZQuit)Zcommandr8z+1+60z+120+60z+240+60ZICON1ZICON2ZICON3) r;ZTkZgeometryZButtonquitrKrFrJr1r=r3Zmainloop)rt1t2Zt3Zi1Zi2Zi3rrr test/s        rW__main__)__doc__r;r rr1rFrWr.rrrr sf Y=#PK!D@**-__pycache__/simpledialog.cpython-38.opt-1.pycnu[U e5d-@sdZddlTddlmZmZGdddZGdddeZdd ZGd d d eZGd d d eZ ddZ GdddeZ ddZ GdddeZ ddZedkrddZedS)a&This modules handles dialog boxes. It contains the following public symbols: SimpleDialog -- A simple but flexible modal dialog box Dialog -- a base class for dialogs askinteger -- get an integer from the user askfloat -- get a float from the user askstring -- get a string from the user )*) messagebox_get_default_rootc@sLeZdZdgddddfddZdddZd d Zd d Zd dZddZdS) SimpleDialogNc Cs|rt||d|_n t||_|r:|j||j|t|jt|j|dd|_|jjdtdt |j|_ |j ||_ ||_ ||_ |jd|jtt|D]L}||} t|j | ||fddd } ||kr| jtd d | jttdd q|jd |j||dS)N)class_i)textZaspect)expandfillcSs ||SN)doneselfnumr,/usr/lib64/python3.8/tkinter/simpledialog.py8z'SimpleDialog.__init__..rcommand)ZreliefZ borderwidth)sider r WM_DELETE_WINDOW)ToplevelroottitleZiconname _setup_dialogZMessagemessagepackZBOTHFrameframercanceldefaultbind return_eventrangelenButtonZconfigZRIDGELEFTprotocolwm_delete_window_set_transient) rmasterrbuttonsr$r#rrrsbrrr__init__ s2       zSimpleDialog.__init__?333333?c Cs|j}|||||rJ|}|}|}|}n| }| }d}}| } | } ||| |} ||| |} | | | kr| | } n | dkrd} | | | kr| | } n | dkrd} | d| | f|dS)Nr+%d+%d)rwithdraw transientupdate_idletasksZwinfo_ismappedZ winfo_widthZ winfo_height winfo_rootx winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheightgeometry deiconify) rr.ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_heightxyrrrr-?s4  zSimpleDialog._set_transientcCs.|j|j|j|j|jSr )rwait_visibilitygrab_setmainloopdestroyrrrrrgo\s     zSimpleDialog.gocCs&|jdkr|jn ||jdSr )r$rbellrrZeventrrrr&cs  zSimpleDialog.return_eventcCs&|jdkr|jn ||jdSr )r#rrErrCrrrr,is  zSimpleDialog.wm_delete_windowcCs||_|jdSr )rrquitrrrrroszSimpleDialog.done)r3r4) __name__ __module__ __qualname__r2r-rDr&r,rrrrrrs  rc@sVeZdZdZdddZddZddZd d Zdd d Zdd dZ ddZ ddZ dS)DialogzZClass to open dialogs. This class is intended as a base class for custom dialogs NcCs|}|std}t||||dk r>|r>|||rL||t|||_d|_ t |}| ||_ |j ddd||j s||_ |d|j|dk r|d|d|df||j ||||dS)zInitialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title zcreate dialog windowN)padxpadyrr52)rrr2r6Zwinfo_viewabler7rrparentresultr!body initial_focusr buttonboxr+r#r;r9r:r< focus_setr?r@Z wait_window)rrPrr.rRrrrr2{s8       zDialog.__init__cCsd|_t|dS)zDestroy the windowN)rSrrBrCrrrrBszDialog.destroycCsdS)zcreate dialog body. return widget that should have initial focus. This method should be overridden, and is called by the __init__ method. Nr)rr.rrrrRsz Dialog.bodycCsvt|}t|dd|jtd}|jtdddt|dd|jd}|jtddd|d|j|d |j|d S) z[add standard button box. override if you do not want the standard buttons ZOK )rwidthrr$rL)rrMrNCancel)rrWrr zN)r!r)okZACTIVEr r*r#r%)rZboxwrrrrTszDialog.buttonboxcCsB|s|jdS||z |W5|XdSr )validaterSrUr6r8r#applyrFrrrrYs  z Dialog.okcCs |jdk r|j|dSr )rPrUrBrFrrrr#s  z Dialog.cancelcCsdS)zvalidate the data This method is called automatically to validate the data before the dialog is destroyed. By default, it always validates OK. r rrCrrrr[szDialog.validatecCsdS)zprocess the data This method is called automatically to process the data, *after* the dialog is destroyed. By default, it does nothing. NrrCrrrr\sz Dialog.apply)N)N)N) rHrIrJ__doc__r2rBrRrTrYr#r[r\rrrrrKts 7    rKcCs:|jdkr |jdd|ddn|jdkr6|dddS) NZaquaz!::tk::unsupported::MacWindowStyleZstyleZ moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkZcallZ wm_attributes)rZrrrrs   rc@s.eZdZd ddZddZddZdd ZdS) _QueryDialogNcCs*||_||_||_||_t|||dSr )promptminvaluemaxvalue initialvaluerKr2)rrr_rbr`rarPrrrr2s z_QueryDialog.__init__cCsd|_t|dSr )entryrKrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdk rl|j d|j|j dt |jS)N)rZjustifyrrL)rowrMZstickyrc)namer ) ZLabelr_r*ZgridWZEntryrcErbinsertZ select_rangeZEND)rr.rZrrrrR s z_QueryDialog.bodycCsz |}Wn,tk r8tjd|jd|dYdSX|jdk rh||jkrhtjdd|j|ddS|jdk r||jkrtjdd|j|ddS||_d S) Nz Illegal valuez Please try again)rPrz Too smallz2The allowed minimum value is %s. Please try again.z Too largez2The allowed maximum value is %s. Please try again.r ) getresult ValueErrorr showwarning errormessager`rarQ)rrQrrrr[.s: z_QueryDialog.validate)NNNN)rHrIrJr2rBrRr[rrrrr^ s r^c@seZdZdZddZdS) _QueryIntegerzNot an integer.cCs||jSr )ZgetintrcgetrCrrrriSsz_QueryInteger.getresultNrHrIrJrlrirrrrrmPsrmcKst||f|}|jS)zget an integer from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is an integer )rmrQrr_kwdrrr askintegerWs rsc@seZdZdZddZdS) _QueryFloatzNot a floating point value.cCs||jSr )Z getdoublercrnrCrrrriisz_QueryFloat.getresultNrorrrrrtfsrtcKst||f|}|jS)zget a float from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a float )rtrQrprrraskfloatms ruc@s$eZdZddZddZddZdS) _QueryStringcOs6d|kr|d|_|d=nd|_tj|f||dS)Nshow)_QueryString__showr^r2)rargsrqrrrr2}s  z_QueryString.__init__cCs(t||}|jdk r$|j|jd|S)N)rw)r^rRrxZ configure)rr.rcrrrrRs  z_QueryString.bodycCs |jSr )rcrnrCrrrrisz_QueryString.getresultN)rHrIrJr2rRrirrrrrv|srvcKst||f|}|jS)zget a string from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a string )rvrQrprrr askstrings rz__main__cCsLt}|fdd}t|d|d}|t|d|jd}||dS)NcSs^t|ddddgdddd}t|ttd d d d ttd d dddttd ddS)NzThis is a test dialog. Would this have been an actual dialog, the buttons below would have been glowing in soft pink light. Do you believe this?ZYesZNorXrz Test Dialog)rr/r$r#rZSpamz Egg count)rbzEgg weight (in tons)r d)r`raz Egg label)rprintrDrsrurz)rrrrrrdoits  ztest..doitZTestrZQuit)ZTkr)r rGrA)rrtqrrrtests rN)r]ZtkinterrrrrrKrr^rmrsrtrurvrzrHrrrrr s V CPK!zYVV-__pycache__/scrolledtext.cpython-38.opt-2.pycnu[U e5d@shdgZddlmZmZmZmZmZmZddlm Z m Z m Z m Z GdddeZ ddZedkrdedS) ScrolledText)FrameText ScrollbarPackGridPlace)RIGHTLEFTYBOTHc@seZdZdddZddZdS)rNcKst||_t|j|_|jjttd|d|jjit j ||jf||jt t dd|j |jd<tt }ttttBttB}||}|D]4}|ddkr|dkr|d krt||t|j|qdS) N)sidefillZyscrollcommandT)r rexpandZcommandr_ZconfigZ configure)rframerZvbarpackr r updatesetr__init__r r Zyviewvarskeysrrr differencesetattrgetattr)selfZmasterkwZ text_methsmethodsmr,/usr/lib64/python3.8/tkinter/scrolledtext.pyrs    $ zScrolledText.__init__cCs t|jS)N)strr)rrrr __str__)szScrolledText.__str__)N)__name__ __module__ __qualname__rr"rrrr rs cCsHddlm}tddd}||t|jttdd|| dS)Nr)ENDZwhite )ZbgZheightT)rr r) tkinter.constantsr&rinsert__doc__rr r Z focus_setZmainloop)r&Zstextrrr example-s    r+__main__N)__all__Ztkinterrrrrrrr(r r r r rr+r#rrrr s   PK!\yd33)__pycache__/__init__.cpython-38.opt-1.pycnu[U e5d͕@sdZddlZddlZddlZejZddlTddlZdZeej Z eej Z ej Z ejZejZedZedejZddZd d Zd d Zz ejZWnek rYnXd dZz ejZWnek rYnXdyddZGdddeejZGdddZdadaddZ dzddZ!ddZ"d{ddZ#da$GdddZ%Gd d!d!e%Z&Gd"d#d#e%Z'Gd$d%d%e%Z(Gd&d'd'e%Z)d|d(d)Z*e+Z,eZ-d*d+Z.Gd,d-d-Z/Gd.d/d/Z0Gd0d1d1Z1Gd2d3d3Z2Gd4d5d5Z3Gd6d7d7e/e3Z4d}d8d9Z5Gd:d;d;Z6Gdd?d?Z8Gd@dAdAe/Z9GdBdCdCe9e6e7e8Z:GdDdEdEe9e3Z;GdFdGdGe:ZGdLdMdMe:e1Z?GdNdOdOe:Z@GdPdQdQe:ZAGdRdSdSe:e1e2ZBGdTdUdUe:ZCGdVdWdWe:ZDGdXdYdYe:ZEGdZd[d[e:ZFGd\d]d]e:ZGGd^d_d_e:ZHGd`dadae:e1e2ZIGdbdcdcZJGdddedeeDZKGdfdgdgZLGdhdidieLZMGdjdkdkeLZNdldmZOdndoZPGdpdqdqe:e1ZQGdrdsdse:ZRGdtdudue:ZSdvdwZTeUdxkreTdS)~a8Wrapper functions for Tcl/Tk. Tkinter provides classes which allow the display, positioning and control of widgets. Toplevel widgets are Tk and Toplevel. Other widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox LabelFrame and PanedWindow. Properties of the widgets are specified with keyword arguments. Keyword arguments have the same name as the corresponding resource under Tk. Widgets are positioned with one of the geometry managers Place, Pack or Grid. These managers can be called with methods place, pack, grid available in every Widget. Actions are bound to events by resources (e.g. keyword argument command) or with the method bind. Example (Hello, World): import tkinter from tkinter.constants import * tk = tkinter.Tk() frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = tkinter.Label(frame, text="Hello, World") label.pack(fill=X, expand=1) button = tkinter.Button(frame,text="Exit",command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop() N)*z([\\{}])z([\s])cCsdtt|S)Internal function. )joinmap _stringifyvaluer (/usr/lib64/python3.8/tkinter/__init__.py_join8sr cCst|ttfrHt|dkr:t|d}t|rFd|}qdt|}ntt|}|sZd}nbt|rt d|}| dd}t d|}|ddkrd |}n|ddkst |rd|}|S) rrrz{%s}z{}z\\\1 z\n"\) isinstancelisttuplelenr _magic_researchr strsubreplace _space_rer r r r r=s$          rcCs@d}|D]2}t|ttfr(|t|}q|dk r||f}q|S)rr N)rrr_flatten)seqresitemr r r rVs rc Cst|tr|St|tdtfr$|Si}t|D]^}z||Wq0ttfk r}z(td|| D]\}}|||<qjW5d}~XYq0Xq0|SdS)rNz_cnfmerge: fallback due to:) rdicttyperrupdateAttributeError TypeErrorprintitems)Zcnfscnfcmsgkvr r r _cnfmergees   r+Tc Csz||}t|drtdt|}i}t||D]@\}}t|}|r`|ddkr`|dd}|rl||}|||<q4|S)aReturn a properly formatted dict built from Tcl list pairs. If cut_minus is True, the supposed '-' prefix will be removed from keys. If conv is specified, it is used to convert values. Tcl list is expected to contain an even number of elements. zNTcl list representing a dict is expected to contain an even number of elementsr-rN) splitlistr RuntimeErroriterzipr) tkr*Z cut_minusconvtitrkeyr r r r _splitdict{s    r7c@seZdZdZeZdZdZeZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)e*j+Z+d&S)' EventType23456789Z10Z11Z12Z13Z14Z15Z16Z17Z18Z19Z20Z21Z22Z23Z24Z25Z26Z27Z28Z29Z30Z31Z32Z33Z34Z35Z36Z37Z38N),__name__ __module__ __qualname__ZKeyPressZKeyZ KeyReleaseZ ButtonPressButtonZ ButtonReleaseZMotionZEnterZLeaveZFocusInZFocusOutZKeymapZExposeZGraphicsExposeZNoExposeZ VisibilityZCreateZDestroyZUnmapZMapZ MapRequestZReparentZ ConfigureZConfigureRequestZGravityZ ResizeRequestZ CirculateZCirculateRequestZPropertyZSelectionClearZSelectionRequestZ SelectionZColormapZ ClientMessageMappingZ VirtualEventZActivateZ DeactivateZ MouseWheelr__str__r r r r r8sPr8c@seZdZdZddZdS)EventaContainer for the properties of an event. Instances of this type are generated if one of the following events occurs: KeyPress, KeyRelease - for keyboard events ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for mouse events Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate, Colormap, Gravity, Reparent, Property, Destroy, Activate, Deactivate - for window events. If a callback function for one of these events is registered using bind, bind_all, bind_class, or tag_bind, the callback is called with an Event as first argument. It will have the following attributes (in braces are the event types for which the attribute is valid): serial - serial number of event num - mouse button pressed (ButtonPress, ButtonRelease) focus - whether the window has the focus (Enter, Leave) height - height of the exposed window (Configure, Expose) width - width of the exposed window (Configure, Expose) keycode - keycode of the pressed key (KeyPress, KeyRelease) state - state of the event as a number (ButtonPress, ButtonRelease, Enter, KeyPress, KeyRelease, Leave, Motion) state - state as a string (Visibility) time - when the event occurred x - x-position of the mouse y - y-position of the mouse x_root - x-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) y_root - y-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) char - pressed character (KeyPress, KeyRelease) send_event - see X/Windows documentation keysym - keysym of the event as a string (KeyPress, KeyRelease) keysym_num - keysym of the event as a number (KeyPress, KeyRelease) type - type of the event as a number widget - widget in which the event occurred delta - delta of wheel movement (MouseWheel) csdd|jD|js"d=n|jdkr:t|jd<t|ddsLd=|jdkr^d=n|t|jtr|j}d }g}t|D]\}}|d |>@r| |q|d t |>d @}|s|s| t |d |d<|j dkrd =d }dt|jd|jd fdd|DfS)NcSsi|]\}}|dkr||qS)??r .0r)r*r r r sz"Event.__repr__..charrH send_eventTrstate) ZShiftZLockZControlZMod1ZMod2ZMod3ZMod4ZMod5ZButton1ZButton2ZButton3ZButton4ZButton5r|delta) rMrNkeysymkeycoderLnumrPfocusxywidthheightz <%s event%s>namec3s&|]}|krd||fVqdS)z %s=%sNr )rJr)attrsr r sz!Event.__repr__..)__dict__r%rLreprgetattrrNrint enumerateappendrhexrrPr )selfrNZmodssinkeysr r[r __repr__s6       zEvent.__repr__N)rArBrC__doc__rjr r r r rGs*rGcCsdadabdS)zInhibit setting of default root window. Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window. FN)_support_default_root _default_rootr r r r NoDefaultRootsrncCs.ts tdts*|r$td|dt}tS)NzINo master specified and tkinter is configured to not support default rootz Too early to z: no default root window)rlr/rmTk)whatrootr r r _get_default_root#srrcCsdSrNr )errr r r _tkerror/srucCs.z t|}Wntk r YnXt|dS)zBInternal function. Calling it will raise the exception SystemExit.N)ra ValueError SystemExit)coder r r _exit4s  ryc@seZdZdZdZdZdZdddZddZdd Z d d Z e Z d d Z ddZ ddZddZddZddZeZddZddZddZdS)VariablezClass to define value holders for e.g. buttons. Subclasses StringVar, IntVar, DoubleVar, BooleanVar are specializations that constrain the type of the value returned from get().rZNcCs|dk rt|tstd|s&td}||_|j|_|rD||_ndtt |_t d7a |dk rn| |n&|j |j dd|js| |j dS)a.Construct a variable MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nzname must be a stringzcreate variablePY_VARrinfoexists)rrr#rr_rootr2_tk_namer__varnum initialize getbooleancall_defaultremasterr rYr r r __init__Is   zVariable.__init__cCsb|jdkrdS|j|jdd|jr6|j|j|jdk r^|jD]}|j|qFd|_dS)zUnset the variable in Tcl.Nr|r})rrrrZglobalunsetvar _tclCommands deletecommandrerYr r r __del__gs   zVariable.__del__cCs|jS)z'Return the name of the variable in Tcl.)rrer r r rFsszVariable.__str__cCs|j|j|SzSet the variable to VALUE.)r globalsetvarrrer r r r setwsz Variable.setcCs|j|jS)zReturn value of variable.)r globalgetvarrrr r r get}sz Variable.getcCst|d|jj}tt|}z |j}Wntk r:YnXz||j}Wntk r^YnX|j |||j dkr~g|_ |j ||SN) CallWrapperr~__call__r_id__func__r"rAr createcommandrrc)recallbackfcbnamer r r _registers    zVariable._registercCs(||}|jddd|j||f|S)a#Define a trace callback for the variable. Mode is one of "read", "write", "unset", or a list or tuple of such strings. Callback must be a function which is called when the variable is read, written or unset. Return the name of the callback. traceaddvariablerrrrremoderrr r r trace_adds  zVariable.trace_addcCsx|jddd|j|||D] \}}|j|d|kr qtq |j|z|j|Wntk rrYnXdS)aDelete the trace callback for a variable. Mode is one of "read", "write", "unset" or a list or tuple of such strings. Must be same as were specified in trace_add(). cbname is the name of the callback returned from trace_add(). rremoverrN) rrr trace_infor.rrrrvrerrmZcar r r trace_removes  zVariable.trace_removec s4|jjfddt|jddd|jDS)z&Return all trace callback information.csg|]\}}||fqSr r rIr.r r sz'Variable.trace_info..rr|r)rr.rrrrr rr rszVariable.trace_infocCs$||}|jdd|j|||S)aDefine a trace callback for the variable. MODE is one of "r", "w", "u" for read, write, undefine. CALLBACK must be a function which is called when the variable is read, written or undefined. Return the name of the callback. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_add() instead. rrrrr r r trace_variables zVariable.trace_variablecCs|jdd|j|||j|d}|D] \}}|j|d|kr.qq.|j|z|j|Wntk rYnXdS)aSDelete the trace callback for a variable. MODE is one of "r", "w", "u" for read, write, undefine. CBNAME is the name of the callback returned from trace_variable or trace. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_remove() instead. rZvdeleterN) rrrr.rrrrrvrr r r trace_vdeletes  zVariable.trace_vdeletecs(fddjjddjDS)zReturn all trace callback information. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_info() instead. csg|]}j|qSr )rr.rJrUrr r rsz(Variable.trace_vinfo..rZvinfo)rr.rrrr rr trace_vinfoszVariable.trace_vinfocCs6t|tstS|j|jko4|jj|jjko4|j|jkSr)rrzNotImplementedr __class__rAr)reotherr r r __eq__s   zVariable.__eq__)NNN)rArBrCrkrrrrrrFrrrrrrrrrrrrr r r r rz@s&   rzc@s&eZdZdZdZdddZddZdS) StringVarz#Value holder for strings variables.rZNcCst||||dS)a6Construct a string variable. MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrzrrr r r rs zStringVar.__init__cCs$|j|j}t|tr|St|S)z#Return value of variable as string.)rrrrrrr r r rs z StringVar.get)NNNrArBrCrkrrrr r r r rs rc@s&eZdZdZdZdddZddZdS) IntVarz#Value holder for integer variables.rNcCst||||dS)a7Construct an integer variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrrr r r rs zIntVar.__init__c CsJ|j|j}z|j|WSttfk rDt|j|YSXdS)z/Return the value of the variable as an integer.N)rrrgetintr#TclErrorra getdoublerr r r rs z IntVar.get)NNNrr r r r r s rc@s&eZdZdZdZdddZddZdS) DoubleVarz!Value holder for float variables.gNcCst||||dS)a6Construct a float variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0.0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrrr r r r*s zDoubleVar.__init__cCs|j|j|jS)z,Return the value of the variable as a float.)rrrrrr r r r6sz DoubleVar.get)NNNrr r r r r&s rc@s2eZdZdZdZd ddZddZeZdd ZdS) BooleanVarz#Value holder for boolean variables.FNcCst||||dS)a:Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrrr r r r?s zBooleanVar.__init__cCs|j|j|j|Sr)rrrrrr r r rKszBooleanVar.setcCs:z|j|j|jWStk r4tdYnXdS)z+Return the value of the variable as a bool. invalid literal for getboolean()N)rrrrrrvrr r r rQszBooleanVar.get)NNN) rArBrCrkrrrrrr r r r r;s  rcCstdj|dS)zRun the main loop of Tcl.zrun the main loopN)rrr2mainloop)rhr r r rYsrcCs4ztdj|WStk r.tdYnXdS)z$Convert Tcl object to True or False.zuse getboolean()rN)rrr2rrrvrfr r r rcsrc@seZdZdZdZdZddZddZd1ddZd d Z d d Z d2ddZ e Z d3ddZ d4ddZd5ddZd6ddZddZddZddZdd ZeZd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd7d/d0Zd1d2Zd3d4Zd8d6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(d9dHdIZ)dJdKZ*dLdMZ+d:dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d;d\d]Z3ddbdcZ7dddeZ8dfdgZ9dhdiZ:djdkZ;d?dldmZdrdsZ?dtduZ@dvdwZAdxdyZBd@dzd{ZCd|d}ZDd~dZEddZFddZGdAddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^dBddZ_ddZ`ddZaddZbddZcddZdddZedd„ZfddĄZgddƄZhddȄZiddʄZjdCdd̄ZkdDddτZldEddфZmdFddӄZndGddՄZoddׄZpdHddلZqddۄZrdIdd݄Zsdd߄ZtddZuddZvddZwddZxeyddZzdJddZ{ddZ|e|Z}dKddZ~e~ZddZdZdeZddZddZddZddZddZdLddZeZddZeZddZddZddZdd Zd gZefd d ZeZd dZeZddZdMddZeZdNddZeZddZddZifddZeZddZefddZifdd ZeZd!d"ZeZdOd#d$Zd%d&Zd'd(Zd)d*ZdPd+d,Zd-d.Zd/d0ZdS(QMisczRInternal class. Base class which defines methods common for interior widgets.NcCs,|jdk r(|jD]}|j|qd|_dS)zkInternal function. Delete all Tcl commands created for this widget in the Tcl interpreter.N)rr2rrr r r destroyxs  z Misc.destroycCs6|j|z|j|Wntk r0YnXdS)zDInternal function. Delete the Tcl command provided in NAME.N)r2rrrrvrr r r rs  zMisc.deletecommandcCs|j|jdd|S)zSet Tcl internal variable, whether the look and feel should adhere to Motif. A parameter of 1 means adhere to Motif (e.g. no color change if mouse passes over slider). Returns the set value.rtk_strictMotif)r2rrrebooleanr r r rs  zMisc.tk_strictMotifcCs|jddS)zDChange the color scheme to light brown as used in Tk 3.6 and before. tk_bisqueNr2rrr r r rszMisc.tk_bisquecOs(|jdt|tt|dS)a Set a new color scheme for all widget elements. A single color as argument will cause that all colors of Tk widget elements are derived from this. Alternatively several keyword parameters and its associated colors can be given. The following keywords are valid: activeBackground, foreground, selectColor, activeForeground, highlightBackground, selectBackground, background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.) tk_setPaletteN)r2rrrr%reargskwr r r rs zMisc.tk_setPaletter{cCs|jdd|dS)zWait until the variable is modified. A parameter of type IntVar, StringVar, DoubleVar or BooleanVar must be given.tkwaitrNrrr r r wait_variableszMisc.wait_variablecCs"|dkr |}|jdd|jdS)zQWait until a WIDGET is destroyed. If no parameter is given self is used.Nrwindowr2r_wrerr r r wait_windowszMisc.wait_windowcCs"|dkr |}|jdd|jdS)zxWait until the visibility of a WIDGET changes (e.g. it appears). If no parameter is given self is used.NrZ visibilityrrr r r wait_visibilityszMisc.wait_visibility1cCs|j||dS)zSet Tcl variable NAME to VALUE.N)r2setvar)rerYr r r r rsz Misc.setvarcCs |j|S)z"Return value of Tcl variable NAME.)r2getvarrr r r rsz Misc.getvarc CsBz|j|WStk r<}ztt|W5d}~XYnXdSr)r2rrrvrrerfexcr r r rsz Misc.getintc CsBz|j|WStk r<}ztt|W5d}~XYnXdSr)r2rrrvrrr r r rszMisc.getdoublecCs0z|j|WStk r*tdYnXdS)zPReturn a boolean value for Tcl boolean values true and false given as parameter.rN)r2rrrv)rerfr r r rszMisc.getbooleancCs|jd|jdS)zDirect input focus to this widget. If the application currently does not have the focus this widget will get the focus if the application gets the focus through the window manager.rTNrrr r r focus_setszMisc.focus_setcCs|jdd|jdS)ztDirect input focus to this widget even if the application does not have the focus. Use with caution!rTz-forceNrrr r r focus_forceszMisc.focus_forcecCs&|jd}|dks|sdS||S)zReturn the widget which has currently the focus in the application. Use focus_displayof to allow working with several displays. Return None if application does not have the focus.rTnoneN)r2r _nametowidgetrr r r focus_gets  zMisc.focus_getcCs,|jdd|j}|dks|s"dS||S)zReturn the widget which has currently the focus on the display where this widget is located. Return None if the application does not have the focus.rT -displayofrNr2rrrrr r r focus_displayofs zMisc.focus_displayofcCs,|jdd|j}|dks|s"dS||S)zyReturn the widget which would have the focus if top level for this widget gets the focus from the window manager.rTz-lastforrNrrr r r focus_lastfors zMisc.focus_lastforcCs|jddS)zXThe widget under mouse will get automatically focus. Can not be disabled easily.tk_focusFollowsMouseNrrr r r rszMisc.tk_focusFollowsMousecCs"|jd|j}|sdS||S)anReturn the next widget in the focus order which follows widget which has currently the focus. The focus order first goes to the next child, then to the children of the child recursively and then to the next sibling which is higher in the stacking order. A widget is omitted if it has the takefocus resource set to 0. tk_focusNextNrrr r r r s zMisc.tk_focusNextcCs"|jd|j}|sdS||S)zHReturn previous widget in the focus order. See tk_focusNext for details. tk_focusPrevNrrr r r rszMisc.tk_focusPrevcsNsjd|dSfdd}j|_|jd|SdS)aCall function once after given time. MS specifies the time in milliseconds. FUNC gives the function which shall be called. Additional parameters are given as parameters to the function call. Return identifier to cancel scheduling with after_cancel.afterNcs8z W5zWntk r0YnXXdSr)rrr rfuncrYrer r callit,s  zMisc.after..callit)r2rrAr)reZmsrrrr rr r s z Misc.aftercGs|jd|f|S)zCall FUNC once if the Tcl main loop has no event to process. Return an identifier to cancel the scheduling with after_cancel.Zidle)r)rerrr r r after_idle8szMisc.after_idlecCsd|s tdz.|jdd|}|j|d}||Wntk rNYnX|jdd|dS)zCancel scheduling of function identified with ID. Identifier returned by after or after_idle must be given as first parameter. z?id must be a valid identifier returned from after or after_idlerr|rZcancelN)rvr2rr.rr)rerdataZscriptr r r after_cancel@szMisc.after_cancelrcCs|jd||dS)zRing a display's bell.)bellN)r2r _displayofre displayofr r r rQsz Misc.bellcKsdd|krN|jdkrNz d|d<|jd||WStk rL|d=YnX|jd||S)aRetrieve data from the clipboard on window's display. The window keyword defaults to the root window of the Tkinter application. The type keyword specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING, except on X11, where the default is to try UTF8_STRING and fall back to STRING. This command is equivalent to: selection_get(CLIPBOARD) r x11 UTF8_STRING) clipboardr)_windowingsystemr2r_optionsrrerr r r clipboard_getVs zMisc.clipboard_getcKs,d|kr|j|d<|jd||dS)zClear the data in the Tk clipboard. A widget specified for the optional displayof keyword argument specifies the target display.r)rclearNrr2rrrr r r clipboard_clearms zMisc.clipboard_clearcKs4d|kr|j|d<|jd||d|fdS)zAppend STRING to the Tk clipboard. A widget specified at the optional displayof keyword argument specifies the target display. The clipboard can be retrieved with selection_get.r)rrc--Nr)restringrr r r clipboard_appendus  zMisc.clipboard_appendcCs$|jdd|j}|sdS||S)zOReturn widget which has currently the grab in this application or None.grabZcurrentNrrr r r grab_currentszMisc.grab_currentcCs|jdd|jdS)z.Release grab for this widget if currently set.rreleaseNrrr r r grab_releaseszMisc.grab_releasecCs|jdd|jdS)zwSet grab for this widget. A grab directs all events to this and descendant widgets in the application.rrNrrr r r grab_setsz Misc.grab_setcCs|jddd|jdS)zSet global grab for this widget. A global grab directs all events to this and descendant widgets on the display. Use with caution - other applications do not get events anymore.rrz-globalNrrr r r grab_set_globalszMisc.grab_set_globalcCs"|jdd|j}|dkrd}|S)zYReturn None, "local" or "global" if this widget has no, a local or a global grab.rstatusrNr)rerr r r grab_statusszMisc.grab_statuscCs|jdd|||dS)zSet a VALUE (second parameter) for an option PATTERN (first parameter). An optional third parameter gives the numeric priority (defaults to 80).optionrNr)repatternr priorityr r r option_addszMisc.option_addcCs|jdddS)zPClear the option database. It will be reloaded if option_add is called.rrNrrr r r option_clearszMisc.option_clearcCs|jdd|j||S)zReturn the value for an option NAME for this widget with CLASSNAME. Values with higher priority override lower values.rrr)rerY classNamer r r option_getszMisc.option_getcCs|jdd||dS)zvRead file FILENAME into the option database. An optional second parameter gives the numeric priority.rZreadfileNr)reZfileNamerr r r option_readfileszMisc.option_readfilecKs,d|kr|j|d<|jd||dS)zClear the current X selection.r) selectionrNrrr r r selection_clears zMisc.selection_clearcKsvd|kr|j|d<d|kr`|jdkr`z d|d<|jd||WStk r^|d=YnX|jd||S)aReturn the contents of the current X selection. A keyword parameter selection specifies the name of the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display to use. A keyword parameter type specifies the form of data to be fetched, defaulting to STRING except on X11, where UTF8_STRING is tried before STRING.rr rr)r r)rrr2rrrrr r r selection_gets   zMisc.selection_getcKs.||}|jd|||j|fdS)aSpecify a function COMMAND to call if the X selection owned by this widget is queried by another application. This function must return the contents of the selection. The function will be called with the arguments OFFSET and LENGTH which allows the chunking of very long selections. The following keyword parameters can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).)r ZhandleN)rr2rrr)recommandrrYr r r selection_handles zMisc.selection_handlecKs"|jd|||jfdS)zBecome owner of X selection. A keyword parameter selection specifies the name of the selection (default PRIMARY).r ZownN)r2rrrrr r r selection_owns zMisc.selection_owncKs:d|kr|j|d<|jd||}|s0dS||S)zReturn owner of X selection. The following keyword parameter can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).rrN)rr2rrr)rerrYr r r selection_own_gets  zMisc.selection_own_getcGs|jd||f|S)zDSend Tcl command CMD to different interpreter INTERP to be executed.sendr)reZinterpcmdrr r r rsz Misc.sendcCs|jd|j|dS)z(Lower this widget in the stacking order.lowerNr)re belowThisr r r rsz Misc.lowercCs|jd|j|dS)z(Raise this widget in the stacking order.raiseNr)re aboveThisr r r tkraisesz Misc.tkraisecCs(d|||f}|j|j|S)z*Return integer which represents atom NAME.)winfoZatom)rr2rr)rerYrrr r r winfo_atomszMisc.winfo_atomcCs d|||f}|j|S)z'Return name of atom with identifier ID.)rZatomnamerr2rrerrrr r r winfo_atomname s zMisc.winfo_atomnamecCs|j|jdd|jS)z7Return number of cells in the colormap for this widget.rZcellsr2rrrrr r r winfo_cellsszMisc.winfo_cellsc CsRg}|j|jdd|jD].}z|||Wqtk rJYqXq|S)z?Return a list of all widgets which are children of this widget.rchildren)r2r.rrrcrKeyError)reresultchildr r r winfo_childrenszMisc.winfo_childrencCs|jdd|jS)z(Return window class name of this widget.rclassrrr r r winfo_class#szMisc.winfo_classcCs|j|jdd|jS)z?Return True if at the last color request the colormap was full.rZ colormapfullr2rrrrr r r winfo_colormapfull'szMisc.winfo_colormapfullcCs4d||||f}|j|}|s*dS||S)z@Return the widget which is at the root coordinates ROOTX, ROOTY.)rZ containingN)rr2rr)reZrootXZrootYrrrYr r r winfo_containing,s zMisc.winfo_containingcCs|j|jdd|jS)z$Return the number of bits per pixel.rZdepthr rr r r winfo_depth4szMisc.winfo_depthcCs|j|jdd|jS)z"Return true if this widget exists.rr}r rr r r winfo_exists8szMisc.winfo_existscCs|j|jdd|j|S)zWReturn the number of pixels for the given distance NUMBER (e.g. "3c") as float.rZfpixelsr2rrrrenumberr r r winfo_fpixels=s  zMisc.winfo_fpixelscCs|jdd|jS)zFReturn geometry string for this widget in the form "widthxheight+X+Y".rgeometryrrr r r winfo_geometryCszMisc.winfo_geometrycCs|j|jdd|jS)zReturn height of this widget.rrXr rr r r winfo_heightGszMisc.winfo_heightcCst|jdd|jdS)z%Return identifier ID for this widget.rrr)rar2rrrr r r winfo_idLsz Misc.winfo_idcCs"d||}|j|j|S)z9Return the name of all Tcl interpreters for this display.)rZinterps)rr2r.r)rerrr r r winfo_interpsPszMisc.winfo_interpscCs|j|jdd|jS)z%Return true if this widget is mapped.rZismappedr rr r r winfo_ismappedUszMisc.winfo_ismappedcCs|jdd|jS)z/Return the window manager name for this widget.rZmanagerrrr r r winfo_managerZszMisc.winfo_managercCs|jdd|jS)zReturn the name of this widget.rrYrrr r r winfo_name^szMisc.winfo_namecCs|jdd|jS)z-Return the name of the parent of this widget.rparentrrr r r winfo_parentbszMisc.winfo_parentcCs d|||f}|j|S)z.Return the pathname of the widget given by ID.)rpathnamerrr r r winfo_pathnamefs zMisc.winfo_pathnamecCs|j|jdd|j|S)z'Rounded integer value of winfo_fpixels.rZpixelsr r/r r r winfo_pixelslszMisc.winfo_pixelscCs|j|jdd|jS)z:Return the x coordinate of the pointer on the root window.rZpointerxr rr r r winfo_pointerxqszMisc.winfo_pointerxcCs||jdd|jS)zHReturn a tuple of x and y coordinates of the pointer on the root window.rZ pointerxy_getintsr2rrrr r r winfo_pointerxyvszMisc.winfo_pointerxycCs|j|jdd|jS)z:Return the y coordinate of the pointer on the root window.rZpointeryr rr r r winfo_pointery{szMisc.winfo_pointerycCs|j|jdd|jS)z'Return requested height of this widget.rZ reqheightr rr r r winfo_reqheightszMisc.winfo_reqheightcCs|j|jdd|jS)z&Return requested width of this widget.rZreqwidthr rr r r winfo_reqwidthszMisc.winfo_reqwidthcCs||jdd|j|S)zNReturn a tuple of integer RGB values in range(65536) for color in this widget.rZrgbr@)reZcolorr r r winfo_rgbszMisc.winfo_rgbcCs|j|jdd|jS)zSReturn x coordinate of upper left corner of this widget on the root window.rZrootxr rr r r winfo_rootxszMisc.winfo_rootxcCs|j|jdd|jS)zSReturn y coordinate of upper left corner of this widget on the root window.rZrootyr rr r r winfo_rootyszMisc.winfo_rootycCs|jdd|jS)z&Return the screen name of this widget.rscreenrrr r r winfo_screenszMisc.winfo_screencCs|j|jdd|jS)zTReturn the number of the cells in the colormap of the screen of this widget.rZ screencellsr rr r r winfo_screencellsszMisc.winfo_screencellscCs|j|jdd|jS)z\Return the number of bits per pixel of the root window of the screen of this widget.rZ screendepthr rr r r winfo_screendepthszMisc.winfo_screendepthcCs|j|jdd|jS)zXReturn the number of pixels of the height of the screen of this widget in pixel.rZ screenheightr rr r r winfo_screenheightszMisc.winfo_screenheightcCs|j|jdd|jS)zUReturn the number of pixels of the height of the screen of this widget in mm.rZscreenmmheightr rr r r winfo_screenmmheightszMisc.winfo_screenmmheightcCs|j|jdd|jS)zTReturn the number of pixels of the width of the screen of this widget in mm.rZ screenmmwidthr rr r r winfo_screenmmwidthszMisc.winfo_screenmmwidthcCs|jdd|jS)zReturn one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the default colormodel of this screen.rZ screenvisualrrr r r winfo_screenvisualszMisc.winfo_screenvisualcCs|j|jdd|jS)zWReturn the number of pixels of the width of the screen of this widget in pixel.rZ screenwidthr rr r r winfo_screenwidthszMisc.winfo_screenwidthcCs|jdd|jS)zxReturn information of the X-Server of the screen of this widget in the form "XmajorRminor vendor vendorVersion".rZserverrrr r r winfo_serverszMisc.winfo_servercCs||jdd|jS)z*Return the toplevel widget of this widget.rtoplevel)rr2rrrr r r winfo_toplevels  zMisc.winfo_toplevelcCs|j|jdd|jS)zBReturn true if the widget and all its higher ancestors are mapped.rZviewabler rr r r winfo_viewableszMisc.winfo_viewablecCs|jdd|jS)zReturn one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the colormodel of this widget.rvisualrrr r r winfo_visualszMisc.winfo_visualcCs|jdd|jS)z7Return the X identifier for the visual for this widget.rZvisualidrrr r r winfo_visualidszMisc.winfo_visualidFcsHjddj|rdnd}fddj|D}fdd|DS)zReturn a list of all visuals available for the screen of this widget. Each item in the list consists of a visual name (see winfo_visual), a depth and if includeids is true is given also the X identifier.rZvisualsavailable includeidsNcsg|]}j|qSr )r2r.rrr r rsz/Misc.winfo_visualsavailable..csg|]}|qSr )_Misc__winfo_parseitemrrr r rs)r2rrr.)rerYrr rr winfo_visualsavailables  zMisc.winfo_visualsavailablecCs$|ddtt|j|ddS)rNr)rr_Misc__winfo_getint)rer4r r r Z__winfo_parseitemszMisc.__winfo_parseitemcCs t|dS)rr)rarerUr r r Z__winfo_getintszMisc.__winfo_getintcCs|j|jdd|jS)zReturn the height of the virtual root window associated with this widget in pixels. If there is no virtual root window return the height of the screen.rZ vrootheightr rr r r winfo_vrootheightszMisc.winfo_vrootheightcCs|j|jdd|jS)zReturn the width of the virtual root window associated with this widget in pixel. If there is no virtual root window return the width of the screen.rZ vrootwidthr rr r r winfo_vrootwidthszMisc.winfo_vrootwidthcCs|j|jdd|jS)ziReturn the x offset of the virtual root relative to the root window of the screen of this widget.rZvrootxr rr r r winfo_vrootxszMisc.winfo_vrootxcCs|j|jdd|jS)ziReturn the y offset of the virtual root relative to the root window of the screen of this widget.rZvrootyr rr r r winfo_vrooty szMisc.winfo_vrootycCs|j|jdd|jS)z Return the width of this widget.rrWr rr r r winfo_widthszMisc.winfo_widthcCs|j|jdd|jS)zVReturn the x coordinate of the upper left corner of this widget in the parent.rrUr rr r r winfo_xsz Misc.winfo_xcCs|j|jdd|jS)zVReturn the y coordinate of the upper left corner of this widget in the parent.rrVr rr r r winfo_ysz Misc.winfo_ycCs|jddS)zEEnter event loop until all pending events have been processed by Tcl.r!Nrrr r r r! sz Misc.updatecCs|jdddS)zEnter event loop until all idle callbacks have been called. This will update the display of windows but not process events caused by the user.r!Z idletasksNrrr r r update_idletasks$szMisc.update_idletaskscCs6|dkr |j|jd|jS|jd|j|dS)a,Set or get the list of bindtags for this widget. With no argument return the list of all bindtags associated with this widget. With a list of strings as argument the bindtags are set to this list. The bindtags determine in which order events are processed (see bind).Nbindtagsr2r.rr)reZtagListr r r rf*s z Misc.bindtagsrcCst|tr |j|||fnn|rd|||j|}d|r>dp@d||jf}|j|||f|S|rz|j||fS|j|j|SdS)rz"%sif {"[%s %s]" == "break"} break +rZN)rrr2rr _substitute_subst_format_strr.)rerpsequencerr needcleanupfuncidrr r r _bind7s"   z Misc._bindcCs|d|jf|||S)aOBind to this widget at event SEQUENCE a call to function FUNC. SEQUENCE is a string of concatenated event patterns. An event pattern is of the form where MODIFIER is one of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4, Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3, B3, Alt, Button4, B4, Double, Button5, B5 Triple, Mod1, M1. TYPE is one of Activate, Enter, Map, ButtonPress, Button, Expose, Motion, ButtonRelease FocusIn, MouseWheel, Circulate, FocusOut, Property, Colormap, Gravity Reparent, Configure, KeyPress, Key, Unmap, Deactivate, KeyRelease Visibility, Destroy, Leave and DETAIL is the button number for ButtonPress, ButtonRelease and DETAIL is the Keysym for KeyPress and KeyRelease. Examples are for pressing Control and mouse button 1 or for pressing A and the Alt key (KeyPress can be omitted). An event pattern can also be a virtual event of the form <> where AString can be arbitrary. This event can be generated by event_generate. If events are concatenated they must appear shortly after each other. FUNC will be called if the event sequence occurs with an instance of Event as argument. If the return value of FUNC is "break" no further bound function is invoked. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. Bind will return an identifier to allow deletion of the bound function with unbind without memory leak. If FUNC or SEQUENCE is omitted the bound function or list of bound events are returned.bindrnrrerkrrr r r roIs'z Misc.bindcCs&|jd|j|d|r"||dS)zWUnbind for this widget for event SEQUENCE the function identified with FUNCID.rorZNr2rrr)rerkrmr r r unbindrsz Misc.unbindcCs|d|||dS)aBind to all widgets at an event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.)roallrrnrqr r r bind_allysz Misc.bind_allcCs|jdd|ddS)z8Unbind for all widgets for event SEQUENCE all functions.rortrZNr)rerkr r r unbind_allszMisc.unbind_allcCs|d|f|||dS)a=Bind to widgets with bindtag CLASSNAME at event SEQUENCE a call of function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rorru)rer rkrrr r r bind_classszMisc.bind_classcCs|jd||ddS)zWUnbind for all widgets with bindtag CLASSNAME for event SEQUENCE all functions.rorZNr)rer rkr r r unbind_classszMisc.unbind_classcCs|j|dS)zCall the mainloop of Tk.N)r2r)rerhr r r rsz Misc.mainloopcCs|jdS)z8Quit the Tcl interpreter. All widgets will be destroyed.N)r2quitrr r r rzsz Misc.quitcCs"|rtt|jj|j|SdSrs)rrr2rr.rerr r r rAsz Misc._getintscCs"|rtt|jj|j|SdSrs)rrr2rr.r{r r r _getdoublesszMisc._getdoublescCs|r|j|SdSrs)r2rr{r r r _getbooleanszMisc._getbooleancCs"|r d|fS|dkrd|jfSdS)rrNr rrr r r rs  zMisc._displayofcCsBz |jWStk r<|jdd}|_|YSXdS)rr2ZwindowingsystemN)r~Z_windowingsystem_cachedr"r2r)reZwsr r r rs   zMisc._windowingsystemcCs|rt||f}nt|}d}|D]\}}|dk r&|ddkrN|dd}t|rb||}n^t|ttfrg}|D]<}t|tr|t |qxt|t r|t |qxqqxd |}|d||f}q&|S)rr N_rr-) r+r%callablerrrrrarcrrr)rer&rrr)r*Znvrr r r rs*     z Misc._optionscCsNt|d}|}|ds.|}|dd}|D]}|s>qJ|j|}q2|S)zPReturn the Tkinter instance of a widget identified by its Tcl name NAME..rrN)rsplitr~r")rerYwrhr r r nametowidgets  zMisc.nametowidgetcCst|||j}tt|}z |j}Wntk r8YnXz||j}Wntk r\YnX|j|||r|j dkrg|_ |j ||S)zReturn a newly created Tcl function. If this function is called, the Python function FUNC will be executed. An optional function SUBST can be given which will be executed before FUNC.N) rrr_rrr"rAr2rrrc)rersubstrlrrYr r r rs     zMisc._registercCs|}|jr|j}q|S)rr)rerr r r r~sz Misc._root)z%#z%bz%fz%hz%kz%sz%tz%wz%xz%yz%Az%Ez%Kz%Nz%Wz%Tz%Xz%Yz%Drcst|t|jkr|S|jj}|jjfdd}|\}}}}}} } } } } }}}}}}}}}t}||_|||_z|||_Wnt k rYnX|||_ |||_ || |_ || |_ || |_|| |_|| |_||_z|||_Wnt k r YnX||_|||_zt||_Wntk rF||_YnXz|||_Wntk rt||_YnX|||_|||_z||_Wn tt fk rd|_YnX|fS)rc s,z |WSttfk r&|YSXdS)z?Tk changed behavior in 8.4.2, returning "??" rather more often.N)rvrrrr r getint_events z&Misc._substitute..getint_eventr)r _subst_formatr2rrrGserialrSrTrrXrRrNtimerWrUrVrLrMrQZ keysym_numr8r rvrwidgetr#Zx_rootZy_rootrP)rerrrZnsignbrhr)rfr4rrUrVAEKNWTXYDer rr ri sT *               zMisc._substitutecCs(t\}}}|}||||dSrs)sysexc_infor~report_callback_exception)rervaltbrqr r r _report_exceptionHszMisc._report_exceptioncGs\i}|j|jj|D]>}|j|}|dddf|dd||ddd<q|S)z;Call Tcl configure command and return the result as a dict.rrNr2r.r)rerr&rUr r r _getconfigureNs  0zMisc._getconfigurecGs2|j|jj|}|dddf|ddS)Nrrr)rerrUr r r _getconfigure1VszMisc._getconfigure1cCs|rt||f}n |rt|}|dkr:|t|j|fSt|tr^|t|j|d|fS|jt|j|f| |dS)rNr-) r+rrrrrrr2rr)rerr&rr r r _configureZs zMisc._configurecKs|d||S)zConfigure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys. configurerrer&rr r r rgszMisc.configurecCs|j|jdd|S)z4Return the resource value for a KEY given as string.cgetr-rrer6r r r rrsz Misc.cgetcCs|||idSr)rrer6r r r r __setitem__xszMisc.__setitem__cs*|jjfdd|j|jdDS)z3Return a list of all resource names of this widget.cs g|]}|dddqS)rrNr rrr r r~szMisc.keys..rrgrr rr ri{s z Misc.keyscCs|jS)z+Return the window path name of this widget.r~rr r r rFsz Misc.__str__cCsd|jj|jj|jfS)Nz<%s.%s object %s>)rrBrCrrr r r rjs z Misc.__repr___noarg_cCs:|tjkr"||jdd|jS|jdd|j|dS)aSet or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given the current setting will be returned. pack propagateNrrr}r2rrreflagr r r pack_propagates  zMisc.pack_propagatecs(fddjjddjDS)HReturn a list of all slaves of this widget in its packing order.csg|]}|qSr rrrr r rsz$Misc.pack_slaves..rslavesrgrr rr pack_slavess  zMisc.pack_slavescs(fddjjddjDS)rcsg|]}|qSr rrrr r rsz%Misc.place_slaves..placerrgrr rr place_slavess zMisc.place_slavescCs|jdd|j|dS)zThe anchor value controls how to place the grid within the master when no row/column has any weight. The default anchor is nw.gridanchorNr)rerr r r grid_anchorszMisc.grid_anchorcCsZdd|jf}|dk r(|dk r(|||f}|dk rD|dk rD|||f}||jj|pXdS)aReturn a tuple of integer coordinates for the bounding box of this widget controlled by the geometry manager grid. If COLUMN, ROW is given the bounding box applies from the cell with row and column 0 to the specified cell. If COL2 and ROW2 are given the bounding box starts at that cell. The returned integers specify the offset of the upper left corner in the master widget and the width and height. rbboxN)rrAr2r)recolumnrowZcol2Zrow2rr r r grid_bboxs   zMisc.grid_bboxc Csht|ttjfrdz:t|}|s$WdSd|kr:|j|WS|j|WSWnttfk rbYnX|S)Nr) rr_tkinterZTcl_Objr2rrrvr)rer Zsvaluer r r _gridconvvalueszMisc._gridconvvaluecCst|trJ|sJ|dddkr*|dd}|dddkrBd|}|f}n |||}|s|t|j|jd||j||jdS|jd||j|f|}t|dkr||SdS)rrNrrr-r)r3) rrrr7r2rrrr)rerindexr&roptionsrr r r _grid_configures(    zMisc._grid_configurecKs|d|||S)zConfigure column INDEX of a grid. Valid resources are minsize (minimum size of the column), weight (how much does additional space propagate to this column) and pad (how much space to let additionally).columnconfigurerrerr&rr r r grid_columnconfigureszMisc.grid_columnconfigurec Cs ||jdd|j||pdS)zReturn a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.rlocationNr@rerUrVr r r grid_locationszMisc.grid_locationcCs:|tjkr"||jdd|jS|jdd|j|dS)aSet or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given, the current setting will be returned. rrNrrr r r grid_propagates  zMisc.grid_propagatecKs|d|||S)zConfigure row INDEX of a grid. Valid resources are minsize (minimum size of the row), weight (how much does additional space propagate to this row) and pad (how much space to let additionally). rowconfigurerrr r r grid_rowconfigureszMisc.grid_rowconfigurecCs||jdd|jpdS)z.rrrg)rerrrr rr grid_slaves s    zMisc.grid_slavescGsdd|f|}|j|dS)zBind a virtual event VIRTUAL (of the form <>) to an event SEQUENCE such that the virtual event is triggered whenever SEQUENCE occurs.eventrNrrevirtual sequencesrr r r event_add/szMisc.event_addcGsdd|f|}|j|dS)z-Unbind a virtual event VIRTUAL from SEQUENCE.rdeleteNrrr r r event_delete6szMisc.event_deletecKsDdd|j|f}|D]\}}|d|t|f}q|j|dS)zGenerate an event SEQUENCE. Additional keyword arguments specify parameter of the event (e.g. x, y, rootx, rooty).rZgenerate-%sN)rr%rr2r)rerkrrr)r*r r r event_generate;szMisc.event_generatecCs|j|jdd|S)zuReturn a list of all virtual events or the information about the SEQUENCE bound to the virtual event VIRTUAL.rr|r)rerr r r event_infoDszMisc.event_infocCs|j|jddS)z*Return a list of all existing image names.imagenamesrrr r r image_namesLszMisc.image_namescCs|j|jddS)z?Return a list of all available image types (e.g. photo bitmap).rtypesrrr r r image_typesPszMisc.image_types)N)r{)N)N)r{r)r{)N)r)N)N)N)N)r)r)r)r)r)F)N)r)NNN)N)NNN)NNN)r)N)Nr)N)N)NNNN)NN)N)rArBrCrk_last_child_idsrrrrrrrZwaitvarrrrrrrrrrTrrrrrrrrrrrrrrrrrrrrrr r r rrrrrrrliftrrr!r&r(r*r+r,r-r1r3r4r5r6r7r8r9r;r=r>r?rBrCrDrErFrGrHrJrKrLrMrNrOrPrQrRrTrUrWrXr[rZr\r^r_r`rarbrcrdr!rerfrnrorsrvrwrxryrrzrAr|r}rpropertyrrrrrregisterr~rrrjrirrrrrconfigr __getitem__rrirFrjrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rmsP                          )       =                  rc@s eZdZdZddZddZdS)rzwInternal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.cCs||_||_||_dS)z(Store FUNC, SUBST and WIDGET as members.N)rrr)rerrrr r r rYszCallWrapper.__init__cGsLz|jr|j|}|j|WStk r2Yn|jYnXdS)z3Apply first function SUBST to arguments, than FUNC.N)rrrwrrrerr r r r_s  zCallWrapper.__call__NrArBrCrkrrr r r r rUsrc@s(eZdZdZddZddZddZdS) XViewzXMix-in class for querying and changing the horizontal position of a widget's window.cGs(|jj|jdf|}|s$||SdS)z5Query and change the horizontal position of the view.xviewNr2rrr|rerrr r r rosz XView.xviewcCs|j|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.rmovetoNrrefractionr r r xview_movetouszXView.xview_movetocCs|j|jdd||dS)z\Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).rscrollNrrer0rpr r r xview_scrollzszXView.xview_scrollN)rArBrCrkrrrr r r r rksrc@s(eZdZdZddZddZddZdS) YViewzVMix-in class for querying and changing the vertical position of a widget's window.cGs(|jj|jdf|}|s$||SdS)z3Query and change the vertical position of the view.yviewNrrr r r rsz YView.yviewcCs|j|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.rrNrrr r r yview_movetoszYView.yview_movetocCs|j|jdd||dS)z\Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).rrNrrr r r yview_scrollszYView.yview_scrollN)rArBrCrkrrrr r r r rsrc@seZdZdZdBddZeZddZeZdCddZeZ d d Z e Z dDd d Z e Z d dZeZdEddZeZddZeZddZeZdFddZeZdGddZeZdHddZeZdIddZeZddZeZdJdd Z e Z!dKd!d"Z"e"Z#dLd$d%Z$e$Z%dMd&d'Z&e&Z'dNd(d)Z(e(Z)d*d+Z*e*Z+dOd,d-Z,e,Z-dPd.d/Z.e.Z/dQd0d1Z0e0Z1dRd2d3Z2e2Z3dSd4d5Z4e4Z5dTd6d7Z6e6Z7dUd8d9Z8e8Z9dVd:d;Z:e:Z;dWdd?Z>e>Z?d@dAZ@e@ZAdS)YWmzAProvides functions for the communication with the window manager.Nc Cs ||jdd|j||||S)zInstruct the window manager to set the aspect ratio (width/height) of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. Return a tuple of the actual values if no argument is given.wmaspectr@)reZminNumerZminDenomZmaxNumerZmaxDenomr r r wm_aspectsz Wm.wm_aspectcGsdd|jf|}|j|S)aThis subcommand returns or sets platform specific attributes The first form returns a list of the platform specific flags and their values. The second form returns the value for the specific option. The third form sets one or more of the values. The values are as follows: On Windows, -disabled gets or sets whether the window is in a disabled state. -toolwindow gets or sets the style of the window to toolwindow (as defined in the MSDN). -topmost gets or sets whether this is a topmost window (displays above all other windows). On Macintosh, XXXXX On Unix, there are currently no special attribute values. r attributes)rr2rrr r r wm_attributesszWm.wm_attributescCs|jdd|j|S)zVStore NAME in WM_CLIENT_MACHINE property of this widget. Return current value.rclientrrr r r wm_clientsz Wm.wm_clientcsZt|dkr|f}ddjf|}|r4j|n"fddjj|DSdS)zStore list of window names (WLIST) into WM_COLORMAPWINDOWS property of this widget. This list contains windows whose colormaps differ from their parents. Return current list of widgets if WLIST is empty.rrcolormapwindowscsg|]}|qSr rrrr r rsz)Wm.wm_colormapwindows..N)rrr2rr.)reZwlistrr rr wm_colormapwindowss  zWm.wm_colormapwindowscCs|jdd|j|S)zStore VALUE in WM_COMMAND property. It is the command which shall be used to invoke the application. Return current command if VALUE is None.rrrrr r r wm_commandsz Wm.wm_commandcCs|jdd|jS)zDeiconify this widget. If it was never mapped it will not be mapped. On Windows it will raise this widget and give it the focus.r deiconifyrrr r r wm_deiconifyszWm.wm_deiconifycCs|jdd|j|S)zSet focus model to MODEL. "active" means that this widget will claim the focus itself, "passive" means that the window manager shall give the focus. Return current focus model if MODEL is None.r focusmodelr)reZmodelr r r wm_focusmodelszWm.wm_focusmodelcCs|jdd|dS)aAThe window will be unmapped from the screen and will no longer be managed by wm. toplevel windows will be treated like frame windows once they are no longer managed by wm, however, the menu option configuration will be remembered and the menus will return once the widget is managed again.rforgetNrrr r r wm_forgetsz Wm.wm_forgetcCs|jdd|jS)zAReturn identifier for decorative frame of this widget if present.rframerrr r r wm_framesz Wm.wm_framecCs|jdd|j|S)ziSet geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return current value if None is given.rr2r)reZ newGeometryr r r wm_geometryszWm.wm_geometryc Cs ||jdd|j||||S)aInstruct the window manager that this widget shall only be resized on grid boundaries. WIDTHINC and HEIGHTINC are the width and height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are the number of grid units requested in Tk_GeometryRequest.rrr@)reZ baseWidthZ baseHeightZwidthIncZ heightIncr r r wm_grids z Wm.wm_gridcCs|jdd|j|S)z~Set the group leader widgets for related widgets to PATHNAME. Return the group leader of this widget if None is given.rgrouprreZpathNamer r r wm_group sz Wm.wm_groupcCs2|r|jdd|jd|S|jdd|j|SdS)aSet bitmap for the iconified widget to BITMAP. Return the bitmap if None is given. Under Windows, the DEFAULT parameter can be used to set the icon for the widget and any descendents that don't have an icon set explicitly. DEFAULT can be the relative path to a .ico file (example: root.iconbitmap(default='myicon.ico') ). See Tk documentation for more information.r iconbitmap-defaultNr)rebitmapdefaultr r r wm_iconbitmaps zWm.wm_iconbitmapcCs|jdd|jS)zDisplay widget as icon.riconifyrrr r r wm_iconify$sz Wm.wm_iconifycCs|jdd|j|S)zVSet mask for the icon bitmap of this widget. Return the mask if None is given.riconmaskr)rerr r r wm_iconmask*szWm.wm_iconmaskcCs|jdd|j|S)zSSet the name of the icon for this widget. Return the name if None is given.riconnamer)reZnewNamer r r wm_iconname1szWm.wm_iconnameFcGs<|r |jjdd|jdf|n|jjdd|jf|dS)aSets the titlebar icon for this window based on the named photo images passed through args. If default is True, this is applied to all future created toplevels as well. The data in the images is taken as a snapshot at the time of invocation. If the images are later changed, this is not reflected to the titlebar icons. Multiple images are accepted to allow different images sizes to be provided. The window manager may scale provided icons to an appropriate size. On Windows, the images are packed into a Windows icon structure. This will override an icon specified to wm_iconbitmap, and vice versa. On X, the images are arranged into the _NET_WM_ICON X property, which most modern window managers support. An icon specified by wm_iconbitmap may exist simultaneously. On Macintosh, this currently does nothing.r iconphotorNr)rerrr r r wm_iconphoto8szWm.wm_iconphotoc Cs||jdd|j||S)zSet the position of the icon of this widget to X and Y. Return a tuple of the current values of X and X if None is given.r iconpositionr@rr r r wm_iconpositionSs zWm.wm_iconpositioncCs|jdd|j|S)zgSet widget PATHNAME to be displayed instead of icon. Return the current value if None is given.r iconwindowrr r r r wm_iconwindow[szWm.wm_iconwindowcCs|jdd|dS)zThe widget specified will become a stand alone top-level window. The window will be decorated with the window managers title bar, etc.rmanageNr)rerr r r wm_managebsz Wm.wm_managec Cs||jdd|j||S)zSet max WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.rmaxsizer@rerWrXr r r wm_maxsizejs z Wm.wm_maxsizec Cs||jdd|j||S)zSet min WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.rminsizer@r#r r r wm_minsizess z Wm.wm_minsizecCs||jdd|j|S)zInstruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.roverrideredirect)r}r2rrrr r r wm_overrideredirect|s  zWm.wm_overrideredirectcCs|jdd|j|S)zInstruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".r positionfromrreZwhor r r wm_positionfromszWm.wm_positionfromcCs.t|r||}n|}|jdd|j||S)zBind function FUNC to command NAME for this widget. Return the function bound to NAME if None is given. NAME could be e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW".rprotocol)rrr2rr)rerYrrr r r wm_protocols zWm.wm_protocolcCs|jdd|j||S)zyInstruct the window manager whether this width can be resized in WIDTH or HEIGHT. Both values are boolean values.r resizablerr#r r r wm_resizableszWm.wm_resizablecCs|jdd|j|S)zInstruct the window manager that the size of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".rsizefromrr*r r r wm_sizefromszWm.wm_sizefromcCs|jdd|j|S)zQuery or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).rrNr)reZnewstater r r wm_statesz Wm.wm_statecCs|jdd|j|S)zSet the title of this widget.rtitlerr{r r r wm_titlesz Wm.wm_titlecCs|jdd|j|S)z_Instruct the window manager that this widget is transient with regard to widget MASTER.r transientr)rerr r r wm_transientszWm.wm_transientcCs|jdd|jS)zWithdraw this widget from the screen such that it is unmapped and forgotten by the window manager. Re-draw it with wm_deiconify.rwithdrawrrr r r wm_withdrawszWm.wm_withdraw)NNNN)N)N)N)N)NNNN)N)NN)N)N)F)NN)N)NN)NN)N)N)NN)NN)N)N)N)N)BrArBrCrkrrrrrrrrrrrrrrrrr rr r2r rrr rrrrrrrrrrrrrrr!r r$r"r&r%r(r'r+r)r-r,r/r.r1r0r2rNr4r3r6r5r8r7r r r r rs                        rc@sNeZdZdZdZdddZdd Zd d Zd d ZddZ ddZ ddZ dS)rozzToplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.rNrrc Csd|_i|_d|_d|_|dkrZddl}|jtjd}|j |\}}|dkrZ||}d} t |||| t ||||_|r| tjjs|||dS)a@Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.NFr)z.pyz.pyc)rr" _tkloadedr2ospathbasenamerargvsplitextrcreate wantobjects_loadtkflagsignore_environment readprofile) re screenNamebaseNamer useTksyncZuser:Zext interactiver r r rs z Tk.__init__cCs|js|j|dSr)r9r2loadtkrArr r r rJs z Tk.loadtkcCsd|_|jd}|tjkr.tdtj|ft|jd}|tjkrZtdtj|f|jdkrjg|_|j dt |j dt |j d|j dt rts|a|d|jdS) NT tk_versionz4tk.h version (%s) doesn't match libtk.a version (%s) tcl_versionz6tcl.h version (%s) doesn't match libtcl.a version (%s)ZtkerrorexitWM_DELETE_WINDOW)r9r2rr TK_VERSIONr/r TCL_VERSIONrrruryrcrlrmr,r)rerKrLr r r rAs(      z Tk._loadtkcCsJt|jD] }|q|jd|jt|trFt |krFda dS)zhDestroy this and all descendants widgets. This will end the application of this Tcl interpreter.rN) rr"valuesrr2rrrrlrmrer'r r r r s    z Tk.destroyc Csddl}d|jkr|jd}n|j}|j|d|}|j|d|}|j|d|}|j|d|}d|i} td| |j|r|jd||j|rtt | | |j|r|jd||j|rtt | | dS) zInternal function. It reads BASENAME.tcl and CLASSNAME.tcl into the Tcl Interpreter and calls exec on the contents of BASENAME.py and CLASSNAME.py if such a file exists in the home directory.rNHOMEz.%s.tclz.%s.pyrezfrom tkinter import *source) r:environcurdirr;rexecisfiler2ropenread) rerFr r:homeZ class_tclZclass_pyZbase_tclZbase_pydirr r r rD s$      zTk.readprofilecCs:ddl}tdtjd|t_|t_|t_||||dS)zReport callback exception on sys.stderr. Applications may want to override this internal function, and should when sys.stderr is None.rNzException in Tkinter callback)file) tracebackr$rstderr last_type last_valuelast_tracebackprint_exception)rerrrr^r r r r$ s zTk.report_callback_exceptioncCs t|j|S)z3Delegate attribute access to the interpreter object)r`r2)reattrr r r __getattr__0 szTk.__getattr__)NNrorrN) rArBrCrkrrrJrArrDrrer r r r ros   rocCst||||Sr)ro)rErFr rGr r r TclC srfc@sTeZdZdZifddZeZZZddZeZ ddZ e Z e j ZZ e jZZdS) PackzQGeometry manager Pack. Base class to use the methods pack_* in every widget.cKs$|jdd|jf|||dS)a(Pack a widget in the parent widget. Use as options: after=widget - pack it after you have packed widget anchor=NSEW (or subset) - position widget according to given direction before=widget - pack it before you will pack widget expand=bool - expand widget if parent size grows fill=NONE or X or Y or BOTH - fill widget if widget grows in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction side=TOP or BOTTOM or LEFT or RIGHT - where to add this widget. rrNr2rrrrr r r pack_configureL s   zPack.pack_configurecCs|jdd|jdS)z:Unmap this widget and do not use it for the packing order.rrNrrr r r pack_forgetb szPack.pack_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)zEReturn information about the packing options for this widget.rr|inr7r2rrrredr r r pack_infoh szPack.pack_infoN)rArBrCrkrirrrrjrror|rrrrrr r r r rgG s   rgc@sJeZdZdZifddZeZZZddZeZ ddZ e Z e j ZZ dS) PlacezSGeometry manager Place. Base class to use the methods place_* in every widget.cKs$|jdd|jf|||dS)a Place a widget in the parent widget. Use as options: in=master - master relative to which the widget is placed in_=master - see 'in' option description x=amount - locate anchor of this widget at position x of master y=amount - locate anchor of this widget at position y of master relx=amount - locate anchor of this widget between 0.0 and 1.0 relative to width of master (1.0 is right edge) rely=amount - locate anchor of this widget between 0.0 and 1.0 relative to height of master (1.0 is bottom edge) anchor=NSEW (or subset) - position anchor according to given direction width=amount - width of this widget in pixel height=amount - height of this widget in pixel relwidth=amount - width of this widget between 0.0 and 1.0 relative to width of master (1.0 is the same width as the master) relheight=amount - height of this widget between 0.0 and 1.0 relative to height of master (1.0 is the same height as the master) bordermode="inside" or "outside" - whether to take border width of master widget into account rrNrhrr r r place_configurez s   zPlace.place_configurecCs|jdd|jdS)Unmap this widget.rrNrrr r r place_forget szPlace.place_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)zEReturn information about the placing options for this widget.rr|rkrlrmr r r place_info szPlace.place_infoN)rArBrCrkrqrrrrsrrtr|rrrr r r r rpu s  rpc@seZdZdZifddZeZZZej Z Z ej Z Z ddZ e ZddZdd ZeZejZZejZZejZZejZZejZZd S) GridzQGeometry manager Grid. Base class to use the methods grid_* in every widget.cKs$|jdd|jf|||dS)aPosition a widget in the parent widget in a grid. Use as options: column=number - use cell identified with given column (starting with 0) columnspan=number - this widget will span several columns in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction row=number - use cell identified with given row (starting with 0) rowspan=number - this widget will span several rows sticky=NSEW - if cell is larger on which sides will this widget stick to the cell boundary rrNrhrr r r grid_configure s   zGrid.grid_configurecCs|jdd|jdS)rrrrNrrr r r grid_forget szGrid.grid_forgetcCs|jdd|jdS)z0Unmap this widget but remember the grid options.rrNrrr r r grid_remove szGrid.grid_removecCs8t|j|jdd|j}d|kr4||d|d<|S)zSReturn information about the options for positioning this widget in a grid.rr|rkrlrmr r r grid_info szGrid.grid_infoN)rArBrCrkrvrrrrrrrrrwrrxryr|rrrrrrrrrrr r r r ru s        ruc@s:eZdZdZddZiidfddZddZd d d Zd S) BaseWidgetzInternal class.cCs|s t}||_|j|_d}d|kr2|d}|d=|s|jj}|jdkrRi|_|j|dd}||j|<|dkrd|f}n d||f}||_|j dkrd||_ n|j d||_ i|_ |j|jj kr|jj |j ||jj |j<dS)z6Internal function. Sets up information about children.NrYrrz!%sz!%s%dr) rrrr2rrArrrrrr"r)rerr&rYcountr r r _setup s2       zBaseWidget._setupr c Cs|rt||f}||_t||||jdkr4g|_dd|D}|D]\}}||=qJ|j||jf|| ||D]\}}| ||q~dS)zdConstruct a widget with the parent widget MASTER, a name WIDGETNAME and appropriate options.NcSs"g|]\}}t|tr||fqSr )rr rIr r r r s z'BaseWidget.__init__..) r+ widgetNamerzr|rr%r2rrrr) rerr}r&rextraclassesr)r*r r r r s    zBaseWidget.__init__cCsTt|jD] }|q|jd|j|j|jjkrF|jj|j=t |dS)z)Destroy this and all descendants widgets.rN) rr"rQrr2rrrrrrRr r r r s   zBaseWidget.destroycCs|j|j|f|Srr)rerYrr r r _do szBaseWidget._doN)r )rArBrCrkr|rrrr r r r rz s rzc@seZdZdZdS)WidgetzxInternal class. Base class for a widget which can be positioned with the geometry managers Pack, Place or Grid.N)rArBrCrkr r r r r src@seZdZdZdifddZdS)Toplevelz"Toplevel widget, e.g. for dialogs.Nc Ks|rt||f}d}dD]L}||kr||}|ddkrJd|dd}nd|}|||f}||=qt||d|i||}|||||d|jdS) a%Construct a toplevel widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, menu, relief, screen, takefocus, use, visual, width.r )rIclass_r'rVZcolormaprrr-NrSrN)r+rzrr~rr3r,r) rerr&rr~Zwmkeyroptrqr r r r) s    zToplevel.__init__rArBrCrkrr r r r r& src@s.eZdZdZdifddZddZddZdS) rDzButton widget.NcKst||d||dS)aUConstruct a button widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, repeatdelay, repeatinterval, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS command, compound, default, height, overrelief, state, width ZbuttonNrrrerr&rr r r rG szButton.__init__cCs|j|jddS)a_Flash the button. This is accomplished by redisplaying the button several times, alternating between active and normal colors. At the end of the flash the button is left in the same normal/active state as when the command was invoked. This command is ignored if the button's state is disabled. flashNrrr r r r\ s z Button.flashcCs|j|jdS)aInvoke the command associated with the button. The return value is the return value from the command, or an empty string if there is no command associated with the button. This command is ignored if the button's state is disabled. invokerrr r r rh sz Button.invoke)rArBrCrkrrrr r r r rDD s rDc@seZdZdZdifddZddZddZd d Zd d Zdwd dZ ddZ ddZ ddZ ddZ dxddZdyddZdzddZd{ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#d|dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-d}dWdXZ.e.Z/dYdZZ0e0Z1d[d\Z2d~d^d_Z3ifd`daZ4dbdcZ5e5Z6Z7dddeZ8dfdgZ9ddidjZ:dkdlZ;dmdnZdsdtZ?dudvZ@dS)Canvasz?Canvas widget to display graphical elements like lines or text.NcKst||d||dS)aConstruct a canvas widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, closeenough, confine, cursor, height, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, offset, relief, scrollregion, selectbackground, selectborderwidth, selectforeground, state, takefocus, width, xscrollcommand, xscrollincrement, yscrollcommand, yscrollincrement.ZcanvasNrrr r r rv s zCanvas.__init__cGs|j|jdf|dS)raddtagNrrr r r r sz Canvas.addtagcCs||d|dS)z*Add tag NEWTAG to all items above TAGORID.aboveNrrenewtagtagOrIdr r r addtag_above szCanvas.addtag_abovecCs||ddS)zAdd tag NEWTAG to all items.rtNr)rerr r r addtag_all szCanvas.addtag_allcCs||d|dS)z*Add tag NEWTAG to all items below TAGORID.belowNrrr r r addtag_below szCanvas.addtag_belowcCs||d||||dS)zAdd tag NEWTAG to item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closests). If START is specified the next below this tag is taken.closestNr)rerrUrVhalostartr r r addtag_closest szCanvas.addtag_closestcCs||d||||dS)zLAdd tag NEWTAG to all items in the rectangle defined by X1,Y1,X2,Y2.enclosedNrrerx1y1x2y2r r r addtag_enclosed szCanvas.addtag_enclosedcCs||d||||dS)zWAdd tag NEWTAG to all items which overlap the rectangle defined by X1,Y1,X2,Y2. overlappingNrrr r r addtag_overlapping szCanvas.addtag_overlappingcCs||d|dS)z)Add tag NEWTAG to all items with TAGORID.withtagNrrr r r addtag_withtag szCanvas.addtag_withtagcGs ||j|jdf|pdS)z|Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses all items with tags specified as arguments.rNr@rr r r r s z Canvas.bboxcCs(|j|jd||d|r$||dS)zbUnbind for all items with TAGORID for event SEQUENCE the function identified with FUNCID.rorZNrr)rerrkrmr r r tag_unbind szCanvas.tag_unbindcCs||jd|f|||S)a&Bind to all items with TAGORID at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rorp)rerrkrrr r r tag_bind s zCanvas.tag_bindcCs|j|j|jd||S)zrReturn the canvas x coordinate of pixel position SCREENX rounded to nearest multiple of GRIDSPACING units.canvasxr.)reZscreenx gridspacingr r r r s  zCanvas.canvasxcCs|j|j|jd||S)zrReturn the canvas y coordinate of pixel position SCREENY rounded to nearest multiple of GRIDSPACING units.canvasyr.)reZscreenyrr r r r s  zCanvas.canvasycs,fddjjjdf|DS)z8Return a list of coordinates for the item given in ARGS.csg|]}j|qSr )r2rrrr r r sz!Canvas.coords..coordsrgrr rr r s  z Canvas.coordsc Cs\t|}|d}t|ttfr,|dd}ni}|j|jj|jd|f||||S)rrNr?) rrrrr2rrrr)reitemTyperrr&r r r _create s zCanvas._createcOs|d||S)z6Create arc shaped region with coordinates x1,y1,x2,y2.Zarcrrr r r create_arc szCanvas.create_arccOs|d||S)z%Create bitmap with coordinates x1,y1.rrrr r r create_bitmap szCanvas.create_bitmapcOs|d||S)z)Create image item with coordinates x1,y1.rrrr r r create_image szCanvas.create_imagecOs|d||S)z-Create line with coordinates x1,y1,...,xn,yn.linerrr r r create_line szCanvas.create_linecOs|d||S)z)Create oval with coordinates x1,y1,x2,y2.Zovalrrr r r create_oval szCanvas.create_ovalcOs|d||S)z0Create polygon with coordinates x1,y1,...,xn,yn.Zpolygonrrr r r create_polygon szCanvas.create_polygoncOs|d||S)z.Create rectangle with coordinates x1,y1,x2,y2.Z rectanglerrr r r create_rectangle szCanvas.create_rectanglecOs|d||S)z#Create text with coordinates x1,y1.textrrr r r create_text szCanvas.create_textcOs|d||S)z+Create window with coordinates x1,y1,x2,y2.rrrr r r create_window szCanvas.create_windowcGs|j|jdf|dS)zDelete characters of text items identified by tag or id in ARGS (possibly several times) from FIRST to LAST character (including).dcharsNrrr r r r sz Canvas.dcharscGs|j|jdf|dS)zeZdZdZdifddZddZddZd d Zd d ZdS) RadiobuttonzGRadiobutton widget which shows only one of several buttons in on-state.NcKst||d||dS)aConstruct a radiobutton widget with the parent MASTER. Valid resource names: activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor, disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, padx, pady, relief, selectcolor, selectimage, state, takefocus, text, textvariable, underline, value, variable, width, wraplength.rNrrr r r rV s zRadiobutton.__init__cCs|j|jddSrrrr r r rb szRadiobutton.deselectcCs|j|jddSrrrr r r rg szRadiobutton.flashcCs|j|jdSrrrr r r rk szRadiobutton.invokecCs|j|jddSrrrr r r ro szRadiobutton.select) rArBrCrkrrrrrr r r r r*S s  r*c@s@eZdZdZdifddZddZddZd d d Zd d ZdS)Scalez1Scale widget which can display a numerical scale.NcKst||d||dS)aConstruct a scale widget with the parent MASTER. Valid resource names: activebackground, background, bigincrement, bd, bg, borderwidth, command, cursor, digits, fg, font, foreground, from, highlightbackground, highlightcolor, highlightthickness, label, length, orient, relief, repeatdelay, repeatinterval, resolution, showvalue, sliderlength, sliderrelief, state, takefocus, tickinterval, to, troughcolor, variable, width.rNrrr r r rw s zScale.__init__c CsJ|j|jd}z|j|WStttfk rD|j|YSXdS)z*Get the current value as integer or float.rN)r2rrrrvr#rrrr r r r s z Scale.getcCs|j|jd|dS)zSet the value to VALUE.rNrrr r r r sz Scale.setcCs||j|jd|S)zReturn a tuple (X,Y) of the point along the centerline of the trough that corresponds to VALUE or the current value if None is given.rr@rr r r r sz Scale.coordscCs|j|jd||S)zcReturn where the point X,Y lies. Valid return values are "slider", "though1" and "though2".identifyrrr r r r, szScale.identify)N) rArBrCrkrrrrr,r r r r r+t s   r+c@sPeZdZdZdifddZdddZddZd d Zd d Zd dZ ddZ dS) Scrollbarz?Scrollbar widget which displays a slider at a certain position.NcKst||d||dS)alConstruct a scrollbar widget with the parent MASTER. Valid resource names: activebackground, activerelief, background, bd, bg, borderwidth, command, cursor, elementborderwidth, highlightbackground, highlightcolor, highlightthickness, jump, orient, relief, repeatdelay, repeatinterval, takefocus, troughcolor, width.Z scrollbarNrrr r r r s zScrollbar.__init__cCs|j|jd|pdS)aMarks the element indicated by index as active. The only index values understood by this method are "arrow1", "slider", or "arrow2". If any other value is specified then no element of the scrollbar will be active. If index is not specified, the method returns the name of the element that is currently active, or None if no element is active.rNrrr r r r szScrollbar.activatecCs|j|j|jd||S)znReturn the fractional change of the scrollbar setting if it would be moved by DELTAX or DELTAY pixels.rPr.)reZdeltaxZdeltayr r r rP szScrollbar.deltacCs|j|j|jd||S)zRReturn the fractional value which corresponds to a slider position of X,Y.rr.rr r r r szScrollbar.fractioncCs|j|jd||S)zYReturn the element under position X,Y as one of "arrow1","slider","arrow2" or "".r,rrr r r r, szScrollbar.identifycCs||j|jdS)zZReturn the current fractional values (upper and lower end) of the slider position.r)r|r2rrrr r r r sz Scrollbar.getcCs|j|jd||dS)ziSet the fractional values of the slider position (upper and lower ends as value between 0 and 1).rNrrr r r r sz Scrollbar.set)N) rArBrCrkrrrPrr,rrr r r r r- s r-c@seZdZdZdifddZddZddZd d Zdkd d Zdld dZ ddZ dmddZ ddZ dnddZ ddZddZddZddZdodd Zd!d"Zdpd#d$Zifd%d&Zd'd(Zd)d*Zd+d,Zdqd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zifd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#drdCdDZ$dEdFZ%dGdHZ&dsdIdJZ'dtdKdLZ(dMdNZ)dudOdPZ*e*Z+dQdRZ,dvdSdTZ-dwdUdVZ.dxdWdXZ/dydYdZZ0dzd[d\Z1d]d^Z2d{d_d`Z3dadbZ4d|dcddZ5e5Z6ifdedfZ7dgdhZ8didjZ9dS)}Textz4Text widget which can display text in various forms.NcKst||d||dS)aConstruct a text widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, padx, pady, relief, selectbackground, selectborderwidth, selectforeground, setgrid, takefocus, xscrollcommand, yscrollcommand, WIDGET-SPECIFIC OPTIONS autoseparators, height, maxundo, spacing1, spacing2, spacing3, state, tabs, undo, width, wrap, rNrrr r r r sz Text.__init__cCs||j|jd|pdS)zReturn a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the given index.rNr@rr r r r s z Text.bboxc Cs|j|j|jd|||S)zReturn whether between index INDEX1 and index INDEX2 the relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=.comparer))reropr r r r r/ s z Text.comparecGsVdd|D}|||g7}|jj|jdf|p2d}|dk rNt|dkrN|fS|SdS)aCounts the number of relevant things between the two indices. If index1 is after index2, the result will be a negative number (and this holds for each of the possible options). The actual items which are counted depends on the options given by args. The result is a list of integers, one for the result of each counting option given. Valid counting options are "chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels" and "ypixels". There is an additional possible option "update", which if given then all subsequent options ensure that any possible out of date information is recalculated.cSsg|]}|dsd|qS)r-r) startswith)rJargr r r rs zText.count..r{N)r2rrr)rerr rrr r r r{ s  z Text.countcCs6|dkr |j|j|jdS|j|jd|dS)zjTurn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.Ndebugr)rr r r r4 sz Text.debugcCs|j|jd||dS)z?Delete the characters between INDEX1 and INDEX2 (not included).rNrrerr r r r rsz Text.deletecCs||j|jd|S)zReturn tuple (x,y,width,height,baseline) giving the bounding box and baseline position of the visible part of the line containing the character at INDEX. dlineinfor@rr r r r6szText.dlineinfoc Ksg}d}d}|s$g}|fdd}|}zzt|ts>||}}|d|g7}|D]} || rN|d| qN|||r|||jj|jdf||WS|r||XdS)aReturn the contents of the widget between index1 and index2. The type of contents returned in filtered based on the keyword parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are given and true, then the corresponding items are returned. The result is a list of triples of the form (key, value, index). If none of the keywords are true then 'all' is used by default. If the 'command' argument is given, it is called once for each element of the list of triples, with the values of each triple serving as the arguments to the function. In this case the list is not returned.NcSs||||fdSr)rc)r6r rr$r r r append_triple/sz Text.dump..append_triplez-commandr-dump)rrrrrcr2rr) rerr rrrZ func_namer$r7r6r r r r8s*      z Text.dumpcGs|jj|jdf|S)arInternal method This method controls the undo mechanism and the modified flag. The exact behavior of the command depends on the option argument that follows the edit argument. The following forms of the command are currently supported: edit_modified, edit_redo, edit_reset, edit_separator and edit_undo editrrr r r r9Bs z Text.editcCs |d|S)a;Get or Set the modified flag If arg is not specified, returns the modified flag of the widget. The insert, delete, edit undo and edit redo commands or the user can set or clear the modified flag. If boolean is specified, sets the modified flag of the widget to arg. Zmodifiedr9)rer2r r r edit_modifiedQs zText.edit_modifiedcCs |dS)a Redo the last undone edit When the undo option is true, reapplies the last undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the undo option is false. Zredor:rr r r edit_redo\szText.edit_redocCs |dS)z(Clears the undo and redo stacks resetr:rr r r edit_resetfszText.edit_resetcCs |dS)znInserts a separator (boundary) on the undo stack. Does nothing when the undo option is false rr:rr r r edit_separatorkszText.edit_separatorcCs |dS)aDUndoes the last edit action If the undo option is true. An edit action is defined as all the insert and delete commands that are recorded on the undo stack in between two separators. Generates an error when the undo stack is empty. Does nothing when the undo option is false Zundor:rr r r edit_undors zText.edit_undocCs|j|jd||S)z5Return the text from INDEX1 to INDEX2 (not included).rrr5r r r r}szText.getcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z9Return the value of OPTION of an embedded image at INDEX.Nrr-rrrrrr r r r image_cgets  zText.image_cgetcKs|dd|f||S)z%Configure an embedded image at INDEX.rrrrr r r image_configureszText.image_configurecKs"|jj|jdd|f|||S)z"Create an embedded image at INDEX.rr?rhrr r r image_creates zText.image_createcCs|j|jddS)z3Return all names of embedded images in this widget.rrrrr r r rszText.image_namescCst|j|jd|S)z1Return the index in the form line.char for INDEX.r)rr2rrrr r r rsz Text.indexcGs|j|jd||f|dS)zInsert CHARS before the characters at INDEX. An additional tag can be given in ARGS. Additional CHARS and tags can follow in ARGS.rNr)rercharsrr r r rsz Text.insertcCs|j|jdd||fS)zChange the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT). Return the current value if None is given for DIRECTION.rZgravityr)remarkName directionr r r mark_gravityszText.mark_gravitycCs|j|j|jddS)zReturn all mark names.rrrgrr r r mark_namess  zText.mark_namescCs|j|jdd||dS)z0Set mark MARKNAME before the character at INDEX.rrNr)rerErr r r mark_setsz Text.mark_setcGs|j|jddf|dS)zDelete all marks in MARKNAMES.rZunsetNr)reZ markNamesr r r mark_unsetszText.mark_unsetcCs|j|jdd|pdS)z-Return the name of the next mark after INDEX.rnextNrrr r r mark_nextszText.mark_nextcCs|j|jdd|pdS)z2Return the name of the previous mark before INDEX.rZpreviousNrrr r r mark_previousszText.mark_previouscKs&|jj|jdd|f|||dS)aCreates a peer text widget with the given newPathName, and any optional standard configuration options. By default the peer will have the same start and end line as the parent widget, but these can be overridden with the standard configuration options.peerr?Nrh)reZ newPathNamer&rr r r peer_creates zText.peer_createcCs|j|j|jddS)zYReturns a list of peers of this widget (this does not include the widget itself).rNrrgrr r r peer_namesszText.peer_namescGs |jj|jd|||f|dS)zReplaces the range of characters between index1 and index2 with the given characters and tags specified by args. See the method insert for some more information about args, and the method delete for information about the indices.rNr)rerr rDrr r r rsz Text.replacecCs|j|jdd||dSrrrr r r rszText.scan_markcCs|j|jdd||dS)z~Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.rrNrrr r r rszText.scan_dragtoc Cs|jdg} |r| d|r&| d|r4| d|rB| d|rP| d| r^| d| rv| d| | |r|d d kr| d | || ||r| |t|jt| S) zSearch PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.rz -forwardsz -backwardsz-exactz-regexpz-nocasez-elidez-countrr-r)rrcrr2rr) rerrZ stopindexZforwardsZ backwardsexactZregexpZnocaser{Zeliderr r r rs.            z Text.searchcCs|j|jd|dS)z3Scroll such that the character at INDEX is visible.rNrrr r r rszText.seecGs |j|jdd||f|dS)z|Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS. Additional pairs of indices may follow in ARGS.tagrNr)retagNamerrr r r tag_addsz Text.tag_addcCs*|j|jdd||d|r&||dS)zgUnbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.rRrorZNrr)rerSrkrmr r r rszText.tag_unbindcCs||jdd|f|||S)a+Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rRrorp)rerSrkrrr r r rs z Text.tag_bindcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z+Return the value of OPTION for tag TAGNAME.Nrr-rrrRrr)rerSrr r r tag_cget s  z Text.tag_cgetcKs|dd|f||S)zConfigure a tag TAGNAME.rRrr)rerSr&rr r r tag_configureszText.tag_configurecGs|j|jddf|dS)zDelete all tags in TAGNAMES.rRrNr)reZtagNamesr r r tag_deleteszText.tag_deletecCs|j|jdd||dS)z`Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.rRrNr)rerSrr r r rszText.tag_lowercCs|j|j|jdd|S)zReturn a list of all tag names.rRrrgrr r r tag_names szText.tag_namesc Cs |j|j|jdd|||S)zReturn a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched forward from INDEX1.rRZ nextrangergrerSrr r r r tag_nextrange%s zText.tag_nextrangec Cs |j|j|jdd|||S)zReturn a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched backwards from INDEX1.rRZ prevrangergrYr r r tag_prevrange,s zText.tag_prevrangecCs|j|jdd||dS)zaChange the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.rRrNr)rerSrr r r r3szText.tag_raisecCs|j|j|jdd|S)z7Return a list of ranges of text which have tag TAGNAME.rRZrangesrg)rerSr r r tag_ranges9s  zText.tag_rangescCs|j|jdd|||dS)zARemove tag TAGNAME from all characters between INDEX1 and INDEX2.rRrNrrYr r r tag_remove>szText.tag_removecCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z:Return the value of OPTION of an embedded window at INDEX.Nrr-rrrrrr r r r window_cgetCs  zText.window_cgetcKs|dd|f||S)z&Configure an embedded window at INDEX.rrrrr r r window_configureKszText.window_configurecKs&|j|jdd|f|||dS)zCreate a window at INDEX.rr?Nrhrr r r window_createQs   zText.window_createcCs|j|j|jddS)z4Return all names of embedded windows in this widget.rrrgrr r r window_namesWszText.window_namescGs|j|jddf|dS)zObsolete function, use see.rz -pickplaceNr)rerpr r r yview_pickplace\szText.yview_pickplace)N)N)NN)N)N)N)N)NNNNNNNN)N)N)N)N)N)N)N)N)N)N):rArBrCrkrrr/r{r4rr6r8r9r;r<r>r?r@rrArBrCrrrrGrHrIrJrLrMrOrPrrrrrrTrrrUrVZ tag_configrWrrXrZr[rr\r]r^r_Z window_configr`rarbr r r r r. s~   (                   r.c@s"eZdZdZdddZddZdS)_setitz>Internal class. It wraps the command in the widget OptionMenu.NcCs||_||_||_dSr) _setit__value _setit__var_setit__callback)revarr rr r r rdsz_setit.__init__cGs*|j|j|jr&|j|jf|dSr)rerrdrfrr r r risz_setit.__call__)Nrr r r r rcas rcc@s(eZdZdZddZddZddZdS) OptionMenuz?OptionMenu which allows the user to select a value from a menu.c Osd|dtddd}t||d|d|_t|ddd }|_|j|_|d }d |kr\|d =|rtt d t t ||j |t |||d |D]} |j | t || |d q||d<d S)zConstruct an optionmenu widget with the parent MASTER, with the resource textvariable set to VARIABLE, the initially selected value VALUE, the other menu values VALUES and an additional keyword argument command.r,rr')Z borderwidthZ textvariableZ indicatoronZreliefrZhighlightthicknessr'Z tk_optionMenur r)rYZtearoffrzunknown option -)rrN)ZRAISEDrrr}r _OptionMenu__menurZmenunamerrrKr0rrc) rerrr rQkwargsrr rr*r r r rrs.   zOptionMenu.__init__cCs|dkr|jSt||S)Nr )rirrrr r r rszOptionMenu.__getitem__cCst|d|_dS)z,Destroy this widget and the associated menu.N)r&rrirr r r rs zOptionMenu.destroyN)rArBrCrkrrrr r r r rhosrhc@sheZdZdZdZdidfddZddZdd Zd d Zd d Z ddZ e Z ddZ ddZ ddZdS)ImagezBase class for images.rNc Ksd|_|std}t|d||_|s>tjd7_dtjf}|rT|rTt||f}n|r\|}d}|D]*\}}t|r| |}|d||f}qh|j dd||f|||_dS) Nz create imager2rz pyimage%rr r-rr?) rYrrr`r2rk_last_idr+r%rrr) reZimgtyperYr&rrrr)r*r r r rs$  zImage.__init__cCs|jSr)rYrr r r rFz Image.__str__cCs6|jr2z|jdd|jWntk r0YnXdS)Nrr)rYr2rrrr r r rs z Image.__del__cCs|j|jdd||dSNrr-r2rrYrr r r rszImage.__setitem__cCs|j|jdd|Srnrorr r r rszImage.__getitem__cKsvd}t|D]J\}}|dk r|ddkr8|dd}t|rJ||}|d||f}q|j|jdf|dS)zConfigure the image.r Nrrr-r)r+r%rrr2rrY)rerrr)r*r r r rs  zImage.configurecCs|j|jdd|jS)zReturn the height of the image.rrXr2rrrYrr r r rXsz Image.heightcCs|jdd|jS)z7Return the type of the image, e.g. "photo" or "bitmap".rr rorr r r r sz Image.typecCs|j|jdd|jS)zReturn the width of the image.rrWrprr r r rWsz Image.width)rArBrCrkrlrrFrrrrrrXr rWr r r r rks rkc@seZdZdZdidfddZddZddZd d Zd d ZdddZ dddZ ddZ dddZ dddZ ddZddZdS) PhotoImagez=Widget which can display images in PGM, PPM, GIF, PNG format.NcKstj|d|||f|dS)ztCreate an image with NAME. Valid resource names: data, format, file, gamma, height, palette, width.ZphotoNrkrrerYr&rrr r r rszPhotoImage.__init__cCs|j|jddS)zDisplay a transparent image.blankNrorr r r rtszPhotoImage.blankcCs|j|jdd|S)zReturn the value of OPTION.rr-ro)rerr r r rszPhotoImage.cgetcCs|j|jdd|S)Nrr-rorr r r rszPhotoImage.__getitem__cCs"t|jd}|j|d|j|S)z;Return a new PhotoImage with the same image as this widget.rcopyrqr2rrY)re destImager r r rus zPhotoImage.copyrZcCs4t|jd}|dkr|}|j|d|jd|||S)zReturn a new PhotoImage with the same image as this widget but zoom it with a factor of x in the X direction and y in the Y direction. If y is not given, the default value is the same as x. rrZruz-zoomrvrerUrVrwr r r zooms  zPhotoImage.zoomcCs4t|jd}|dkr|}|j|d|jd|||S)zReturn a new PhotoImage based on the same image as this widget but use only every Xth or Yth pixel. If y is not given, the default value is the same as x. rrZruz -subsamplervrxr r r subsamples  zPhotoImage.subsamplecCs|j|jd||S)z8Return the color (red, green, blue) of the pixel at X,Y.rrorr r r r szPhotoImage.getcCsH|jd|f}|r8|ddkr(|dd}|dt|}|j|dS)zzPut row formatted colors to image starting from position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))putr-torN)r|rYrr2r)rerrrr r r r{ s    zPhotoImage.putcCs@|jd|f}|r|d|f}|r0|dt|}|j|dS)zRWrite image to file FILENAME in FORMAT starting from position FROM_COORDS.writez-format)z-fromNr})refilenameformatZ from_coordsrr r r r~s   zPhotoImage.writec Cs|j|j|jdd||S)z/Return True if the pixel at x,y is transparent. transparencyr)r2rrrYrr r r transparency_get"s zPhotoImage.transparency_getcCs|j|jdd|||dS)z)Set the transparency of the pixel at x,y.rrNro)rerUrVrr r r transparency_set'szPhotoImage.transparency_set)rZ)rZ)N)NN)rArBrCrkrrtrrruryrzrr{r~rrr r r r rqs  rqc@s eZdZdZdidfddZdS) BitmapImagez.Widget which can display images in XBM format.NcKstj|d|||f|dS)zqCreate a bitmap with NAME. Valid resource names: background, data, file, foreground, maskdata, maskfile.rNrrrsr r r r/szBitmapImage.__init__rr r r r r,srcCstdj}||ddS)Nzuse image_names()rrrrr2r.rr2r r r r6s rcCstdj}||ddS)Nzuse image_types()rrrrr r r r;s rc@seZdZdZdifddZddZd+ddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd,d!d"Zd#d$Zd%d&Zd'd(Zd)d*ZdS)-Spinboxzspinbox widget.NcKst||d||dS)aConstruct a spinbox widget with the parent MASTER. STANDARD OPTIONS activebackground, background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, justify, relief, repeatdelay, repeatinterval, selectbackground, selectborderwidth selectforeground, takefocus, textvariable xscrollcommand. WIDGET-SPECIFIC OPTIONS buttonbackground, buttoncursor, buttondownrelief, buttonuprelief, command, disabledbackground, disabledforeground, format, from, invalidcommand, increment, readonlybackground, state, to, validate, validatecommand values, width, wrap, ZspinboxNrrr r r rCszSpinbox.__init__cCs||j|jd|pdS)aReturn a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the character given by index. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window. rNr@rr r r r`s z Spinbox.bboxcCs|j|jd||S)aWDelete one or more elements of the spinbox. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last isn't specified it defaults to first+1, i.e. a single character is deleted. This command returns an empty string. rrrr r r rns zSpinbox.deletecCs|j|jdS)zReturns the spinbox's stringrrrr r r rysz Spinbox.getcCs|j|jd|S)zAlter the position of the insertion cursor. The insertion cursor will be displayed just before the character given by index. Returns an empty string rrrr r r r}szSpinbox.icursorcCs|j|jd||S)z{Returns the name of the widget at position x, y Return value is one of: none, buttondown, buttonup, entry r,rrr r r r,szSpinbox.identifycCs|j|jd|S)z;Returns the numerical index corresponding to index rrrr r r rsz Spinbox.indexcCs|j|jd||S)zDInsert string s at index Returns an empty string. rr)rerrfr r r rszSpinbox.insertcCs|j|jd|S)zCauses the specified element to be invoked The element could be buttondown or buttonup triggering the action associated with it. rrreelementr r r rszSpinbox.invokecGs ||j|jdf|pdS)rrr r@rr r r rs z Spinbox.scancCs |d|S)zRecords x and the current view in the spinbox window; used in conjunction with later scan dragto commands. Typically this command is associated with a mouse button press in the widget. It returns an empty string. rrr]r r r rszSpinbox.scan_markcCs |d|S)aCompute the difference between the given x argument and the x argument to the last scan mark command It then adjusts the view left or right by 10 times the difference in x-coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the spinbox at high speed through the window. The return value is an empty string. rrr]r r r rs zSpinbox.scan_dragtocGs ||j|jdf|pdS)rr r r@rr r r r s zSpinbox.selectioncCs |d|S)aLocate the end of the selection nearest to the character given by index, Then adjust that end of the selection to be at index (i.e including but not going beyond index). The other end of the selection is made the anchor point for future select to commands. If the selection isn't currently in the spinbox, then a new selection is created to include the characters between index and the most recent selection anchor point, inclusive. rr rr r r rs zSpinbox.selection_adjustcCs |dS)zsClear the selection If the selection isn't in this widget then the command has no effect. rrrr r r r szSpinbox.selection_clearcCs|j|jdd|S)zSets or gets the currently selected element. If a spinbutton element is specified, it will be displayed depressed. r rrrr r r selection_elementszSpinbox.selection_elementcCs|d|dS)rrNrrr r r rszSpinbox.selection_fromcCs|j|j|jddS)zUReturn True if there are characters selected in the spinbox, False otherwise.r rr)rr r r rszSpinbox.selection_presentcCs|d||dS)rrNrrr r r rszSpinbox.selection_rangecCs|d|dS)rrNrrr r r rszSpinbox.selection_to)N)N)rArBrCrkrrrrrr,rrrrrrr rr rrrrrr r r r r@s*    rc@seZdZdZdifddZdS) LabelFramezlabelframe widget.NcKst||d||dS)aConstruct a labelframe widget with the parent MASTER. STANDARD OPTIONS borderwidth, cursor, font, foreground, highlightbackground, highlightcolor, highlightthickness, padx, pady, relief, takefocus, text WIDGET-SPECIFIC OPTIONS background, class, colormap, container, height, labelanchor, labelwidget, visual, width Z labelframeNrrr r r rszLabelFrame.__init__rr r r r rsrc@seZdZdZdifddZddZddZeZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZd!ddZeZdd ZdS)" PanedWindowzpanedwindow widget.NcKst||d||dS)aTConstruct a panedwindow widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, height, orient, relief, width WIDGET-SPECIFIC OPTIONS handlepad, handlesize, opaqueresize, sashcursor, sashpad, sashrelief, sashwidth, showhandle, Z panedwindowNrrr r r r szPanedWindow.__init__cKs"|j|jd|f||dS)a+Add a child widget to the panedwindow in a new pane. The child argument is the name of the child widget followed by pairs of arguments that specify how to manage the windows. The possible options and values are the ones accepted by the paneconfigure method. rNrh)rer%rr r r rszPanedWindow.addcCs|j|jd|dS)zRemove the pane containing child from the panedwindow All geometry management options for child will be forgotten. rNr)rer%r r r r'szPanedWindow.removecCs|j|jd||S)aIdentify the panedwindow component at point x, y If the point is over a sash or a sash handle, the result is a two element list containing the index of the sash or handle, and a word indicating whether it is over a sash or a handle, such as {0 sash} or {2 handle}. If the point is over any other part of the panedwindow, the result is an empty list. r,rrr r r r,0s zPanedWindow.identifycGs ||j|jdf|pdS)rproxyr r@rr r r r<s zPanedWindow.proxycCs |dS)zBReturn the x and y pair of the most recent proxy location coordrrr r r proxy_coordAszPanedWindow.proxy_coordcCs |dS)z+Remove the proxy from the display. rrrr r r proxy_forgetFszPanedWindow.proxy_forgetcCs|d||S)z:Place the proxy at the given x and y coordinates. rrrr r r proxy_placeKszPanedWindow.proxy_placecGs ||j|jdf|pdS)rsashr r@rr r r rPs zPanedWindow.sashcCs |d|S)aAReturn the current x and y pair for the sash given by index. Index must be an integer between 0 and 1 less than the number of panes in the panedwindow. The coordinates given are those of the top left corner of the region containing the sash. pathName sash dragto index x y This command computes the difference between the given coordinates and the coordinates given to the last sash coord command for the given sash. It then moves that sash the computed difference. The return value is the empty string. rrrr r r sash_coordUs zPanedWindow.sash_coordcCs |d|S)zRecords x and y for the sash given by index; Used in conjunction with later dragto commands to move the sash. rrrr r r sash_markcszPanedWindow.sash_markcCs|d|||S)z?Place the sash given by index at the given coordinates rr)rerrUrVr r r sash_placejszPanedWindow.sash_placecCs|j|jdf|d|fS)zwQuery a management option for window. Option may be any value allowed by the paneconfigure subcommand panecgetr-r)rer%rr r r roszPanedWindow.panecgetcKsd|dkr|s||jd|St|tr@|s@||jd|d|S|j|jd|f|||dS)a Query or modify the management options for window. If no option is specified, returns a list describing all of the available options for pathName. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. The following options are supported: after window Insert the window after the window specified. window should be the name of a window already managed by pathName. before window Insert the window before the window specified. window should be the name of a window already managed by pathName. height size Specify a height for the window. The height will be the outer dimension of the window including its border, if any. If size is an empty string, or if -height is not specified, then the height requested internally by the window will be used initially; the height may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. minsize n Specifies that the size of the window cannot be made less than n. This constraint only affects the size of the widget in the paned dimension -- the x dimension for horizontal panedwindows, the y dimension for vertical panedwindows. May be any value accepted by Tk_GetPixels. padx n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the X-direction. The value may have any of the forms accepted by Tk_GetPixels. pady n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the Y-direction. The value may have any of the forms accepted by Tk_GetPixels. sticky style If a window's pane is larger than the requested dimensions of the window, this option may be used to position (or stretch) the window within its pane. Style is a string that contains zero or more of the characters n, s, e or w. The string can optionally contains spaces or commas, but they are ignored. Each letter refers to a side (north, south, east, or west) that the window will "stick" to. If both n and s (or e and w) are specified, the window will be stretched to fill the entire height (or width) of its cavity. width size Specify a width for the window. The width will be the outer dimension of the window including its border, if any. If size is an empty string, or if -width is not specified, then the width requested internally by the window will be used initially; the width may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. N paneconfigurer-)rrrrrr2rrrr r r rwsD  zPanedWindow.paneconfigurecCs|j|j|jdS)z+Returns an ordered list of the child panes.panesrgrr r r rszPanedWindow.panes)N)rArBrCrkrrrrr,rrrrrrrrrrZ paneconfigrr r r r r s$   LrcCst}dt}|d7}t||d}|t|d|fddd}|||_t|d|jd}|||| | dS) NzThis is Tcl/Tk version %su This should be a cedilla: çrz Click me!cSs|jjd|jddS)Nz[%s]rr)testr)rqr r r s z_test..)rrZQUIT) ro TclVersionrrrDrrrr!rr)rqrrrrzr r r _tests   r__main__)TN)N)r)r)NNror)VrkenumrrrZtkinter.constantsrer@floatrOZ TkVersionrPrZREADABLEZWRITABLEZ EXCEPTIONcompilerASCIIrr rrr"r+r7rEnumr8rGrlrmrnrrruryrrzrrrrrrarrrrrrrrrorfrgrprurzrrrDrrrrrrr r&r(r*r+r-r.rcrhrkrqrrrrrrrrAr r r r s        ,R  6  q2~ .37?/8$Vt!'2'BT 3C PK!00+__pycache__/filedialog.cpython-38.opt-1.pycnu[U e5d8@sdZddlTddlmZddlmZddlmZddlZddlZiZ GdddZ Gd d d e Z Gd d d e Z Gd ddejZ Gddde ZGddde ZGdddejZddZddZddZd(ddZd)ddZd*d!d"Zd#d$Zd%d&Zed'kr edS)+aUFile selection dialog classes. Classes: - FileDialog - LoadFileDialog - SaveFileDialog This module also presents tk common file dialogues, it provides interfaces to the native file dialogues available in Tk 4.2 and newer, and the directory dialogue available in Tk 8.3 and newer. These interfaces were written by Fredrik Lundh, May 1997. )*)Dialog) commondialog) _setup_dialogNc@seZdZdZdZd$ddZejdddfdd Zd%d d Z d d Z ddZ ddZ ddZ ddZddZd&ddZddZddZd'ddZd d!Zd"d#ZdS)( FileDialogaStandard file selection dialog -- no checks on selected file. Usage: d = FileDialog(master) fname = d.go(dir_or_file, pattern, default, key) if fname is None: ...canceled... else: ...open file... All arguments to go() are optional. The 'key' argument specifies a key in the global dictionary 'dialogstates', which keeps track of the values for the directory and pattern arguments, overriding the values passed in (it does not keep track of the default argument!). If no key is specified, the dialog keeps no memory of previous state. Note that memory is kept even when the dialog is canceled. (All this emulates the behavior of the Macintosh file selection dialogs.) zFile Selection DialogNcCs|dkr|j}||_d|_t||_|j||j|t|jt|j|_|jj t t dt |j|_ |j j t t d|j d|jt |j|_|jj tt d|jd|jt|j|_|jj ttdt|j|_|jj ttdt|jd|jdfd|_|jj tttd|j}|j|dd|dd|jd |j|jd |j|jj|jd fd t|j|_ |j j t!tdt|jd|j dfd|_"|j"j t!ttd|j j|j"d fd |j"}|j"|dd|dd|j"d |j#|j"d |j$t%|jd |j&d|_'|j'j t!dt%|jd|jd|_(|j(j t!tdt%|jd|j)d|_*|j*j td|j+d|j)|jd|j)|jd|j)dS)N)sidefillz)expandrrset)ZexportselectionZyscrollcommand)rr rzzZyview)commandZOK)textr )rZFilter)rr CancelZWM_DELETE_WINDOWzz),titlemaster directoryZTopleveltopZiconnamerZFrameZbotframeZpackZBOTTOMXZEntry selectionZbindok_eventfilterZTOPfilter_commandZmidframeZYESZBOTHZ ScrollbarZfilesbarZRIGHTYZListboxfilesZbindtagsfiles_select_eventfiles_double_eventZconfigZdirsbarZLEFTdirsdirs_select_eventdirs_double_eventZButton ok_commandZ ok_buttonZ filter_buttoncancel_commandZ cancel_buttonZprotocol)selfrrZbtagsr"*/usr/lib64/python3.8/tkinter/filedialog.py__init__4st              zFileDialog.__init__rcCs|r|tkrt|\|_}n2tj|}tj|r<||_ntj|\|_}||j|||| |j |j |j d|_|j|r|\}}|jrtj|j}||ft|<|j |jSN) dialogstatesrospath expanduserisdirsplit set_filter set_selectionrrZ focus_setrZwait_visibilityZgrab_sethowrZmainloop get_filterdirnameZdestroy)r!Z dir_or_filepatterndefaultkeyrr"r"r#gots*           z FileDialog.gocCs||_|jdSr&)r/rquit)r!r/r"r"r#r6szFileDialog.quitcCs |dSr&)rr!eventr"r"r#rszFileDialog.dirs_double_eventcCs@|\}}|jd}tjtj|j|}|||dSNZactive) r0rgetr(r)normpathjoinrr-)r!r8dirpatZsubdirr"r"r#rs  zFileDialog.dirs_select_eventcCs |dSr&rr7r"r"r#rszFileDialog.files_double_eventcCs|jd}||dSr9)rr:r.)r!r8filer"r"r#rs zFileDialog.files_select_eventcCs |dSr&r?r7r"r"r#rszFileDialog.ok_eventcCs||dSr&)r6 get_selectionr!r"r"r#rszFileDialog.ok_commandc Cs&|\}}zt|}Wn tk r:|jYdSX||_||||tj g}g}|D]@}tj ||}tj |r| |qft||rf| |qf|jdt|D]}|jt|q|jdt|D]}|jt|qtj |\} } | tjkrd} || dS)Nrr%)r0r(listdirOSErrorrbellrr-sortpardirr)r<r+appendfnmatchrdeleteENDinsertrr,rAcurdirr.) r!r8r=r>namesZsubdirsZ matchingfilesnamefullnameheadtailr"r"r#rs6        zFileDialog.filter_commandcCsN|j}tj|}|ddtjks4tj|rBtj|d}tj|S)Nr) rr:r(r)r*sepr+r<r,)r!rr"r"r#r0s   zFileDialog.get_filtercCs|j}tj|}|Sr&)rr:r(r)r*r!r@r"r"r#rAs  zFileDialog.get_selectioncCs |dSr&)r6r7r"r"r#r szFileDialog.cancel_commandcCstj|sPz t}Wntk r0d}YnX|rPtj||}tj|}|jdt |j t tj|pttj |pzddS)Nrr) r(r)isabsgetcwdrDr<r;rrJrKrLrM)r!r=r>pwdr"r"r#r-s    zFileDialog.set_filtercCs,|jdt|jttj|j|dS)Nr)rrJrKrLr(r)r<rrUr"r"r#r.szFileDialog.set_selection)N)N)N)N)__name__ __module__ __qualname____doc__rr$r(rMr5r6rrrrrrrr0rAr r-r.r"r"r"r#rs" @    rc@seZdZdZdZddZdS)LoadFileDialogz8File selection dialog which checks that the file exists.zLoad File Selection DialogcCs.|}tj|s |jn ||dSr&)rAr(r)isfilerrEr6rUr"r"r#rs  zLoadFileDialog.ok_commandNrYrZr[r\rrr"r"r"r#r]sr]c@seZdZdZdZddZdS)SaveFileDialogz@File selection dialog which checks that the file may be created.zSave File Selection DialogcCs|}tj|rZtj|r.|jdSt|jdd|fdddd}|j dkrdSn*tj |\}}tj|s|jdS| |dS)Nz Overwrite Existing File QuestionzOverwrite existing file %r?Z questheadr )ZYesr)rr Zbitmapr3Zstringsr) rAr(r)existsr+rrErrZnumr,r6)r!r@drQrRr"r"r#rs&      zSaveFileDialog.ok_commandNr_r"r"r"r#r`sr`c@seZdZddZddZdS)_DialogcCs2zt|jd|jd<Wntk r,YnXdS)N filetypes)tupleoptionsKeyErrorrBr"r"r# _fixoptions,sz_Dialog._fixoptionscCsR|rHz |j}Wntk r"YnXtj|\}}||jd<||jd<||_|S)N initialdirZ initialfile)stringAttributeErrorr(r)r,rffilenamer!widgetresultr)r@r"r"r# _fixresult3s   z_Dialog._fixresultN)rYrZr[rhrpr"r"r"r#rc*srcc@seZdZdZdZddZdS)OpenAsk for a filename to openZtk_getOpenFilecCsxt|trBtdd|D}|r>tj|d\}}||jd<|S|jsjd|jkrj|||j |St |||S)NcSsg|]}t|d|qS)rj)getattr).0rr"r"r# Nsz#Open._fixresult..rrimultiple) isinstancerer(r)r,rfZtkZ wantobjectsrpZ splitlistrcrmr"r"r#rpKs  zOpen._fixresultNrYrZr[r\r rpr"r"r"r#rqFsrqc@seZdZdZdZdS)SaveAsAsk for a filename to save asZtk_getSaveFileN)rYrZr[r\r r"r"r"r#rzZsrzc@seZdZdZdZddZdS) DirectoryzAsk for a directoryZtk_chooseDirectorycCs8|r.z |j}Wntk r"YnX||jd<||_|S)Nri)rjrkrfr)r!rnror"r"r#rpfs  zDirectory._fixresultNryr"r"r"r#r|asr|cKstf|S)rrrqshowrfr"r"r#askopenfilenamewsrcKstf|S)r{)rzr~rr"r"r#asksaveasfilename}srcKsd|d<tf|S)ztAsk for multiple filenames to open Returns a list of filenames or empty list if cancel button selected r rwr}rr"r"r#askopenfilenamessrrucKs tf|}|rt||SdS)z8Ask for a filename to open, and returned the opened fileN)rqr~openmoderfrlr"r"r# askopenfiles rcKs4tf|}|r0g}|D]}|t||q|}|S)zAsk for multiple filenames and return the open file objects returns a list of open file objects or an empty list if cancel selected )rrHr)rrfrZofilesrlr"r"r# askopenfiless rwcKs tf|}|rt||SdS)z;Ask for a filename to save as, and returned the opened fileN)rzr~rrr"r"r# asksaveasfiles rcKstf|S)z-Ask for a directory, and return the file name)r|r~rr"r"r# askdirectorysrc Cst}|t|}|jdd}t|}|jdd}t||d}ddl}z&ddl}||j d| |j }Wnt t fk rYnXtdgd}zt|d }|Wn$td t|d YnXtd ||t} td | |dS)zSimple test program.test)r4zutf-8rNr%)z all filesr)rdruzCould not open File: r rZsaveas)ZTkZwithdrawr]r5r`printsyslocale setlocaleLC_ALL nl_langinfoCODESET ImportErrorrkrrcloseexc_infoencoder) rootfdZloadfileZsavefileencrrZ openfilenamefpZsaveasfilenamer"r"r#rs2      r__main__)ru)ru)r)r\ZtkinterZtkinter.dialogrrZtkinter.simpledialogrr(rIr'rr]r`rcrqrzr|rrrrrrrrrYr"r"r"r#s2   I9  , PK!`Nxx)__pycache__/__init__.cpython-38.opt-2.pycnu[U e5d͕@sddlZddlZddlZejZddlTddlZdZeejZ eej Z ej Z ej Z ejZedZedejZddZdd Zd d Zz ejZWnek rYnXd d Zz ejZWnek rYnXdxddZGdddeejZGdddZdadaddZdyddZ ddZ!dzddZ"da#GdddZ$Gdd d e$Z%Gd!d"d"e$Z&Gd#d$d$e$Z'Gd%d&d&e$Z(d{d'd(Z)e*Z+eZ,d)d*Z-Gd+d,d,Z.Gd-d.d.Z/Gd/d0d0Z0Gd1d2d2Z1Gd3d4d4Z2Gd5d6d6e.e2Z3d|d7d8Z4Gd9d:d:Z5Gd;d<d<Z6Gd=d>d>Z7Gd?d@d@e.Z8GdAdBdBe8e5e6e7Z9GdCdDdDe8e2Z:GdEdFdFe9Z;GdGdHdHe9e0e1ZGdMdNdNe9Z?GdOdPdPe9Z@GdQdRdRe9e0e1ZAGdSdTdTe9ZBGdUdVdVe9ZCGdWdXdXe9ZDGdYdZdZe9ZEGd[d\d\e9ZFGd]d^d^e9ZGGd_d`d`e9e0e1ZHGdadbdbZIGdcddddeCZJGdedfdfZKGdgdhdheKZLGdidjdjeKZMdkdlZNdmdnZOGdodpdpe9e0ZPGdqdrdre9ZQGdsdtdte9ZRdudvZSeTdwkreSdS)}N)*z([\\{}])z([\s])cCsdtt|S)N )joinmap _stringifyvaluer (/usr/lib64/python3.8/tkinter/__init__.py_join8sr cCst|ttfrHt|dkr:t|d}t|rFd|}qdt|}ntt|}|sZd}nbt|rt d|}| dd}t d|}|ddkrd |}n|ddkst |rd|}|S) Nrrz{%s}z{}z\\\1 z\n"\) isinstancelisttuplelenr _magic_researchr strsubreplace _space_rerr r r r=s$          rcCs@d}|D]2}t|ttfr(|t|}q|dk r||f}q|S)Nr )rrr_flatten)seqresitemr r r rVs rc Cst|tr|St|tdtfr$|Si}t|D]^}z||Wq0ttfk r}z(td|| D]\}}|||<qjW5d}~XYq0Xq0|SdS)Nz_cnfmerge: fallback due to:) rdicttyperrupdateAttributeError TypeErrorprintitems)Zcnfscnfcmsgkvr r r _cnfmergees   r*Tc Csz||}t|drtdt|}i}t||D]@\}}t|}|r`|ddkr`|dd}|rl||}|||<q4|S)NzNTcl list representing a dict is expected to contain an even number of elementsr-r) splitlistr RuntimeErroriterzipr) tkr)Z cut_minusconvtitrkeyr r r r _splitdict{s    r6c@seZdZdZeZdZdZeZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)e*j+Z+d&S)' EventType23456789Z10Z11Z12Z13Z14Z15Z16Z17Z18Z19Z20Z21Z22Z23Z24Z25Z26Z27Z28Z29Z30Z31Z32Z33Z34Z35Z36Z37Z38N),__name__ __module__ __qualname__ZKeyPressZKeyZ KeyReleaseZ ButtonPressButtonZ ButtonReleaseZMotionZEnterZLeaveZFocusInZFocusOutZKeymapZExposeZGraphicsExposeZNoExposeZ VisibilityZCreateZDestroyZUnmapZMapZ MapRequestZReparentZ ConfigureZConfigureRequestZGravityZ ResizeRequestZ CirculateZCirculateRequestZPropertyZSelectionClearZSelectionRequestZ SelectionZColormapZ ClientMessageMappingZ VirtualEventZActivateZ DeactivateZ MouseWheelr__str__r r r r r7sPr7c@seZdZddZdS)Eventcsdd|jD|js"d=n|jdkr:t|jd<t|ddsLd=|jdkr^d=n|t|jtr|j}d }g}t|D]\}}|d |>@r| |q|d t |>d @}|s|s| t |d |d<|j dkrd =d }dt|jd|jd fdd|DfS)NcSsi|]\}}|dkr||qS)??r .0r(r)r r r sz"Event.__repr__..charrG send_eventTrstate) ZShiftZLockZControlZMod1ZMod2ZMod3ZMod4ZMod5ZButton1ZButton2ZButton3ZButton4ZButton5r|delta) rLrMkeysymkeycoderKnumrOfocusxywidthheightz <%s event%s>namec3s&|]}|krd||fVqdS)z %s=%sNr )rIr(Zattrsr r sz!Event.__repr__..)__dict__r$rKreprgetattrrMrint enumerateappendrhexrrOr)selfrMZmodssinkeysr rZr __repr__s6       zEvent.__repr__N)r@rArBrhr r r r rFs+rFcCsdadabdS)NF)_support_default_root _default_rootr r r r NoDefaultRootsrkcCs.ts tdts*|r$td|dt}tS)NzINo master specified and tkinter is configured to not support default rootz Too early to z: no default root window)rir.rjTk)whatrootr r r _get_default_root#srocCsdSNr )errr r r _tkerror/srrcCs.z t|}Wntk r YnXt|dSrp)r_ ValueError SystemExit)coder r r _exit4s  rvc@seZdZdZdZdZdddZddZddZd d Z e Z d d Z d dZ ddZ ddZddZddZeZddZddZddZdS)VariablerYNcCs|dk rt|tstd|s&td}||_|j|_|rD||_ndtt |_t d7a |dk rn| |n&|j |j dd|js| |j dS)Nzname must be a stringzcreate variablePY_VARrinfoexists)rrr"ro_rootr1_tk_namer]_varnum initialize getbooleancall_defaultrcmasterr rXr r r __init__Is   zVariable.__init__cCsb|jdkrdS|j|jdd|jr6|j|j|jdk r^|jD]}|j|qFd|_dS)Nryrz)r|rrr}Zglobalunsetvar _tclCommands deletecommandrcrXr r r __del__gs   zVariable.__del__cCs|jSrp)r}rcr r r rEsszVariable.__str__cCs|j|j|Srp)r| globalsetvarr}rcr r r r setwsz Variable.setcCs|j|jSrp)r| globalgetvarr}rr r r get}sz Variable.getcCst|d|jj}tt|}z |j}Wntk r:YnXz||j}Wntk r^YnX|j |||j dkr~g|_ |j ||Srp) CallWrapperr{__call__r]id__func__r!r@r| createcommandrra)rccallbackfcbnamer r r _registers    zVariable._registercCs(||}|jddd|j||f|S)Ntraceaddvariablerr|rr}rcmoderrr r r trace_adds  zVariable.trace_addcCsx|jddd|j|||D] \}}|j|d|kr qtq |j|z|j|Wntk rrYnXdS)Nrremoverr) r|rr} trace_infor-rrrrsrcrrmZcar r r trace_removes  zVariable.trace_removec s4|jjfddt|jddd|jDS)Ncsg|]\}}||fqSr r rHr-r r sz'Variable.trace_info..rryr)r|r-rrr}rr rr rszVariable.trace_infocCs$||}|jdd|j|||S)Nrrrrr r r trace_variables zVariable.trace_variablecCs|jdd|j|||j|d}|D] \}}|j|d|kr.qq.|j|z|j|Wntk rYnXdS)NrZvdeleter) r|rr}r-rrrrrsrr r r trace_vdeletes  zVariable.trace_vdeletecs(fddjjddjDS)Ncsg|]}j|qSr )r|r-rIrTrr r rsz(Variable.trace_vinfo..rZvinfo)r|r-rr}rr rr trace_vinfoszVariable.trace_vinfocCs6t|tstS|j|jko4|jj|jjko4|j|jkSrp)rrwNotImplementedr} __class__r@r|)rcotherr r r __eq__s   zVariable.__eq__)NNN)r@rArBrr|rrrrErrrrrrrrrrrrr r r r rw@s$   rwc@s"eZdZdZdddZddZdS) StringVarrYNcCst||||dSrprwrrr r r rs zStringVar.__init__cCs$|j|j}t|tr|St|Srp)r|rr}rrrr r r rs z StringVar.get)NNNr@rArBrrrr r r r rs rc@s"eZdZdZdddZddZdS)IntVarrNcCst||||dSrprrr r r rs zIntVar.__init__c CsJ|j|j}z|j|WSttfk rDt|j|YSXdSrp)r|rr}getintr"TclErrorr_ getdoublerr r r rs z IntVar.get)NNNrr r r r r s rc@s"eZdZdZdddZddZdS) DoubleVargNcCst||||dSrprrr r r r*s zDoubleVar.__init__cCs|j|j|jSrp)r|rrr}rr r r r6sz DoubleVar.get)NNNrr r r r r&s rc@s.eZdZdZd ddZddZeZddZdS) BooleanVarFNcCst||||dSrprrr r r r?s zBooleanVar.__init__cCs|j|j|j|Srp)r|rr}rrr r r rKszBooleanVar.setcCs:z|j|j|jWStk r4tdYnXdSN invalid literal for getboolean())r|rrr}rrsrr r r rQszBooleanVar.get)NNN)r@rArBrrrrrr r r r r;s  rcCstdj|dS)Nzrun the main loop)ror1mainloop)rfr r r rYsrcCs4ztdj|WStk r.tdYnXdS)Nzuse getboolean()r)ror1rrrsrdr r r rcsrc@seZdZdZdZddZddZd0ddZdd Zd d Z d1d dZ e Z d2ddZ d3ddZ d4ddZd5ddZddZddZddZddZeZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd6d.d/Zd0d1Zd2d3Zd7d5d6Zd7d8Z d9d:Z!d;d<Z"d=d>Z#d?d@Z$dAdBZ%dCdDZ&dEdFZ'd8dGdHZ(dIdJZ)dKdLZ*d9dMdNZ+dOdPZ,dQdRZ-dSdTZ.dUdVZ/dWdXZ0dYdZZ1d:d[d\Z2d;d]d^Z3e3Z4ddkdlZ;dmdnZdsdtZ?dudvZ@dwdxZAd?dydzZBd{d|ZCd}d~ZDddZEddZFd@ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXddZYddZZddZ[ddZ\ddZ]dAddZ^ddZ_ddZ`ddZaddZbddZcddZdddZeddÄZfddńZgddDŽZhddɄZidBdd˄ZjdCdd΄ZkdDddЄZldEdd҄ZmdFddԄZnddքZodGdd؄ZpddڄZqdHdd܄ZrddބZsddZtddZuddZvddZwexddZydIddZzddZ{e{Z|dJddZ}e}Z~ddZdZdeZddZddZddZddZddZdKddZeZddZeZddZddZddZddZd gZefd d ZeZd d ZeZddZdLddZeZdMddZeZddZddZifddZeZddZefddZifddZeZd d!ZeZdNd"d#Zd$d%Zd&d'Zd(d)ZdOd*d+Zd,d-Zd.d/ZdS(PMiscNcCs,|jdk r(|jD]}|j|qd|_dSrp)rr1rrr r r destroyxs  z Misc.destroycCs6|j|z|j|Wntk r0YnXdSrp)r1rrrrsrr r r rs  zMisc.deletecommandcCs|j|jdd|S)Nrtk_strictMotif)r1rrrcbooleanr r r rs  zMisc.tk_strictMotifcCs|jddS)N tk_bisquer1rrr r r rszMisc.tk_bisquecOs(|jdt|tt|dS)N) tk_setPalette)r1rrrr$rcargskwr r r rs zMisc.tk_setPaletterxcCs|jdd|dS)Ntkwaitrrrr r r wait_variableszMisc.wait_variablecCs"|dkr |}|jdd|jdS)Nrwindowr1r_wrcrr r r wait_windowszMisc.wait_windowcCs"|dkr |}|jdd|jdS)NrZ visibilityrrr r r wait_visibilityszMisc.wait_visibility1cCs|j||dSrp)r1setvar)rcrXr r r r rsz Misc.setvarcCs |j|Srp)r1getvarrr r r rsz Misc.getvarc CsBz|j|WStk r<}ztt|W5d}~XYnXdSrp)r1rrrsrrcrdexcr r r rsz Misc.getintc CsBz|j|WStk r<}ztt|W5d}~XYnXdSrp)r1rrrsrrr r r rszMisc.getdoublecCs0z|j|WStk r*tdYnXdSr)r1rrrs)rcrdr r r rszMisc.getbooleancCs|jd|jdSNrSrrr r r focus_setszMisc.focus_setcCs|jdd|jdS)NrSz-forcerrr r r focus_forceszMisc.focus_forcecCs&|jd}|dks|sdS||S)NrSnone)r1r _nametowidgetrr r r focus_gets  zMisc.focus_getcCs,|jdd|j}|dks|s"dS||S)NrS -displayofrr1rrrrr r r focus_displayofs zMisc.focus_displayofcCs,|jdd|j}|dks|s"dS||S)NrSz-lastforrrrr r r focus_lastfors zMisc.focus_lastforcCs|jddS)Ntk_focusFollowsMouserrr r r rszMisc.tk_focusFollowsMousecCs"|jd|j}|sdS||S)N tk_focusNextrrr r r r s zMisc.tk_focusNextcCs"|jd|j}|sdS||S)N tk_focusPrevrrr r r rszMisc.tk_focusPrevcsNsjd|dSfdd}j|_|jd|SdS)Naftercs8z W5zWntk r0YnXXdSrp)rrr rfuncrXrcr r callit,s  zMisc.after..callit)r1rr@r)rcZmsrrrr rr r s z Misc.aftercGs|jd|f|S)NZidle)r)rcrrr r r after_idle8szMisc.after_idlecCsd|s tdz.|jdd|}|j|d}||Wntk rNYnX|jdd|dS)Nz?id must be a valid identifier returned from after or after_idlerryrZcancel)rsr1rr-rr)rcrdataZscriptr r r after_cancel@szMisc.after_cancelrcCs|jd||dS)N)bell)r1r _displayofrc displayofr r r rQsz Misc.bellcKsdd|krN|jdkrNz d|d<|jd||WStk rL|d=YnX|jd||S)Nrx11 UTF8_STRING) clipboardr)_windowingsystemr1r_optionsrrcrr r r clipboard_getVs zMisc.clipboard_getcKs,d|kr|j|d<|jd||dS)Nr)rclearrr1rrrr r r clipboard_clearms zMisc.clipboard_clearcKs4d|kr|j|d<|jd||d|fdS)Nr)rra--r)rcstringrr r r clipboard_appendus  zMisc.clipboard_appendcCs$|jdd|j}|sdS||S)NgrabZcurrentrrr r r grab_currentszMisc.grab_currentcCs|jdd|jdS)Nrreleaserrr r r grab_releaseszMisc.grab_releasecCs|jdd|jdS)Nrrrrr r r grab_setsz Misc.grab_setcCs|jddd|jdS)Nrrz-globalrrr r r grab_set_globalszMisc.grab_set_globalcCs"|jdd|j}|dkrd}|S)Nrstatusrr)rcrr r r grab_statusszMisc.grab_statuscCs|jdd|||dS)Noptionrr)rcpatternr priorityr r r option_addszMisc.option_addcCs|jdddS)Nrrrrr r r option_clearszMisc.option_clearcCs|jdd|j||S)Nrrr)rcrX classNamer r r option_getszMisc.option_getcCs|jdd||dS)NrZreadfiler)rcZfileNamerr r r option_readfileszMisc.option_readfilecKs,d|kr|j|d<|jd||dS)Nr) selectionrrrr r r selection_clears zMisc.selection_clearcKsvd|kr|j|d<d|kr`|jdkr`z d|d<|jd||WStk r^|d=YnX|jd||S)Nrrrr)r r)rrr1rrrrr r r selection_gets   zMisc.selection_getcKs.||}|jd|||j|fdS)N)r Zhandle)rr1rrr)rccommandrrXr r r selection_handles zMisc.selection_handlecKs"|jd|||jfdS)Nr Zown)r1rrrrr r r selection_owns zMisc.selection_owncKs:d|kr|j|d<|jd||}|s0dS||S)Nrr)rr1rrr)rcrrXr r r selection_own_gets  zMisc.selection_own_getcGs|jd||f|S)Nsendr)rcZinterpcmdrr r r rsz Misc.sendcCs|jd|j|dSNlowerr)rc belowThisr r r rsz Misc.lowercCs|jd|j|dSNraiser)rc aboveThisr r r tkraisesz Misc.tkraisecCs(d|||f}|j|j|S)N)winfoZatom)rr1rr)rcrXrrr r r winfo_atomszMisc.winfo_atomcCs d|||f}|j|S)N)rZatomnamerr1rrcrrrr r r winfo_atomname s zMisc.winfo_atomnamecCs|j|jdd|jS)NrZcellsr1rrrrr r r winfo_cellsszMisc.winfo_cellsc CsRg}|j|jdd|jD].}z|||Wqtk rJYqXq|S)Nrchildren)r1r-rrrarKeyError)rcresultchildr r r winfo_childrenszMisc.winfo_childrencCs|jdd|jS)Nrclassrrr r r winfo_class#szMisc.winfo_classcCs|j|jdd|jS)NrZ colormapfullr1rrrrr r r winfo_colormapfull'szMisc.winfo_colormapfullcCs4d||||f}|j|}|s*dS||S)N)rZ containing)rr1rr)rcZrootXZrootYrrrXr r r winfo_containing,s zMisc.winfo_containingcCs|j|jdd|jS)NrZdepthrrr r r winfo_depth4szMisc.winfo_depthcCs|j|jdd|jS)Nrrzrrr r r winfo_exists8szMisc.winfo_existscCs|j|jdd|j|S)NrZfpixelsr1rrrrcnumberr r r winfo_fpixels=s  zMisc.winfo_fpixelscCs|jdd|jS)Nrgeometryrrr r r winfo_geometryCszMisc.winfo_geometrycCs|j|jdd|jS)NrrWrrr r r winfo_heightGszMisc.winfo_heightcCst|jdd|jdS)Nrrr)r_r1rrrr r r winfo_idLsz Misc.winfo_idcCs"d||}|j|j|S)N)rZinterps)rr1r-r)rcrrr r r winfo_interpsPszMisc.winfo_interpscCs|j|jdd|jS)NrZismappedrrr r r winfo_ismappedUszMisc.winfo_ismappedcCs|jdd|jS)NrZmanagerrrr r r winfo_managerZszMisc.winfo_managercCs|jdd|jS)NrrXrrr r r winfo_name^szMisc.winfo_namecCs|jdd|jS)Nrparentrrr r r winfo_parentbszMisc.winfo_parentcCs d|||f}|j|S)N)rpathnamerrr r r winfo_pathnamefs zMisc.winfo_pathnamecCs|j|jdd|j|S)NrZpixelsrr.r r r winfo_pixelslszMisc.winfo_pixelscCs|j|jdd|jS)NrZpointerxrrr r r winfo_pointerxqszMisc.winfo_pointerxcCs||jdd|jS)NrZ pointerxy_getintsr1rrrr r r winfo_pointerxyvszMisc.winfo_pointerxycCs|j|jdd|jS)NrZpointeryrrr r r winfo_pointery{szMisc.winfo_pointerycCs|j|jdd|jS)NrZ reqheightrrr r r winfo_reqheightszMisc.winfo_reqheightcCs|j|jdd|jS)NrZreqwidthrrr r r winfo_reqwidthszMisc.winfo_reqwidthcCs||jdd|j|S)NrZrgbr?)rcZcolorr r r winfo_rgbszMisc.winfo_rgbcCs|j|jdd|jS)NrZrootxrrr r r winfo_rootxszMisc.winfo_rootxcCs|j|jdd|jS)NrZrootyrrr r r winfo_rootyszMisc.winfo_rootycCs|jdd|jS)Nrscreenrrr r r winfo_screenszMisc.winfo_screencCs|j|jdd|jS)NrZ screencellsrrr r r winfo_screencellsszMisc.winfo_screencellscCs|j|jdd|jS)NrZ screendepthrrr r r winfo_screendepthszMisc.winfo_screendepthcCs|j|jdd|jS)NrZ screenheightrrr r r winfo_screenheightszMisc.winfo_screenheightcCs|j|jdd|jS)NrZscreenmmheightrrr r r winfo_screenmmheightszMisc.winfo_screenmmheightcCs|j|jdd|jS)NrZ screenmmwidthrrr r r winfo_screenmmwidthszMisc.winfo_screenmmwidthcCs|jdd|jS)NrZ screenvisualrrr r r winfo_screenvisualszMisc.winfo_screenvisualcCs|j|jdd|jS)NrZ screenwidthrrr r r winfo_screenwidthszMisc.winfo_screenwidthcCs|jdd|jS)NrZserverrrr r r winfo_serverszMisc.winfo_servercCs||jdd|jS)Nrtoplevel)rr1rrrr r r winfo_toplevels  zMisc.winfo_toplevelcCs|j|jdd|jS)NrZviewablerrr r r winfo_viewableszMisc.winfo_viewablecCs|jdd|jS)Nrvisualrrr r r winfo_visualszMisc.winfo_visualcCs|jdd|jS)NrZvisualidrrr r r winfo_visualidszMisc.winfo_visualidFcsHjddj|rdnd}fddj|D}fdd|DS)NrZvisualsavailable includeidscsg|]}j|qSr )r1r-rrr r rsz/Misc.winfo_visualsavailable..csg|]}|qSr )_Misc__winfo_parseitemrrr r rs)r1rrr-)rcrXrr rr winfo_visualsavailables  zMisc.winfo_visualsavailablecCs$|ddtt|j|ddS)Nr)rr_Misc__winfo_getint)rcr3r r r Z__winfo_parseitemszMisc.__winfo_parseitemcCs t|dS)Nr)r_rcrTr r r Z__winfo_getintszMisc.__winfo_getintcCs|j|jdd|jS)NrZ vrootheightrrr r r winfo_vrootheightszMisc.winfo_vrootheightcCs|j|jdd|jS)NrZ vrootwidthrrr r r winfo_vrootwidthszMisc.winfo_vrootwidthcCs|j|jdd|jS)NrZvrootxrrr r r winfo_vrootxszMisc.winfo_vrootxcCs|j|jdd|jS)NrZvrootyrrr r r winfo_vrooty szMisc.winfo_vrootycCs|j|jdd|jS)NrrVrrr r r winfo_widthszMisc.winfo_widthcCs|j|jdd|jS)NrrTrrr r r winfo_xsz Misc.winfo_xcCs|j|jdd|jS)NrrUrrr r r winfo_ysz Misc.winfo_ycCs|jddS)Nr rrr r r r sz Misc.updatecCs|jdddS)Nr Z idletasksrrr r r update_idletasks$szMisc.update_idletaskscCs6|dkr |j|jd|jS|jd|j|dS)Nbindtagsr1r-rr)rcZtagListr r r re*s z Misc.bindtagsrcCst|tr |j|||fnn|rd|||j|}d|r>dp@d||jf}|j|||f|S|rz|j||fS|j|j|SdS)Nz"%sif {"[%s %s]" == "break"} break +rY)rrr1rr _substitute_subst_format_strr-)rcrmsequencerr needcleanupfuncidrr r r _bind7s"   z Misc._bindcCs|d|jf|||SNbindrmrrcrjrrr r r roIs'z Misc.bindcCs&|jd|j|d|r"||dSNrorYr1rrr)rcrjrlr r r unbindrsz Misc.unbindcCs|d|||dS)N)roallrrmrqr r r bind_allysz Misc.bind_allcCs|jdd|ddS)NrorurYr)rcrjr r r unbind_allszMisc.unbind_allcCs|d|f|||dS)Nrorrv)rcrrjrrr r r bind_classszMisc.bind_classcCs|jd||ddSrrr)rcrrjr r r unbind_classszMisc.unbind_classcCs|j|dSrp)r1r)rcrfr r r rsz Misc.mainloopcCs|jdSrp)r1quitrr r r r{sz Misc.quitcCs"|rtt|jj|j|SdSrp)rrr1rr-rcrr r r r@sz Misc._getintscCs"|rtt|jj|j|SdSrp)rrr1rr-r|r r r _getdoublesszMisc._getdoublescCs|r|j|SdSrp)r1rr|r r r _getbooleanszMisc._getbooleancCs"|r d|fS|dkrd|jfSdS)Nrr rrr r r rs  zMisc._displayofcCsBz |jWStk r<|jdd}|_|YSXdS)Nr1Zwindowingsystem)r{Z_windowingsystem_cachedr!r1r)rcZwsr r r rs   zMisc._windowingsystemcCs|rt||f}nt|}d}|D]\}}|dk r&|ddkrN|dd}t|rb||}n^t|ttfrg}|D]<}t|tr|t |qxt|t r|t |qxqqxd |}|d||f}q&|S)Nr _rr,) r*r$callablerrrrr_rarrr)rcr%rrr(r)Znvrr r r rs*     z Misc._optionscCsNt|d}|}|ds.|}|dd}|D]}|s>qJ|j|}q2|S)N.rr)rsplitr{r!)rcrXwrfr r r nametowidgets  zMisc.nametowidgetcCst|||j}tt|}z |j}Wntk r8YnXz||j}Wntk r\YnX|j|||r|j dkrg|_ |j ||Srp) rrr]rrr!r@r1rrra)rcrsubstrkrrXr r r rs     zMisc._registercCs|}|jr|j}q|Srpr)rcrr r r r{sz Misc._root)z%#z%bz%fz%hz%kz%sz%tz%wz%xz%yz%Az%Ez%Kz%Nz%Wz%Tz%Xz%Yz%Drcst|t|jkr|S|jj}|jjfdd}|\}}}}}} } } } } }}}}}}}}}t}||_|||_z|||_Wnt k rYnX|||_ |||_ || |_ || |_ || |_|| |_|| |_||_z|||_Wnt k r YnX||_|||_zt||_Wntk rF||_YnXz|||_Wntk rt||_YnX|||_|||_z||_Wn tt fk rd|_YnX|fS)Nc s,z |WSttfk r&|YSXdSrp)rsrrrr r getint_events z&Misc._substitute..getint_eventr)r _subst_formatr1rrrFserialrRrSrrWrQrMtimerVrTrUrKrLrPZ keysym_numr7rrsrwidgetr"Zx_rootZy_rootrO)rcrrrZnsignbrhr(rdr3rrTrUAEKNWTXYDer rr rh sT *               zMisc._substitutecCs(t\}}}|}||||dSrp)sysexc_infor{report_callback_exception)rcrvaltbrnr r r _report_exceptionHszMisc._report_exceptioncGs\i}|j|jj|D]>}|j|}|dddf|dd||ddd<q|SNrrr1r-r)rcrr%rTr r r _getconfigureNs  0zMisc._getconfigurecGs2|j|jj|}|dddf|ddSrr)rcrrTr r r _getconfigure1VszMisc._getconfigure1cCs|rt||f}n |rt|}|dkr:|t|j|fSt|tr^|t|j|d|fS|jt|j|f| |dS)Nr,) r*rrrrrrr1rr)rcrr%rr r r _configureZs zMisc._configurecKs|d||S)N configurerrcr%rr r r rgszMisc.configurecCs|j|jdd|SNcgetr,rrcr5r r r rrsz Misc.cgetcCs|||idSrp)rrcr5r r r r __setitem__xszMisc.__setitem__cs*|jjfdd|j|jdDS)Ncs g|]}|dddqS)rrNr rrr r r~szMisc.keys..rrfrr rr rg{s z Misc.keyscCs|jSrprrr r r rEsz Misc.__str__cCsd|jj|jj|jfS)Nz<%s.%s object %s>)rrArBrrr r r rhs z Misc.__repr___noarg_cCs:|tjkr"||jdd|jS|jdd|j|dS)Npack propagaterrr~r1rrrcflagr r r pack_propagates  zMisc.pack_propagatecs(fddjjddjDS)Ncsg|]}|qSr rrrr r rsz$Misc.pack_slaves..rslavesrfrr rr pack_slavess  zMisc.pack_slavescs(fddjjddjDS)Ncsg|]}|qSr rrrr r rsz%Misc.place_slaves..placerrfrr rr place_slavess zMisc.place_slavescCs|jdd|j|dS)Ngridanchorr)rcrr r r grid_anchorszMisc.grid_anchorcCsZdd|jf}|dk r(|dk r(|||f}|dk rD|dk rD|||f}||jj|pXdS)Nrbbox)rr@r1r)rccolumnrowZcol2Zrow2rr r r grid_bboxs   zMisc.grid_bboxc Csht|ttjfrdz:t|}|s$WdSd|kr:|j|WS|j|WSWnttfk rbYnX|S)Nr) rr_tkinterZTcl_Objr1rrrsr)rcr Zsvaluer r r _gridconvvalueszMisc._gridconvvaluecCst|trJ|sJ|dddkr*|dd}|dddkrBd|}|f}n |||}|s|t|j|jd||j||jdS|jd||j|f|}t|dkr||SdS)Nrrrr,r)r2) rrrr6r1rrrr)rcr indexr%roptionsrr r r _grid_configures(    zMisc._grid_configurecKs|d|||S)Ncolumnconfigurerrcrr%rr r r grid_columnconfigureszMisc.grid_columnconfigurec Cs ||jdd|j||pdS)Nrlocationr?rcrTrUr r r grid_locationszMisc.grid_locationcCs:|tjkr"||jdd|jS|jdd|j|dS)Nrrrrr r r grid_propagates  zMisc.grid_propagatecKs|d|||S)N rowconfigurerrr r r grid_rowconfigureszMisc.grid_rowconfigurecCs||jdd|jpdS)Nrsizer?rr r r grid_sizes zMisc.grid_sizecsZd}|dk r|d|f}|dk r,|d|f}fddjjddjf|DS)Nr z-rowz-columncsg|]}|qSr rrrr r r(sz$Misc.grid_slaves..rrrf)rcrrrr rr grid_slaves s    zMisc.grid_slavescGsdd|f|}|j|dS)Neventrrrcvirtual sequencesrr r r event_add/szMisc.event_addcGsdd|f|}|j|dS)Nrdeleterrr r r event_delete6szMisc.event_deletecKsDdd|j|f}|D]\}}|d|t|f}q|j|dS)NrZgenerate-%s)rr$rr1r)rcrjrrr(r)r r r event_generate;szMisc.event_generatecCs|j|jdd|S)Nrryr)rcrr r r event_infoDszMisc.event_infocCs|j|jddSNimagenamesrrr r r image_namesLszMisc.image_namescCs|j|jddS)Nrtypesrrr r r image_typesPszMisc.image_types)N)rx)N)N)rxr)rx)N)r)N)N)N)N)r)r)r)r)r)F)N)r)NNN)N)NNN)NNN)r)N)Nr)N)N)NNNN)NN)N)r@rArB_last_child_idsrrrrrrrZwaitvarrrrrrrrrrSrrrrrrrrrrrrrrrrrrrrrrrr r r rrrrrliftrrr r%r'r)r*r+r,r0r2r3r4r5r6r7r8r:r<r=r>rArBrCrDrErFrGrIrJrKrLrMrNrOrPrQrSrTrVrWrZrYr[r]r^r_r`rarbrcr rdrermrortrwrxryrzrr{r@r}r~rpropertyrrrrrregisterr{rrrirhrrrrrconfigr __getitem__rrgrErhrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rmsN                          )       =                  rc@seZdZddZddZdS)rcCs||_||_||_dSrp)rrr)rcrrrr r r rYszCallWrapper.__init__cGsLz|jr|j|}|j|WStk r2Yn|jYnXdSrp)rrrtrrrcrr r r r_s  zCallWrapper.__call__Nr@rArBrrr r r r rUsrc@s$eZdZddZddZddZdS)XViewcGs(|jj|jdf|}|s$||SdS)Nxviewr1rrr}rcrrr r r rosz XView.xviewcCs|j|jdd|dS)Nrmovetorrcfractionr r r xview_movetouszXView.xview_movetocCs|j|jdd||dS)Nrscrollrrcr/rmr r r xview_scrollzszXView.xview_scrollN)r@rArBrrrr r r r rksrc@s$eZdZddZddZddZdS)YViewcGs(|jj|jdf|}|s$||SdS)Nyviewrrr r r rsz YView.yviewcCs|j|jdd|dS)Nrrrrr r r yview_movetoszYView.yview_movetocCs|j|jdd||dS)Nrrrrr r r yview_scrollszYView.yview_scrollN)r@rArBrrrr r r r rsrc@seZdZdAddZeZddZeZdBddZeZdd Z e Z dCd d Z e Z d d Z e ZdDddZeZddZeZddZeZdEddZeZdFddZeZdGddZeZdHddZeZddZeZdIddZeZ dJd d!Z!e!Z"dKd#d$Z#e#Z$dLd%d&Z%e%Z&dMd'd(Z'e'Z(d)d*Z)e)Z*dNd+d,Z+e+Z,dOd-d.Z-e-Z.dPd/d0Z/e/Z0dQd1d2Z1e1Z2dRd3d4Z3e3Z4dSd5d6Z5e5Z6dTd7d8Z7e7Z8dUd9d:Z9e9Z:dVd;d<Z;e;ZZ=e=Z>d?d@Z?e?Z@dS)XWmNc Cs ||jdd|j||||S)Nwmaspectr?)rcZminNumerZminDenomZmaxNumerZmaxDenomr r r wm_aspectsz Wm.wm_aspectcGsdd|jf|}|j|S)Nr attributes)rr1rrr r r wm_attributesszWm.wm_attributescCs|jdd|j|S)Nrclientrrr r r wm_clientsz Wm.wm_clientcsZt|dkr|f}ddjf|}|r4j|n"fddjj|DSdS)Nrrcolormapwindowscsg|]}|qSr rrrr r rsz)Wm.wm_colormapwindows..)rrr1rr-)rcZwlistrr rr wm_colormapwindowss  zWm.wm_colormapwindowscCs|jdd|j|S)Nrr rrr r r wm_commandsz Wm.wm_commandcCs|jdd|jS)Nr deiconifyrrr r r wm_deiconifyszWm.wm_deiconifycCs|jdd|j|S)Nr focusmodelr)rcZmodelr r r wm_focusmodelszWm.wm_focusmodelcCs|jdd|dS)Nrforgetrrr r r wm_forgetsz Wm.wm_forgetcCs|jdd|jS)Nrframerrr r r wm_framesz Wm.wm_framecCs|jdd|j|S)Nrr1r)rcZ newGeometryr r r wm_geometryszWm.wm_geometryc Cs ||jdd|j||||S)Nrrr?)rcZ baseWidthZ baseHeightZwidthIncZ heightIncr r r wm_grids z Wm.wm_gridcCs|jdd|j|S)NrgrouprrcZpathNamer r r wm_group sz Wm.wm_groupcCs2|r|jdd|jd|S|jdd|j|SdS)Nr iconbitmap-defaultr)rcbitmapdefaultr r r wm_iconbitmaps zWm.wm_iconbitmapcCs|jdd|jS)Nriconifyrrr r r wm_iconify$sz Wm.wm_iconifycCs|jdd|j|S)Nriconmaskr)rcrr r r wm_iconmask*szWm.wm_iconmaskcCs|jdd|j|S)Nriconnamer)rcZnewNamer r r wm_iconname1szWm.wm_iconnameFcGs<|r |jjdd|jdf|n|jjdd|jf|dS)Nr iconphotorr)rcrrr r r wm_iconphoto8szWm.wm_iconphotoc Cs||jdd|j||S)Nr iconpositionr?rr r r wm_iconpositionSs zWm.wm_iconpositioncCs|jdd|j|S)Nr iconwindowrrr r r wm_iconwindow[szWm.wm_iconwindowcCs|jdd|dS)Nrmanager)rcrr r r wm_managebsz Wm.wm_managec Cs||jdd|j||S)Nrmaxsizer?rcrVrWr r r wm_maxsizejs z Wm.wm_maxsizec Cs||jdd|j||S)Nrminsizer?r&r r r wm_minsizess z Wm.wm_minsizecCs||jdd|j|S)Nroverrideredirect)r~r1rrrr r r wm_overrideredirect|s  zWm.wm_overrideredirectcCs|jdd|j|S)Nr positionfromrrcZwhor r r wm_positionfromszWm.wm_positionfromcCs.t|r||}n|}|jdd|j||S)Nrprotocol)rrr1rr)rcrXrr r r r wm_protocols zWm.wm_protocolcCs|jdd|j||S)Nr resizablerr&r r r wm_resizableszWm.wm_resizablecCs|jdd|j|S)Nrsizefromrr-r r r wm_sizefromszWm.wm_sizefromcCs|jdd|j|S)NrrMr)rcZnewstater r r wm_statesz Wm.wm_statecCs|jdd|j|S)Nrtitlerr|r r r wm_titlesz Wm.wm_titlecCs|jdd|j|S)Nr transientr)rcrr r r wm_transientszWm.wm_transientcCs|jdd|jS)Nrwithdrawrrr r r wm_withdrawszWm.wm_withdraw)NNNN)N)N)N)N)NNNN)N)NN)N)N)F)NN)N)NN)NN)N)N)NN)NN)N)N)N)N)Ar@rArBrrrrrrrrrr rrrrr r r r r r1rrrrrrrrrrrrrrr rr"r!r$r#r'r%r)r(r+r*r.r,r0r/r2r1r4r3r5rMr7r6r9r8r;r:r r r r rs                        rc@sJeZdZdZdddZddZd d Zd d Zd dZddZ ddZ dS)rlrNrrc Csd|_i|_d|_d|_|dkrZddl}|jtjd}|j |\}}|dkrZ||}d} t |||| t ||||_|r| tjjs|||dS)NFr)z.pyz.pyc)rr! _tkloadedr1ospathbasenamerargvsplitextrcreate wantobjects_loadtkflagsignore_environment readprofile) rc screenNamebaseNameruseTksyncZuser=Zext interactiver r r rs z Tk.__init__cCs|js|j|dSrp)r<r1loadtkrDrr r r rMs z Tk.loadtkcCsd|_|jd}|tjkr.tdtj|ft|jd}|tjkrZtdtj|f|jdkrjg|_|j dt |j dt |j d|j dt rts|a|d|jdS) NT tk_versionz4tk.h version (%s) doesn't match libtk.a version (%s) tcl_versionz6tcl.h version (%s) doesn't match libtcl.a version (%s)ZtkerrorexitWM_DELETE_WINDOW)r<r1rr TK_VERSIONr.r TCL_VERSIONrrrrrvrarirjr/r)rcrNrOr r r rDs(      z Tk._loadtkcCsJt|jD] }|q|jd|jt|trFt |krFda dSNr) rr!valuesrr1rrrrirjrcr&r r r r s    z Tk.destroyc Csddl}d|jkr|jd}n|j}|j|d|}|j|d|}|j|d|}|j|d|}d|i} td| |j|r|jd||j|rtt | | |j|r|jd||j|rtt | | dS)NrHOMEz.%s.tclz.%s.pyrczfrom tkinter import *source) r=environcurdirr>rexecisfiler1ropenread) rcrIrr=homeZ class_tclZclass_pyZbase_tclZbase_pydirr r r rG s$      zTk.readprofilecCs:ddl}tdtjd|t_|t_|t_||||dS)NrzException in Tkinter callback)file) tracebackr#rstderr last_type last_valuelast_tracebackprint_exception)rcrrrrbr r r r$ s zTk.report_callback_exceptioncCs t|j|Srp)r^r1)rcattrr r r __getattr__0 szTk.__getattr__)NNrlrrN) r@rArBrrrMrDrrGrrir r r r rls   rlcCst||||Srp)rl)rHrIrrJr r r TclC srjc@sPeZdZifddZeZZZddZeZddZ e Z e j Z Z e jZZdS)PackcKs$|jdd|jf|||dS)Nrrr1rrrrr r r pack_configureL s   zPack.pack_configurecCs|jdd|jdS)Nrr rrr r r pack_forgetb szPack.pack_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)Nrryinr6r1rrrrcdr r r pack_infoh szPack.pack_infoN)r@rArBrmrrrrnr rsryrrrrrr r r r rkG s   rkc@sFeZdZifddZeZZZddZeZddZ e Z e j Z Z dS)PlacecKs$|jdd|jf|||dS)Nrrrlrr r r place_configurez s   zPlace.place_configurecCs|jdd|jdS)Nrr rrr r r place_forget szPlace.place_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)Nrryrorprqr r r place_info szPlace.place_infoN)r@rArBrurrrrvr rwryrrrr r r r rtu s  rtc@seZdZifddZeZZZejZ Zej Z Z ddZ e Z ddZddZeZejZZejZZejZZejZZejZZd S) GridcKs$|jdd|jf|||dS)Nrrrlrr r r grid_configure s   zGrid.grid_configurecCs|jdd|jdS)Nrr rrr r r grid_forget szGrid.grid_forgetcCs|jdd|jdS)Nrrrrr r r grid_remove szGrid.grid_removecCs8t|j|jdd|j}d|kr4||d|d<|S)Nrryrorprqr r r grid_info szGrid.grid_infoN)r@rArBryrrrrrrrrrzr r{r|ryrrrrrrrrrrr r r r rx s        rxc@s6eZdZddZiidfddZddZd dd Zd S) BaseWidgetcCs|s t}||_|j|_d}d|kr2|d}|d=|s|jj}|jdkrRi|_|j|dd}||j|<|dkrd|f}n d||f}||_|j dkrd||_ n|j d||_ i|_ |j|jj kr|jj |j ||jj |j<dS)NrXrrz!%sz!%s%dr) rorr1rr@rrrr}rr!r)rcrr%rXcountr r r _setup s2       zBaseWidget._setupr c Cs|rt||f}||_t||||jdkr4g|_dd|D}|D]\}}||=qJ|j||jf|| ||D]\}}| ||q~dS)NcSs"g|]\}}t|tr||fqSr )rrrHr r r r s z'BaseWidget.__init__..) r* widgetNamer}rrr$r1rrrr) rcrrr%rextraclassesr(r)r r r r s    zBaseWidget.__init__cCsTt|jD] }|q|jd|j|j|jjkrF|jj|j=t |dSrT) rr!rUrr1rrr}rrrVr r r r s   zBaseWidget.destroycCs|j|j|f|Srpr)rcrXrr r r _do szBaseWidget._doN)r )r@rArBrrrrr r r r r} sr}c@s eZdZdS)WidgetN)r@rArBr r r r r src@seZdZdifddZdS)ToplevelNc Ks|rt||f}d}dD]L}||kr||}|ddkrJd|dd}nd|}|||f}||=qt||d|i||}|||||d|jdS)Nr )rHclass_r&rUZcolormaprrr,rRrQ)r*r}rr{rr6r/r) rcrr%rrZwmkeyroptrnr r r r) s    zToplevel.__init__r@rArBrr r r r r& src@s*eZdZdifddZddZddZdS)rCNcKst||d||dS)NZbuttonrrrcrr%rr r r rG szButton.__init__cCs|j|jddSNflashrrr r r r\ s z Button.flashcCs|j|jdSNinvokerrr r r rh sz Button.invoke)r@rArBrrrr r r r rCD s rCc@seZdZdifddZddZddZdd Zd d Zdvd d ZddZ ddZ ddZ ddZ dwddZ dxddZdyddZdzddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"d{dBdCZ#dDdEZ$dFdGZ%dHdIZ&dJdKZ'dLdMZ(dNdOZ)dPdQZ*dRdSZ+dTdUZ,d|dVdWZ-e-Z.dXdYZ/e/Z0dZd[Z1d}d]d^Z2ifd_d`Z3dadbZ4e4Z5Z6dcddZ7dedfZ8d~dhdiZ9djdkZ:dldmZ;dndoZdtduZ?dS)CanvasNcKst||d||dS)NZcanvasrrr r r rv s zCanvas.__init__cGs|j|jdf|dS)Naddtagrrr r r r sz Canvas.addtagcCs||d|dSNZaboverrcnewtagtagOrIdr r r addtag_above szCanvas.addtag_abovecCs||ddSNrur)rcrr r r addtag_all szCanvas.addtag_allcCs||d|dSNZbelowrrr r r addtag_below szCanvas.addtag_belowcCs||d||||dSNZclosestr)rcrrTrUhalostartr r r addtag_closest szCanvas.addtag_closestcCs||d||||dSNZenclosedrrcrx1y1x2y2r r r addtag_enclosed szCanvas.addtag_enclosedcCs||d||||dSNZ overlappingrrr r r addtag_overlapping szCanvas.addtag_overlappingcCs||d|dSNZwithtagrrr r r addtag_withtag szCanvas.addtag_withtagcGs ||j|jdf|pdSNrr?rr r r r s z Canvas.bboxcCs(|j|jd||d|r$||dSrrrs)rcrrjrlr r r tag_unbind szCanvas.tag_unbindcCs||jd|f|||Srnrp)rcrrjrrr r r tag_bind s zCanvas.tag_bindcCs|j|j|jd||S)Ncanvasxr-)rcZscreenx gridspacingr r r r s  zCanvas.canvasxcCs|j|j|jd||S)Ncanvasyr-)rcZscreenyrr r r r s  zCanvas.canvasycs,fddjjjdf|DS)Ncsg|]}j|qSr )r1rrrr r r sz!Canvas.coords..coordsrfrr rr r s  z Canvas.coordsc Cs\t|}|d}t|ttfr,|dd}ni}|j|jj|jd|f||||S)NrrB) rrrrr1rrrr)rcitemTyperrr%r r r _create s zCanvas._createcOs|d||S)NZarcrrr r r create_arc szCanvas.create_arccOs|d||SNrrrr r r create_bitmap szCanvas.create_bitmapcOs|d||S)Nrrrr r r create_image szCanvas.create_imagecOs|d||S)Nlinerrr r r create_line szCanvas.create_linecOs|d||S)NZovalrrr r r create_oval szCanvas.create_ovalcOs|d||S)NZpolygonrrr r r create_polygon szCanvas.create_polygoncOs|d||S)NZ rectanglerrr r r create_rectangle szCanvas.create_rectanglecOs|d||SNtextrrr r r create_text szCanvas.create_textcOs|d||S)Nrrrr r r create_window szCanvas.create_windowcGs|j|jdf|dS)Ndcharsrrr r r r sz Canvas.dcharscGs|j|jdf|dSNrrrr r r r sz Canvas.deletecGs|j|jdf|dS)Ndtagrrr r r r sz Canvas.dtagcGs ||j|jdf|pdS)Nfindr r?rr r r r s z Canvas.findcCs |d|Srrrcrr r r find_above szCanvas.find_abovecCs |dSrrrr r r find_all szCanvas.find_allcCs |d|Srrrr r r find_below szCanvas.find_belowcCs|d||||Srr)rcrTrUrrr r r find_closest szCanvas.find_closestcCs|d||||Srrrcrrrrr r r find_enclosed& szCanvas.find_enclosedcCs|d||||Srrrr r r find_overlapping+ szCanvas.find_overlappingcCs |d|Srrrr r r find_withtag0 szCanvas.find_withtagcGs|j|jdf|Srrrr r r rS4 sz Canvas.focuscGs|j|j|jdf|S)Ngettagsrfrr r r r8 szCanvas.gettagscGs|j|jdf|dSNicursorrrr r r r= szCanvas.icursorcGs|j|j|jdf|SNrrrr r r rB sz Canvas.indexcGs|j|jdf|dSNinsertrrr r r rF sz Canvas.insertcCs|j|jdf|d|fSNitemcgetr,r)rcrrr r r rK szCanvas.itemcgetcKs|d|f||SN itemconfigurerrcrr%rr r r rP szCanvas.itemconfigurecGs|j|jdf|dSrrrr r r tag_lower_ szCanvas.tag_lowercGs|j|jdf|dS)Nmoverrr r r rf sz Canvas.moverYcCs|j|jd|||dS)Nrr)rcrrTrUr r r rj sz Canvas.movetocKs|j|jdf|||S)N postscriptrlrr r r rs s zCanvas.postscriptcGs|j|jdf|dSrrrr r r tag_raise{ szCanvas.tag_raisecGs|j|jdf|dSNscalerrr r r r sz Canvas.scalecCs|j|jdd||dSNscanmarkrrr r r scan_mark szCanvas.scan_mark cCs|j|jdd|||dSNrdragtor)rcrTrUZgainr r r scan_dragto szCanvas.scan_dragtocCs|j|jdd||dS)Nselectadjustrrcrrr r r select_adjust szCanvas.select_adjustcCs|j|jdddS)Nrrrrr r r select_clear szCanvas.select_clearcCs|j|jdd||dS)Nrfromrrr r r select_from szCanvas.select_fromcCs|j|jddpdS)Nrrrrr r r select_item szCanvas.select_itemcCs|j|jdd||dS)Nrtorrr r r select_to szCanvas.select_tocCs|j|jd|pdSNrrrr r r r sz Canvas.type)NN)N)NNN)N)N)NN)N)rYrY)r)@r@rArBrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrSrrrrrr itemconfigrrrrrrrrrrrrrrrrrr r r r rs sx          rc@sBeZdZdifddZddZddZdd Zd d Zd d ZdS) CheckbuttonNcKst||d||dSNZ checkbuttonrrr r r r s zCheckbutton.__init__cCs|j|jddSNdeselectrrr r r r szCheckbutton.deselectcCs|j|jddSrrrr r r r szCheckbutton.flashcCs|j|jdSrrrr r r r szCheckbutton.invokecCs|j|jddSNrrrr r r r szCheckbutton.selectcCs|j|jddS)Ntogglerrr r r r szCheckbutton.toggle) r@rArBrrrrrrr r r r r s  rc@seZdZdifddZdddZddZdd Zd d Zd d ZddZ ddZ ddZ e Z ddZ e ZddZeZddZeZddZeZddZeZdS)EntryNcKst||d||dS)Nentryrrr r r r s zEntry.__init__cCs|j|jd||dSrrrcfirstZlastr r r r sz Entry.deletecCs|j|jdSNrrrr r r r sz Entry.getcCs|j|jd|dSrrrcrr r r r sz Entry.icursorcCs|j|j|jd|Srrrr r r r s  z Entry.indexcCs|j|jd||dSrr)rcrrr r r r sz Entry.insertcCs|j|jdd|dSrrr\r r r r szEntry.scan_markcCs|j|jdd|dSrrr\r r r r szEntry.scan_dragtocCs|j|jdd|dS)Nr rrrr r r selection_adjust szEntry.selection_adjustcCs|j|jdddSNr rrrr r r r  szEntry.selection_clearcCs|j|jdd|dS)Nr rrrr r r selection_from szEntry.selection_fromcCs|j|j|jddSNr Zpresentr(rr r r selection_present szEntry.selection_presentcCs|j|jdd||dS)Nr rangerrcrendr r r selection_range szEntry.selection_rangecCs|j|jdd|dS)Nr rrrr r r selection_to szEntry.selection_to)N)r@rArBrrrrrrrrrrr rrrrZselect_presentrZ select_ranger rr r r r r s( rc@seZdZdifddZdS)FrameNcKs^t||f}d}d|kr,d|df}|d=nd|krFd|df}|d=t||d|i|dS)Nr rz-classr&r )r*rr)rcrr%rrr r r r& s   zFrame.__init__rr r r r r # sr c@seZdZdifddZdS)LabelNcKst||d||dS)Nlabelrrr r r r: szLabel.__init__rr r r r r 7 sr c@seZdZdifddZddZddZdd Zd(d d Zd)d d ZddZ ddZ ddZ ddZ ddZ ddZddZeZd*ddZeZddZeZd+d d!ZeZd"d#Zd$d%Zd,d&d'ZeZdS)-ListboxNcKst||d||dS)NZlistboxrrr r r rR szListbox.__init__cCs|j|jd|dSNactivaterrr r r r\ szListbox.activatecCs||j|jd|pdSrr?rr r r r` sz Listbox.bboxcCs||j|jdpdS)N curselectionr r?rr r r re szListbox.curselectioncCs|j|jd||dSrrrr r r ri szListbox.deletecCs:|dk r$|j|j|jd||S|j|jd|SdSrrfrr r r rm s z Listbox.getcCs*|j|jd|}|dkrdS|j|SNrrr1rrrrcrrer r r ru sz Listbox.indexcGs|j|jd|f|dSrr)rcrelementsr r r r{ szListbox.insertcCs|j|j|jd|S)Nnearestr)rcrUr r r r s  zListbox.nearestcCs|j|jdd||dSrrrr r r r szListbox.scan_markcCs|j|jdd||dSrrrr r r r szListbox.scan_dragtocCs|j|jd|dSNseerrr r r r sz Listbox.seecCs|j|jdd|dS)Nr rrrr r r selection_anchor szListbox.selection_anchorcCs|j|jdd||dSrrrr r r r  s  zListbox.selection_clearcCs|j|j|jdd|S)Nr Zincludesr(rr r r selection_includes s  zListbox.selection_includescCs|j|jdd||dS)Nr rrrr r r selection_set szListbox.selection_setcCs|j|j|jdS)Nrrrr r r r sz Listbox.sizecCs|j|jdf|d|fSrrrcrrr r r r szListbox.itemcgetcKs|d|f||Srrrr r r r szListbox.itemconfigure)N)N)N)N)N)r@rArBrrrrrrrrrrrrrZ select_anchorr rrZselect_includesrZ select_setrrrrr r r r r O s0      r c@seZdZdifddZd5ddZddZifd d Zifd d Zifd dZifddZ ifddZ ifddZ ifddZ ifddZ ifddZifddZifddZifdd Zd6d!d"Zd#d$Zd7d%d&ZeZd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4ZdS)8MenuNcKst||d||dSNmenurrr r r r sz Menu.__init__rYcCs|jd|j|||dS)Ntk_popupr)rcrTrUrr r r r sz Menu.tk_popupcCs|j|jd|dSrrrr r r r sz Menu.activatecKs$|j|jd|f|||dSNrrl)rcrr%rr r r r s zMenu.addcKs|d|p |dSNZcascaderrr r r add_cascade szMenu.add_cascadecKs|d|p |dSrr"rr r r add_checkbutton szMenu.add_checkbuttoncKs|d|p |dSNr r"rr r r add_command szMenu.add_commandcKs|d|p |dSNZ radiobuttonr"rr r r add_radiobutton szMenu.add_radiobuttoncKs|d|p |dSNZ separatorr"rr r r add_separator szMenu.add_separatorcKs&|j|jd||f|||dSrrl)rcrrr%rr r r r s z Menu.insertcKs||d|p|dSr!rrr r r insert_cascade szMenu.insert_cascadecKs||d|p|dSrr+rr r r insert_checkbutton szMenu.insert_checkbuttoncKs||d|p|dSr%r+rr r r insert_command szMenu.insert_commandcKs||d|p|dSr'r+rr r r insert_radiobutton szMenu.insert_radiobuttoncKs||d|p|dSr)r+rr r r insert_separator szMenu.insert_separatorcCs|dkr |}||||}}|dks2|dkr:d\}}t||dD]0}d||krHt||d}|rH||qH|j|jd||dS)N)rrrr r) rr entryconfigr entrycgetrr1rr)rcindex1index2Z num_index1Z num_index2rer&r r r r s z Menu.deletecCs|j|jd|d|S)Nr2r,rrr r r r2 szMenu.entrycgetcKs|d|f||S)Nentryconfigurerrr r r r5 szMenu.entryconfigurecCs*|j|jd|}|dkrdS|j|Srrrr r r r# sz Menu.indexcCs|j|jd|Srrrr r r r) sz Menu.invokecCs|j|jd||dS)Npostrrr r r r6. sz Menu.postcCs|j|jd|Srrrr r r r2 sz Menu.typecCs|j|jddS)Nunpostrrr r r r76 sz Menu.unpostcCs|j|j|jd|S)N xpositionrrr r r r8: szMenu.xpositioncCs|j|j|jd|S)N ypositionrrr r r r9? s  zMenu.yposition)rY)N)N)r@rArBrrrrr#r$r&r(r*rr,r-r.r/r0rr2r5r1rrr6rr7r8r9r r r r r s4               rc@seZdZdifddZdS) MenubuttonNcKst||d||dS)N menubuttonrrr r r rH szMenubutton.__init__rr r r r r:E sr:c@seZdZdifddZdS)MessageNcKst||d||dS)Nmessagerrr r r rO szMessage.__init__rr r r r r<L sr<c@s:eZdZdifddZddZddZdd Zd d ZdS) RadiobuttonNcKst||d||dSr'rrr r r rV s zRadiobutton.__init__cCs|j|jddSrrrr r r rb szRadiobutton.deselectcCs|j|jddSrrrr r r rg szRadiobutton.flashcCs|j|jdSrrrr r r rk szRadiobutton.invokecCs|j|jddSrrrr r r ro szRadiobutton.select)r@rArBrrrrrr r r r r>S s  r>c@s<eZdZdifddZddZddZd dd Zd d ZdS) ScaleNcKst||d||dSrrrr r r rw s zScale.__init__c CsJ|j|jd}z|j|WStttfk rD|j|YSXdSr)r1rrrrsr"rrrr r r r s z Scale.getcCs|j|jd|dSNrrrr r r r sz Scale.setcCs||j|jd|S)Nrr?rr r r r sz Scale.coordscCs|j|jd||SNidentifyrrr r r rB szScale.identify)N)r@rArBrrrrrBr r r r r?t s   r?c@sLeZdZdifddZdddZddZdd Zd d Zd d ZddZ dS) ScrollbarNcKst||d||dS)NZ scrollbarrrr r r r s zScrollbar.__init__cCs|j|jd|pdSrrrr r r r szScrollbar.activatecCs|j|j|jd||S)NrOr-)rcZdeltaxZdeltayr r r rO szScrollbar.deltacCs|j|j|jd||S)Nrr-rr r r r szScrollbar.fractioncCs|j|jd||SrArrr r r rB szScrollbar.identifycCs||j|jdSr)r}r1rrrr r r r sz Scrollbar.getcCs|j|jd||dSr@rrr r r r sz Scrollbar.set)N) r@rArBrrrOrrBrrr r r r rC s rCc@seZdZdifddZddZddZdd Zdjd d Zdkd d ZddZ dlddZ ddZ dmddZ ddZ ddZddZddZdnddZd d!Zdod"d#Zifd$d%Zd&d'Zd(d)Zd*d+Zdpd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zifd8d9Zd:d;Zdd?Z!d@dAZ"dqdBdCZ#dDdEZ$dFdGZ%drdHdIZ&dsdJdKZ'dLdMZ(dtdNdOZ)e)Z*dPdQZ+dudRdSZ,dvdTdUZ-dwdVdWZ.dxdXdYZ/dydZd[Z0d\d]Z1dzd^d_Z2d`daZ3d{dbdcZ4e4Z5ifdddeZ6dfdgZ7dhdiZ8dS)|TextNcKst||d||dSrrrr r r r sz Text.__init__cCs||j|jd|pdSrr?rr r r r s z Text.bboxc Cs|j|j|jd|||S)Ncomparer()rcr3opr4r r r rE s z Text.comparecGsVdd|D}|||g7}|jj|jdf|p2d}|dk rNt|dkrN|fS|SdS)NcSsg|]}|dsd|qS)r,r) startswith)rIargr r r rs zText.count..r~)r1rrr)rcr3r4rrr r r r~ s  z Text.countcCs6|dkr |j|j|jdS|j|jd|dS)Ndebugr(rr r r rJ sz Text.debugcCs|j|jd||dSrrrcr3r4r r r rsz Text.deletecCs||j|jd|S)N dlineinfor?rr r r rLszText.dlineinfoc Ksg}d}d}|s$g}|fdd}|}zzt|ts>||}}|d|g7}|D]} || rN|d| qN|||r|||jj|jdf||WS|r||XdS)NcSs||||fdSrp)ra)r5r rr#r r r append_triple/sz Text.dump..append_triplez-commandr,dump)rrrrrar1rr) rcr3r4r rrZ func_namer#rMr5r r r rNs*      z Text.dumpcGs|jj|jdf|S)Neditrrr r r rOBs z Text.editcCs |d|S)NZmodifiedrO)rcrHr r r edit_modifiedQs zText.edit_modifiedcCs |dS)NZredorPrr r r edit_redo\szText.edit_redocCs |dS)NresetrPrr r r edit_resetfszText.edit_resetcCs |dSr)rPrr r r edit_separatorkszText.edit_separatorcCs |dS)NZundorPrr r r edit_undors zText.edit_undocCs|j|jd||SrrrKr r r r}szText.getcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)Nrr,rrrrrrr r r image_cgets  zText.image_cgetcKs|dd|f||S)Nrrrrr r r image_configureszText.image_configurecKs"|jj|jdd|f|||S)NrrBrlrr r r image_creates zText.image_createcCs|j|jddSrrrr r r rszText.image_namescCst|j|jd|Sr)rr1rrrr r r rsz Text.indexcGs|j|jd||f|dSrr)rcrcharsrr r r rsz Text.insertcCs|j|jdd||fS)NrZgravityr)rcmarkName directionr r r mark_gravityszText.mark_gravitycCs|j|j|jddS)Nrrrfrr r r mark_namess  zText.mark_namescCs|j|jdd||dS)Nrrr)rcr[rr r r mark_setsz Text.mark_setcGs|j|jddf|dS)NrZunsetr)rcZ markNamesr r r mark_unsetszText.mark_unsetcCs|j|jdd|pdS)Nrnextrrr r r mark_nextszText.mark_nextcCs|j|jdd|pdS)NrZpreviousrrr r r mark_previousszText.mark_previouscKs&|jj|jdd|f|||dS)NpeerrBrl)rcZ newPathNamer%rr r r peer_creates zText.peer_createcCs|j|j|jddS)Nrdrrfrr r r peer_namesszText.peer_namescGs |jj|jd|||f|dS)Nrr)rcr3r4rZrr r r rsz Text.replacecCs|j|jdd||dSrrrr r r rszText.scan_markcCs|j|jdd||dSrrrr r r rszText.scan_dragtoc Cs|jdg} |r| d|r&| d|r4| d|rB| d|rP| d| r^| d| rv| d| | |r|d d kr| d | || ||r| |t|jt| S) Nrz -forwardsz -backwardsz-exactz-regexpz-nocasez-elidez-countrr,r)rrarr1rr) rcrrZ stopindexZforwardsZ backwardsexactZregexpZnocaser~Zeliderr r r rs.            z Text.searchcCs|j|jd|dSrrrr r r rszText.seecGs |j|jdd||f|dS)Ntagrr)rctagNamer3rr r r tag_addsz Text.tag_addcCs*|j|jdd||d|r&||dS)NrhrorYrs)rcrirjrlr r r rszText.tag_unbindcCs||jdd|f|||S)Nrhrorp)rcrirjrrr r r rs z Text.tag_bindcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)Nrr,rrrhrr)rcrirr r r tag_cget s  z Text.tag_cgetcKs|dd|f||S)Nrhrr)rcrir%rr r r tag_configureszText.tag_configurecGs|j|jddf|dS)Nrhrr)rcZtagNamesr r r tag_deleteszText.tag_deletecCs|j|jdd||dS)Nrhrr)rcrirr r r rszText.tag_lowercCs|j|j|jdd|S)Nrhrrfrr r r tag_names szText.tag_namesc Cs |j|j|jdd|||S)NrhZ nextrangerfrcrir3r4r r r tag_nextrange%s zText.tag_nextrangec Cs |j|j|jdd|||S)NrhZ prevrangerfror r r tag_prevrange,s zText.tag_prevrangecCs|j|jdd||dS)Nrhrr)rcrirr r r r3szText.tag_raisecCs|j|j|jdd|S)NrhZrangesrf)rcrir r r tag_ranges9s  zText.tag_rangescCs|j|jdd|||dS)Nrhrrror r r tag_remove>szText.tag_removecCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)Nrr,rrrrrrr r r window_cgetCs  zText.window_cgetcKs|dd|f||S)Nrrrrr r r window_configureKszText.window_configurecKs&|j|jdd|f|||dS)NrrBrlrr r r window_createQs   zText.window_createcCs|j|j|jddS)Nrrrfrr r r window_namesWszText.window_namescGs|j|jddf|dS)Nrz -pickplacer)rcrmr r r yview_pickplace\szText.yview_pickplace)N)N)NN)N)N)N)N)NNNNNNNN)N)N)N)N)N)N)N)N)N)N)9r@rArBrrrEr~rJrrLrNrOrQrRrTrUrVrrWrXrYrrrr]r^r_r`rbrcrerfrrrrrrjrrrkrlZ tag_configrmrrnrprqrrrrsrtruZ window_configrvrwrxr r r r rD s|   (                   rDc@seZdZdddZddZdS)_setitNcCs||_||_||_dSrp) _setit__value _setit__var_setit__callback)rcvarr rr r r rdsz_setit.__init__cGs*|j|j|jr&|j|jf|dSrp)r{rrzr|rr r r risz_setit.__call__)Nrr r r r ryas ryc@s$eZdZddZddZddZdS) OptionMenuc Osd|dtddd}t||d|d|_t|ddd }|_|j|_|d }d |kr\|d =|rtt d t t ||j |t |||d |D]} |j | t || |d q||d<dS) Nr+rr&)Z borderwidthZ textvariableZ indicatoronZreliefrZhighlightthicknessr;Z tk_optionMenurr)rXZtearoffr zunknown option -)r r )ZRAISEDrrrr_OptionMenu__menurZmenunamerrrar/r&ry) rcrrr rUkwargsrrrr)r r r rrs.   zOptionMenu.__init__cCs|dkr|jSt||Sr)rrrrr r r rszOptionMenu.__getitem__cCst|d|_dSrp)r:rrrr r r rs zOptionMenu.destroyN)r@rArBrrrr r r r r~osr~c@sdeZdZdZdidfddZddZddZd d Zd d Zd dZ e Z ddZ ddZ ddZ dS)ImagerNc Ksd|_|std}t|d||_|s>tjd7_dtjf}|rT|rTt||f}n|r\|}d}|D]*\}}t|r| |}|d||f}qh|j dd||f|||_dS) Nz create imager1rz pyimage%rr r,rrB) rXror^r1r_last_idr*r$rrr) rcZimgtyperXr%rrrr(r)r r r rs$  zImage.__init__cCs|jSrp)rXrr r r rEz Image.__str__cCs6|jr2z|jdd|jWntk r0YnXdS)Nrr)rXr1rrrr r r rs z Image.__del__cCs|j|jdd||dSNrr,r1rrXrr r r rszImage.__setitem__cCs|j|jdd|Srrrr r r rszImage.__getitem__cKsvd}t|D]J\}}|dk r|ddkr8|dd}t|rJ||}|d||f}q|j|jdf|dS)Nr rrr,r)r*r$rrr1rrX)rcrrr(r)r r r rs  zImage.configurecCs|j|jdd|jS)NrrWr1rrrXrr r r rWsz Image.heightcCs|jdd|jS)Nrrrrr r r rsz Image.typecCs|j|jdd|jS)NrrVrrr r r rVsz Image.width)r@rArBrrrErrrrrrWrrVr r r r rs rc@s|eZdZdidfddZddZddZdd Zd d Zdd dZdddZ ddZ dddZ dddZ ddZ ddZdS) PhotoImageNcKstj|d|||f|dS)NZphotorrrcrXr%rrr r r rszPhotoImage.__init__cCs|j|jddS)Nblankrrr r r rszPhotoImage.blankcCs|j|jdd|Srr)rcrr r r rszPhotoImage.cgetcCs|j|jdd|Srrrr r r rszPhotoImage.__getitem__cCs"t|jd}|j|d|j|S)Nrcopyrr1rrX)rc destImager r r rs zPhotoImage.copyrYcCs4t|jd}|dkr|}|j|d|jd|||S)NrrYrz-zoomrrcrTrUrr r r zooms  zPhotoImage.zoomcCs4t|jd}|dkr|}|j|d|jd|||S)NrrYrz -subsamplerrr r r subsamples  zPhotoImage.subsamplecCs|j|jd||Srrrr r r r szPhotoImage.getcCsH|jd|f}|r8|ddkr(|dd}|dt|}|j|dS)Nputr-tor)rrXrr1r)rcrrrr r r r s    zPhotoImage.putcCs@|jd|f}|r|d|f}|r0|dt|}|j|dS)Nwritez-format)z-fromr)rcfilenameformatZ from_coordsrr r r rs   zPhotoImage.writec Cs|j|j|jdd||S)N transparencyr)r1rrrXrr r r transparency_get"s zPhotoImage.transparency_getcCs|j|jdd|||dS)Nrrr)rcrTrUrr r r transparency_set'szPhotoImage.transparency_set)rY)rY)N)NN)r@rArBrrrrrrrrrrrrr r r r rs  rc@seZdZdidfddZdS) BitmapImageNcKstj|d|||f|dSrrrr r r r/szBitmapImage.__init__rr r r r r,srcCstdj}||ddS)Nzuse image_names()rrror1r-rr1r r r r6s rcCstdj}||ddS)Nzuse image_types()rrrrr r r r;s rc@seZdZdifddZddZd*ddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd+d d!Zd"d#Zd$d%Zd&d'Zd(d)ZdS),SpinboxNcKst||d||dS)NZspinboxrrr r r rCszSpinbox.__init__cCs||j|jd|pdSrr?rr r r r`s z Spinbox.bboxcCs|j|jd||Srrrr r r rns zSpinbox.deletecCs|j|jdSrrrr r r rysz Spinbox.getcCs|j|jd|Srrrr r r r}szSpinbox.icursorcCs|j|jd||SrArrr r r rBszSpinbox.identifycCs|j|jd|Srrrr r r rsz Spinbox.indexcCs|j|jd||Srr)rcrrdr r r rszSpinbox.insertcCs|j|jd|Srrrcelementr r r rszSpinbox.invokecGs ||j|jdf|pdS)Nrr r?rr r r rs z Spinbox.scancCs |d|SNrrr\r r r rszSpinbox.scan_markcCs |d|S)Nrrr\r r r rs zSpinbox.scan_dragtocGs ||j|jdf|pdS)Nr r r?rr r r r s zSpinbox.selectioncCs |d|S)Nrr rr r r rs zSpinbox.selection_adjustcCs |dS)Nrrrr r r r szSpinbox.selection_clearcCs|j|jdd|S)Nr rrrr r r selection_elementszSpinbox.selection_elementcCs|d|dS)Nrrrr r r rszSpinbox.selection_fromcCs|j|j|jddSrr(rr r r rszSpinbox.selection_presentcCs|d||dS)Nrrrr r r rszSpinbox.selection_rangecCs|d|dS)Nrrrr r r r szSpinbox.selection_to)N)N)r@rArBrrrrrrBrrrrrrr rr rrrrr r r r r r@s(    rc@seZdZdifddZdS) LabelFrameNcKst||d||dS)NZ labelframerrr r r rszLabelFrame.__init__rr r r r rsrc@seZdZdifddZddZddZeZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZd ddZeZddZdS)! PanedWindowNcKst||d||dS)NZ panedwindowrrr r r r szPanedWindow.__init__cKs"|j|jd|f||dSr rl)rcr$rr r r rszPanedWindow.addcCs|j|jd|dSNr r)rcr$r r r r'szPanedWindow.removecCs|j|jd||SrArrr r r rB0s zPanedWindow.identifycGs ||j|jdf|pdS)Nproxyr r?rr r r r<s zPanedWindow.proxycCs |dSNZcoordrrr r r proxy_coordAszPanedWindow.proxy_coordcCs |dSrrrr r r proxy_forgetFszPanedWindow.proxy_forgetcCs|d||SNrrrr r r proxy_placeKszPanedWindow.proxy_placecGs ||j|jdf|pdS)Nsashr r?rr r r rPs zPanedWindow.sashcCs |d|Srrrr r r sash_coordUs zPanedWindow.sash_coordcCs |d|Srrrr r r sash_markcszPanedWindow.sash_markcCs|d|||Srr)rcrrTrUr r r sash_placejszPanedWindow.sash_placecCs|j|jdf|d|fS)Npanecgetr,r)rcr$rr r r roszPanedWindow.panecgetcKsd|dkr|s||jd|St|tr@|s@||jd|d|S|j|jd|f|||dS)N paneconfigurer,)rrrrrr1rrrr r r rwsD  zPanedWindow.paneconfigurecCs|j|j|jdS)Npanesrfrr r r rszPanedWindow.panes)N)r@rArBrrrr rBrrrrrrrrrrZ paneconfigrr r r r r s"   LrcCst}dt}|d7}t||d}|t|d|fddd}|||_t|d|jd}|||| | dS) NzThis is Tcl/Tk version %su This should be a cedilla: çrz Click me!cSs|jjd|jddS)Nz[%s]rr)testr)rnr r r s z_test..)rr ZQUIT) rl TclVersionr rrCrrrr rr)rnrr rr{r r r _tests   r__main__)TN)N)r)r)NNrlr)UenumrrrZtkinter.constantsrerCfloatrRZ TkVersionrSrZREADABLEZWRITABLEZ EXCEPTIONcompilerASCIIrr rrr!r*r6rEnumr7rFrirjrkrorrrvr~rwrrrrrr_rrrrrrrrrlrjrkrtrxr}rrrCrrrr r r rr:r<r>r?rCrDryr~rrrrrrrrrr@r r r r !s       ,R  6  q2~ .37?/8$Vt!'2'BT 3C PK!wbh^$__pycache__/dnd.cpython-38.opt-2.pycnu[U e5d,@sTddlZddZGdddZGdddZGdd d Zd d Zed krPedS) NcCst||}|jr|SdSdSN) DndHandlerroot)sourceeventhr#/usr/lib64/python3.8/tkinter/dnd.py dnd_startls r c@sDeZdZdZddZddZddZdd Zdd d Zdd dZ dS)rNcCs|jdkrdS|j}z |jWdStk rD||_||_YnX||_d|_|j|_}|j|_ }d||f|_ |dpd|_ | |j |j | d|jd|d<dS)NzcursorZhand2)ZnumwidgetZ_root_DndHandler__dndAttributeErrorrrtargetZinitial_buttoninitial_widgetrelease_pattern save_cursorbind on_release on_motion)selfrrrZbuttonrrrr __init__zs$     zDndHandler.__init__cCs2|j}d|_|r.z|`Wntk r,YnXdSr)rrrrrrrr __del__szDndHandler.__del__c Cs|j|j}}|j||}|j}d}|rbz |j}Wntk rHYnX|||}|rZqb|j}q&|j}||kr|r| ||n,|rd|_| |||r| ||||_dSr) x_rooty_rootrZwinfo_containingr dnd_acceptrZmasterr dnd_motion dnd_leave dnd_enter) rrxyZ target_widgetr new_targetattrZ old_targetrrr rs.    zDndHandler.on_motioncCs||ddS)Nfinishrrrrr rszDndHandler.on_releasecCs||ddS)Nrr(r*rrr cancelszDndHandler.cancelrc Cs|j}|j}|j}|j}zf|`|j|j|jd|j|d<d|_|_|_|_|r||rp| ||n | ||W5|||XdS)Nrr ) rrrrdnd_endrZunbindrr dnd_commitr!)rrZcommitrrrrrrr r)s  zDndHandler.finish)N)r) __name__ __module__ __qualname__rrrrrr+r)rrrr rvs  rc@sNeZdZddZdddZddZdd Zd d Zd d ZddZ ddZ dS)IconcCs||_d|_|_|_dSr)namecanvaslabelid)rr2rrr rsz Icon.__init__ cCs||jkr |j|j||dS|jr.||s6dStj||jddd}|j|||dd}||_||_||_| d|j dS)NZraised)textZ borderwidthZreliefZnw)ZwindowZanchorz ) r3coordsr5detachtkinterZLabelr2Z create_windowr4rpress)rr3r#r$r4r5rrr attachs   z Icon.attachcCsB|j}|sdS|j}|j}d|_|_|_|||dSr)r3r5r4deleteZdestroy)rr3r5r4rrr r:s z Icon.detachcCs4t||r0|j|_|j|_|j|j\|_|_ dSr) r r#x_offr$y_offr3r9r5x_origy_origr*rrr r<s z Icon.presscCs(||j|\}}|j|j||dSr)wherer3r9r5)rrr#r$rrr movesz Icon.movecCs|j|j|j|jdSr)r3r9r5rArB)rrrr putbacksz Icon.putbackcCs8|}|}|j|}|j|}||j||jfSr)Z winfo_rootxZ winfo_rootyrrr?r@)rr3rZx_orgZy_orgr#r$rrr rCs   z Icon.wherecCsdSrr)rrrrrr r,sz Icon.dnd_endN)r6r6) r.r/r0rr=r:r<rDrErCr,rrrr r1s   r1c@s<eZdZddZddZddZddZd d Zd d Zd S)TestercCs>t||_tj|jddd|_|jjddd|j|j_dS)Nd)widthZheightZbothr')Zfillexpand)r;ZTopleveltopZCanvasr3packrrrrr rs zTester.__init__cCs|Srrrrrrrr rszTester.dnd_acceptc Csp|j||j|\}}|j|j\}}}}||||} } |j|||| || |_|||dSr)r3 focus_setrCbboxr5Zcreate_rectangledndidr ) rrrr#r$x1y1x2y2ZdxZdyrrr r"s  zTester.dnd_enterc CsF||j|\}}|j|j\}}}}|j|j||||dSr)rCr3rNrOrD) rrrr#r$rPrQrRrSrrr r szTester.dnd_motioncCs"|j|j|jd|_dSr)rJrMr3r>rOrLrrr r!$s zTester.dnd_leavecCs2|||||j|\}}||j||dSr)r!rCr3r=)rrrr#r$rrr r-)s zTester.dnd_commitN) r.r/r0rrr"r r!r-rrrr rF s rFcCst}|dtj|jddt|}|jdt|}|jdt|}|jdtd}td}td }| |j | |j | |j | dS) Nz+1+1ZQuit)Zcommandr8z+1+60z+120+60z+240+60ZICON1ZICON2ZICON3) r;ZTkZgeometryZButtonquitrKrFrJr1r=r3Zmainloop)rt1t2Zt3Zi1Zi2Zi3rrr test/s        rW__main__)r;r rr1rFrWr.rrrr gs Y=#PK!#N-__pycache__/colorchooser.cpython-38.opt-1.pycnu[U e5dA @s>ddlmZGdddeZd ddZedkr:ededS) )Dialogc@s$eZdZdZdZddZddZdS)ChooseraCreate a dialog for the tk_chooseColor command. Args: master: The master widget for this dialog. If not provided, defaults to options['parent'] (if defined). options: Dictionary of options for the tk_chooseColor call. initialcolor: Specifies the selected color when the dialog is first displayed. This can be a tk color string or a 3-tuple of ints in the range (0, 255) for an RGB triplet. parent: The parent window of the color dialog. The color dialog is displayed on top of this. title: A string for the title of the dialog box. Ztk_chooseColorcCs@z&|jd}t|tr$d||jd<Wntk r:YnXdS)zvEnsure initialcolor is a tk color string. Convert initialcolor from a RGB triplet to a color string. initialcolorz #%02x%02x%02xN)options isinstancetupleKeyError)selfcolorr ,/usr/lib64/python3.8/tkinter/colorchooser.py _fixoptions!s   zChooser._fixoptionscCs>|r t|sdS||\}}}|d|d|dft|fS)zAdjust result returned from call to tk_chooseColor. Return both an RGB tuple of ints in the range (0, 255) and the tk color string in the form #rrggbb. )NN)strZ winfo_rgb)r Zwidgetresultrgbr r r _fixresult.s zChooser._fixresultN)__name__ __module__ __qualname____doc__Zcommandr rr r r r rs rNcKs"|r|}||d<tf|S)zDisplay dialog window for selection of a color. Convenience wrapper for the Chooser class. Displays the color chooser dialog with color as the initial value. r)copyrZshow)r rr r r askcolorBsr__main__r )N)Ztkinter.commondialogrrrrprintr r r r  s 3 PK!jxx*__pycache__/constants.cpython-38.opt-2.pycnu[U e5d@s8dZZZdZZZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Zd;Z?dZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIS)JnsweZnwswneZsensZewZnsewcenterZnonexyZbothlefttoprightZbottomZraisedZsunkenZflatZridgeZgrooveZsolidZ horizontalZverticalnumericcharZwordZbaselineZinsideZoutsideZselz sel.firstzsel.lastendinsertZcurrentZanchorallZnormalZdisabledZactiveZhiddenZcascadeZ checkbuttonZcommandZ radiobuttonZ separatorZsingleZbrowseZmultipleZextendedZdotboxZ underlineZpiesliceZchordZarcfirstZlastZbuttZ projectingroundZbevelZmiterZmovetoZscrollZunitsZpagesN)MZNOZFALSEZOFFZYESZTRUEZONNSWEZNWZSWZNEZSEZNSZEWZNSEWZCENTERZNONEXYZBOTHZLEFTZTOPZRIGHTZBOTTOMZRAISEDZSUNKENZFLATZRIDGEZGROOVEZSOLIDZ HORIZONTALZVERTICALZNUMERICZCHARZWORDZBASELINEZINSIDEZOUTSIDEZSELZ SEL_FIRSTZSEL_LASTZENDZINSERTZCURRENTZANCHORZALLZNORMALZDISABLEDZACTIVEZHIDDENZCASCADEZ CHECKBUTTONZCOMMANDZ RADIOBUTTONZ SEPARATORZSINGLEZBROWSEZMULTIPLEZEXTENDEDZDOTBOXZ UNDERLINEZPIESLICEZCHORDZARCZFIRSTZLASTZBUTTZ PROJECTINGZROUNDZBEVELZMITERZMOVETOZSCROLLZUNITSZPAGESrr)/usr/lib64/python3.8/tkinter/constants.pys  PK![_S S +__pycache__/messagebox.cpython-38.opt-2.pycnu[U e5d}@sHddlmZdZdZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZGdddeZd5ddZd6ddZd7ddZd8ddZd9ddZd:dd Zd;d!d"Zd)DialogerrorinfoZquestionZwarningZabortretryignoreokZokcancelZ retrycancelZyesnoZ yesnocancelabortZretryignoreZcancelZyesZnoc@seZdZdZdS)MessageZ tk_messageBoxN)__name__ __module__ __qualname__Zcommandr r */usr/lib64/python3.8/tkinter/messagebox.pyr9srNcKsl|rd|kr||d<|r(d|kr(||d<|r4||d<|r@||d<tf|}t|trd|r`tStSt|S)NZicontypetitlemessage)rZshow isinstanceboolYESNOstr)rrZ_iconZ_typeoptionsresr r r _showCs   rcKst||ttf|SN)rINFOOKrrrr r r showinfoRsrcKst||ttf|Sr)rWARNINGrrr r r showwarningWsrcKst||ttf|Sr)rERRORrrr r r showerror\sr!cKst||ttf|Sr)rQUESTIONYESNOrr r r askquestionasr$cKst||ttf|}|tkSr)rr"OKCANCELrrrrsr r r askokcancelfsr(cKst||ttf|}|tkSr)rr"r#rr&r r r askyesnolsr)cKs.t||ttf|}t|}|tkr&dS|tkSr)rr" YESNOCANCELrCANCELrr&r r r askyesnocancelrs r,cKst||ttf|}|tkSr)rr RETRYCANCELRETRYr&r r r askretrycancel|sr/__main__ZSpamzEgg Informationz Egg Warningz Egg Alertz Question?ZproceedzProceed?zyes/nozGot it?z yes/no/cancelzWant it?z try againz Try again?)NNNN)NN)NN)NN)NN)NN)NN)NN)NN)Ztkinter.commondialogrr rr"rZABORTRETRYIGNORErr%r-r#r*ZABORTr.ZIGNOREr+rrrrrrr!r$r(r)r,r/r printr r r r sH         PK!1& +__pycache__/messagebox.cpython-38.opt-1.pycnu[U e5d}@sHddlmZdZdZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZGdddeZd5ddZd6ddZd7ddZd8ddZd9ddZd:dd Zd;d!d"Zd)DialogerrorinfoZquestionZwarningZabortretryignoreokZokcancelZ retrycancelZyesnoZ yesnocancelabortZretryignoreZcancelZyesZnoc@seZdZdZdZdS)Messagez A message boxZ tk_messageBoxN)__name__ __module__ __qualname____doc__Zcommandr r */usr/lib64/python3.8/tkinter/messagebox.pyr9srNcKsl|rd|kr||d<|r(d|kr(||d<|r4||d<|r@||d<tf|}t|trd|r`tStSt|S)NZicontypetitlemessage)rZshow isinstanceboolYESNOstr)rrZ_iconZ_typeoptionsresr r r_showCs   rcKst||ttf|S)zShow an info message)rINFOOKrrrr r rshowinfoRsrcKst||ttf|S)zShow a warning message)rWARNINGrrr r r showwarningWsrcKst||ttf|S)zShow an error message)rERRORrrr r r showerror\sr!cKst||ttf|S)zAsk a question)rQUESTIONYESNOrr r r askquestionasr$cKst||ttf|}|tkS)z@Ask if operation should proceed; return true if the answer is ok)rr"OKCANCELrrrrsr r r askokcancelfsr(cKst||ttf|}|tkS)z0Ask a question; return true if the answer is yes)rr"r#rr&r r raskyesnolsr)cKs.t||ttf|}t|}|tkr&dS|tkS)zDAsk a question; return true if the answer is yes, None if cancelled.N)rr" YESNOCANCELrCANCELrr&r r raskyesnocancelrs r,cKst||ttf|}|tkS)zDAsk if operation should be retried; return true if the answer is yes)rr RETRYCANCELRETRYr&r r raskretrycancel|sr/__main__ZSpamzEgg Informationz Egg Warningz Egg Alertz Question?ZproceedzProceed?zyes/nozGot it?z yes/no/cancelzWant it?z try againz Try again?)NNNN)NN)NN)NN)NN)NN)NN)NN)NN)Ztkinter.commondialogrr rr"rZABORTRETRYIGNORErr%r-r#r*ZABORTr.ZIGNOREr+rrrrrrr!r$r(r)r,r/r printr r r rsH         PK! MС%__pycache__/font.cpython-38.opt-1.pycnu[U e5d@@szdZddlZddlZdZdZdZdZddZGd d d Zd d d Z d!d dZ e dkrve Z eddedZeeeedeedeeeedeedee eededeeje deddZeedejde deje dedZeeje de jdZeeeddZejedejededS)"z0.9NZnormalZromanboldZitaliccCs t|ddS)zFGiven the name of a tk named font, returns a Font representation. T)nameexists)Fontrr$/usr/lib64/python3.8/tkinter/font.py nametofontsr c@seZdZdZedZddZddZddZ d#d d Z d dZ ddZ ddZ ddZddZddZd$ddZddZddZeZd%dd Zd!d"Zd S)&raRepresents a named font. Constructor options are: font -- font specifier (name, system font, or (family, size, style)-tuple) name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new named font if False, points to the existing font if True. Raises _tkinter.TclError if the assertion is false. the following are ignored if font is specified: family -- font 'family', e.g. Courier, Times, Helvetica size -- font size in points weight -- font thickness: NORMAL, BOLD slant -- font slant: ROMAN, ITALIC underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) cCs:g}|D]$\}}|d||t|q t|SN-)itemsappendstrtuple)selfkwoptionskvrrr_set1s z Font._setcCs$g}|D]}|d|qt|Sr )rr)rargsrrrrr_get8sz Font._getcCs:i}tdt|dD] }||d|||dd<q|S)Nrr )rangelen)rrrirrr_mkdict>sz Font._mkdictNFcKs|std}t|d|}|r4||dd|}n ||}|sTdtt|j}||_ |rd|_ |j ||ddkrtj d|j f|r|jdd|j f|n|jdd |j f|d |_ ||_ |j|_|j|_dS) Nzuse fonttkfontactualFnamesz$named font %s does not already exist configureZcreateT)tkinter_get_default_rootgetattr splitlistcallrrnextcounterr delete_fontZ_tkinterZTclError_tk_split_call)rrootrrrrrrrr__init__Ds,    z Font.__init__cCs|jSNrrrrr__str__csz Font.__str__cCs&t|tstS|j|jko$|j|jkSr0) isinstancerNotImplementedrr+)rotherrrr__eq__fs z Font.__eq__cCs ||Sr0)cget)rkeyrrr __getitem__kszFont.__getitem__cCs|jf||idSr0)r")rr8valuerrr __setitem__nszFont.__setitem__cCs4z|jr|dd|jWntk r.YnXdS)Nrdelete)r*r-r Exceptionr1rrr__del__qs z Font.__del__cCst|jf|S)z*Return a distinct copy of the current font)rr+r r1rrrcopyxsz Font.copycCs^d}|rd|f}|r8|d|f}|jdd|jf|S|||jdd|jf|SdS)zReturn actual font attributesr -displayofr rr N)r-rrr,)roption displayofrrrrr |sz Font.actualcCs|dd|jd|S)zGet font attributerconfigr )r-r)rrArrrr7sz Font.cgetc KsB|r"|jdd|jf||n|||dd|jSdS)zModify font attributesrrCN)r-rrrr,)rrrrrrCsz Font.configcCs2|f}|rd||f}|j|jdd|jf|S)zReturn text widthr@rmeasure)r+getintr-r)rtextrBrrrrrDs z Font.measurecOsd}|dd}|rd|f}|rL|||}|j|jdd|jf|S||jdd|jf|}i}tdt|dD](}|j||d |||d d<q||SdS) z}Return font metrics. For best performance, create a dummy widget using this font before calling this method.rrBNr@rmetricsrrr ) poprr+rEr-rr,rr)rrrrrBresrrrrrGs &z Font.metrics)NNNF)NN)N)__name__ __module__ __qualname____doc__ itertoolscountr)rrrr/r2r6r9r;r>r?r r7rCr"rDrGrrrrrs$     rcCs6|std}d}|rd|f}|j|jjd|S)zGet font families (as a tuple)zuse font.families()rr@rfamilies)rrPr#r$rr&r')r.rBrrrrrPs  rPcCs$|std}|j|jddS)z'Get names of defined fonts (as a tuple)zuse font.names()rr!rQ)r.rrrr!s r!__main__times)familysizeweightrUrWZhelloZ linespace)rB)ZCourierr)rz Hello, world)rFrzQuit!)rFZcommandr)rW)NN)N) __version__rNr#ZNORMALZROMANZBOLDZITALICr rrPr!rJZTkr.fprintr rCr7rDrGZLabelwZpackZButtonZdestroyr?ZfbZmainlooprrrrsB       PK!ҧ'__pycache__/dialog.cpython-38.opt-1.pycnu[U e5d@srddlTddlmZdZGdddeZddZedkrned d d d eeiiZ ed d d d e j eiiZ e d S))*) _cnfmergeZ questheadc@s"eZdZdifddZddZdS)DialogNc Kst||f}d|_t||||j|jjd|j|d|d|d|df|d|_zt |Wnt k r~YnXdS)NZ __dialog__Z tk_dialogtitletextbitmapdefaultstrings) rZ widgetNameWidget_setupZtkZgetintZcallZ_wnumdestroyZTclError)selfZmasterZcnfkwr&/usr/lib64/python3.8/tkinter/dialog.py__init__ s& zDialog.__init__cCsdS)Nr)rrrrr zDialog.destroy)__name__ __module__ __qualname__rr rrrrr s rcCs$tdddtddd}t|jdS)Nz File ModifiedzzFile "Python.h" has been modified since the last time it was saved. Do you want to save it before exiting the application.r)z Save FilezDiscard ChangeszReturn to Editor)rrrrr )r DIALOG_ICONprintr )drrr_tests r__main__NrZTestZcommandZQuit) Ztkinterrrr rrrZButtonZPacktquitqZmainlooprrrrs$ PK!vZZ-__pycache__/commondialog.cpython-38.opt-2.pycnu[U e5d@sddlTGdddZdS))*c@s2eZdZdZd ddZddZddZdd ZdS) DialogNcKs|s|d}||_||_dS)Nparent)getmasteroptions)selfrrr ,/usr/lib64/python3.8/tkinter/commondialog.py__init__s zDialog.__init__cCsdSNr )rr r r _fixoptionsszDialog._fixoptionscCs|Sr r )rZwidgetresultr r r _fixresultszDialog._fixresultc Ks||D]\}}||j|<q|t|j}z,|jj|jf| |j}| ||}W5z |Wn YnXX|Sr ) itemsrr ZFramerZdestroyZtkZcallcommandZ_optionsr)rrkvwsr r r shows   z Dialog.show)N)__name__ __module__ __qualname__rr r rrr r r r rs  rN)Ztkinterrr r r r  sPK!vZZ'__pycache__/commondialog.cpython-38.pycnu[U e5d@sddlTGdddZdS))*c@s2eZdZdZd ddZddZddZdd ZdS) DialogNcKs|s|d}||_||_dS)Nparent)getmasteroptions)selfrrr ,/usr/lib64/python3.8/tkinter/commondialog.py__init__s zDialog.__init__cCsdSNr )rr r r _fixoptionsszDialog._fixoptionscCs|Sr r )rZwidgetresultr r r _fixresultszDialog._fixresultc Ks||D]\}}||j|<q|t|j}z,|jj|jf| |j}| ||}W5z |Wn YnXX|Sr ) itemsrr ZFramerZdestroyZtkZcallcommandZ_optionsr)rrkvwsr r r shows   z Dialog.show)N)__name__ __module__ __qualname__rr r rrr r r r rs  rN)Ztkinterrr r r r  sPK!1& %__pycache__/messagebox.cpython-38.pycnu[U e5d}@sHddlmZdZdZdZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZGdddeZd5ddZd6ddZd7ddZd8ddZd9ddZd:dd Zd;d!d"Zd)DialogerrorinfoZquestionZwarningZabortretryignoreokZokcancelZ retrycancelZyesnoZ yesnocancelabortZretryignoreZcancelZyesZnoc@seZdZdZdZdS)Messagez A message boxZ tk_messageBoxN)__name__ __module__ __qualname____doc__Zcommandr r */usr/lib64/python3.8/tkinter/messagebox.pyr9srNcKsl|rd|kr||d<|r(d|kr(||d<|r4||d<|r@||d<tf|}t|trd|r`tStSt|S)NZicontypetitlemessage)rZshow isinstanceboolYESNOstr)rrZ_iconZ_typeoptionsresr r r_showCs   rcKst||ttf|S)zShow an info message)rINFOOKrrrr r rshowinfoRsrcKst||ttf|S)zShow a warning message)rWARNINGrrr r r showwarningWsrcKst||ttf|S)zShow an error message)rERRORrrr r r showerror\sr!cKst||ttf|S)zAsk a question)rQUESTIONYESNOrr r r askquestionasr$cKst||ttf|}|tkS)z@Ask if operation should proceed; return true if the answer is ok)rr"OKCANCELrrrrsr r r askokcancelfsr(cKst||ttf|}|tkS)z0Ask a question; return true if the answer is yes)rr"r#rr&r r raskyesnolsr)cKs.t||ttf|}t|}|tkr&dS|tkS)zDAsk a question; return true if the answer is yes, None if cancelled.N)rr" YESNOCANCELrCANCELrr&r r raskyesnocancelrs r,cKst||ttf|}|tkS)zDAsk if operation should be retried; return true if the answer is yes)rr RETRYCANCELRETRYr&r r raskretrycancel|sr/__main__ZSpamzEgg Informationz Egg Warningz Egg Alertz Question?ZproceedzProceed?zyes/nozGot it?z yes/no/cancelzWant it?z try againz Try again?)NNNN)NN)NN)NN)NN)NN)NN)NN)NN)Ztkinter.commondialogrr rr"rZABORTRETRYIGNORErr%r-r#r*ZABORTr.ZIGNOREr+rrrrrrr!r$r(r)r,r/r printr r r rsH         PK!T—||$__pycache__/ttk.cpython-38.opt-1.pycnu[U e5d@sdZdZdZddddddd d d d d ddddddddddddddgZddlZddlmZmZmZmZej dkrpd nd!Z d"d#Z dXd$d%Z dYd&d'Z d(d)ZdZd*d+Zd[d,d-Zd\d/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Zd?dZd]d@dZGdAddeZGdBdCdCejZGdDddeZGdEddeZGdFddeej Z GdGdde Z!GdHddeZ"GdIddeZ#GdJd d eZ$e$Z%GdKd d eZ&GdLd d eZ'GdMd d eej(Z)e)Z(GdNddeZ*GdOddeZ+GdPddeej,Z,GdQddeej-Z-GdRddeZ.GdSddeZ/GdTdde Z0GdUddeej1ej2Z3GdVdde"Z4GdWdde&Z5dS)^aTtk wrapper. This module provides classes to allow using Tk themed widget set. Ttk is based on a revised and enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style engine. Its basic idea is to separate, to the extent possible, the code implementing a widget's behavior from the code implementing its appearance. Widget class bindings are primarily responsible for maintaining the widget state and invoking callbacks, all aspects of the widgets appearance lies at Themes. z0.3.1z!Guilherme Polo Button CheckbuttonComboboxEntryFrameLabel Labelframe LabelFrame MenubuttonNotebook Panedwindow PanedWindow Progressbar RadiobuttonScale Scrollbar SeparatorSizegripSpinboxStyleTreeview LabeledScale OptionMenu tclobjs_to_py setup_masterN)_flatten_join _stringify _splitdictg!@TFcCsBtr>ddl}|jd}|r,|jd||jdd|_dS)NrZ TILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT) _REQUIRE_TILEosenvirongettkeval _tile_loaded)masterr Ztilelibr'#/usr/lib64/python3.8/tkinter/ttk.py _load_tile"s  r)cCs(|rt|}nt|ttfr$t|}|S)zInternal function.)r isinstancelisttupler)valuescriptr'r'r(_format_optvalue1s  r/cCsPg}|D]:\}}|r ||kr |d||dk r |t||q t|S)zFormats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')-%sN)itemsappendr/r)Zoptdictr.ignoreoptsoptr-r'r'r(_format_optdict;s r6cCsXg}|D]J^}}t|dkr,|dp(d}n d|}|||dk r||q|S)Nr )lenjoinr2)r1Zopt_valstatevalr'r'r(_mapdict_valuesKs    r>cCs:g}|D]$\}}|d|tt||fq t|S)zFormats mapdict to pass it to tk.call. E.g. (script=False): {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]} returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')r0)r1extendr/r>r)Zmapdictr.r4r5r-r'r'r(_format_mapdict`s   r@c Osd}d}|dkr|dkrB|d}tt|dd}d||f}n2|dd\}} tt|dd} d || | f}t||}n,|d kr|d}t|dkrt|d|f}|rd |}d |}||fS) zAFormats args and kw according to the given element factory etype.Nr')imageZvsapirArr7z%s %sz%s %s %sfromz{%s}r9)rr>r6r:r/r;) etyper.argskwspecr4ZinameZ imagespec class_nameZpart_idZstatemapr'r'r(_format_elemcreateqs&   rIrBc Csg}|D]}|\}}|pi}dt|dd}dd|||rDd|ndf}d|kr||d||7}t|d||\} }|| ||8}|d d|q||qd ||fS) a$Formats a layout list so we can pass the result to ttk::style layout and ttk::style settings. Note that the layout doesn't have to be a list necessarily. E.g.: [("Menubutton.background", None), ("Menubutton.button", {"children": [("Menubutton.focus", {"children": [("Menubutton.padding", {"children": [("Menubutton.label", {"side": "left", "expand": 1})] })] })] }), ("Menubutton.indicator", {"side": "right"}) ] returns: Menubutton.background Menubutton.button -children { Menubutton.focus -children { Menubutton.padding -children { Menubutton.label -side left -expand 1 } } } Menubutton.indicator -side rightr9T)childrenz%s%s%sz %sr8rJz -children {z%s} )r;r6r2_format_layoutlist) layoutindentZ indent_sizer.Z layout_elemelemr4ZfoptsheadZ newscriptr'r'r(rLs"   rLc CsXg}|D]>\}}|drFdt|dd}|d||f|drvdt|dd}|d||fd|kr|dsd}nt|d\}}|d ||f|d r |d }|d }d }|t|krt||d s|d 7}q|d |} |t|kr||r||ni} t |df| | \} }|d||| |fq d|S)zReturns an appropriate script, based on settings, according to theme_settings definition to be used by theme_settings and theme_create. configurer9Tzttk::style configure %s %s;mapzttk::style map %s %s;rMnullzttk::style layout %s { %s }zelement createrr7r1z%ttk::style element create %s %s %s %srK) r1r"r;r6r2r@rLr:hasattrrI) settingsr.namer4s_ZeoptsrDZargcZelemargsZelemkwrGr'r'r(_script_from_settingss:     $ rYcCst|tr|Sg}t|}t||D]j\}}t|drDt|}n(t|trX|}nt|ttfsl|f}t|dr~t|}|||fq$|S)ztConstruct a list from the given statespec tuple according to the accepted statespec accepted by _format_mapdict.typename) r*striterziprTsplitr,r+r2)Zstupleresultitr<r=r'r'r(_list_from_statespecs     racCs||}g}d}|t|kr||}i}|||f|d7}|t|kr|||d\}}|dslq|dd}|d7}|dkrt||}|||<q@q|S)zpConstruct a list from the tuple returned by ttk::layout, this is somewhat the reverse of _format_layoutlist.rr7rB-NrJ) splitlistr:r2 startswith_list_from_layouttuple)r#ZltupleresZindxrVr4r5r=r'r'r(res$       recGs4t|}|j||}t|dr&|St||tdS)ahFormat options then call Tk command with args and options and return the appropriate result. If no option is specified, a dict is returned. If an option is specified with the None value, the value for that option is returned. Otherwise, the function just sets the passed options and the caller shouldn't be expecting a return value anyway.rB)conv)r6callr:r _tclobj_to_py)r#optionsrErfr'r'r( _val_or_dict!s  rkc Cs2t|}z t|}Wnttfk r,YnX|S)zAConverts a value to, hopefully, a more appropriate Python object.)r[int ValueError TypeError)r-r'r'r(_convert_stringval1s  rocCs(t|tr$d|krt|}nt|}|S)N.)r*r[floatrl)xr'r'r( _to_number;s   rscCs\|rFt|drFt|tsFt|ddddkr6t|}qXttt|}nt|drXt|}|S)z8Return value converted from Tcl object to Python object.__len__rrZNZ StateSpec)rTr*r[getattrrar+rRro)r=r'r'r(riCs  ricCs"|D]\}}t|||<q|S)zOReturns adict with its values converted from Tcl objects to Python objects.)r1ri)Zadictr5r=r'r'r(rPscCs|dkrt}|S)aIf master is not None, itself is returned. If master is None, the default master is returned if there is one, otherwise a new master is created and returned. If it is not allowed to use the default root and master is None, RuntimeError is raised.N)tkinterZ_get_default_root)r&r'r'r(rXsc@seZdZdZdZdddZdddZddd Zdd d Zd d d Z ddZ ddZ ddZ d!ddZ ddZddZd"ddZdS)#rzManipulate style database.z ttk::styleNcCs0t|}t|ddst|||_|jj|_dS)Nr%F)rrur)r&r#)selfr&r'r'r(__init__is  zStyle.__init__cKs4|dk rd||<t|j||jd|}|s,|r0|SdS)zQuery or sets the default value of the specified option(s) in style. Each key in kw is an option and each value is either a string or a sequence identifying the value for that option.NrQ)rkr#_namerwstyleZ query_optrFr_r'r'r(rQts zStyle.configurec sj|dk r0jjd|d|}tj|Sjjjd|ft|}fddtj|DS)aSQuery or sets dynamic values of the specified option(s) in style. Each key in kw is an option and each value should be a list or a tuple (usually) containing statespecs grouped in tuples, or list, or something else of your preference. A statespec is compound of one or more states and then a value.NrRr0cs"i|]\}}|tj|qSr')rar#rc).0kvrwr'r( szStyle.map..)r#rhryrarcr@rr1rzr'rr(rRs z Style.mapcCs.|rd|nd}|j|jd|d|||S)aReturns the value specified for option in style. If state is specified it is expected to be a sequence of one or more states. If the default argument is set, it is used as a fallback value in case no specification for option is found.r9r8lookupr0)r;r#rhry)rwr{optionr<defaultr'r'r(rs z Style.lookupcCs>d}|rt|d}n |dk r"d}t|j|j|jd||S)aDefine the widget layout for given style. If layoutspec is omitted, return the layout specification for given style. layoutspec is expected to be a list or an object different than None that evaluates to False if you want to "turn off" that style. If it is a list (or tuple, or something else), each item should be a tuple where the first item is the layout name and the second item should have the format described below: LAYOUTS A layout can contain the value None, if takes no options, or a dict of options specifying how to arrange the element. The layout mechanism uses a simplified version of the pack geometry manager: given an initial cavity, each element is allocated a parcel. Valid options/values are: side: whichside Specifies which side of the cavity to place the element; one of top, right, bottom or left. If omitted, the element occupies the entire cavity. sticky: nswe Specifies where the element is placed inside its allocated parcel. children: [sublayout... ] Specifies a list of elements to place inside the element. Each element is a tuple (or other sequence) where the first item is the layout name, and the other is a LAYOUT.NrrSrM)rLrer#rhry)rwr{Z layoutspecZlspecr'r'r(rMs z Style.layoutcOs8t|df||\}}|jj|jdd|||f|dS)z9Create a new element in the current theme of given etype.FelementcreateN)rIr#rhry)rw elementnamerDrErFrGr4r'r'r(element_creates zStyle.element_createc Cs(tdd|j|j|jddDS)z:Returns the list of elements defined in the current theme.css|]}|dVqdSrbNlstrip)r|nr'r'r( sz&Style.element_names..rnamesr,r#rcrhryrr'r'r( element_namesszStyle.element_namesc Cs*tdd|j|j|jdd|DS)z)Return the list of elementname's options.css|]}|dVqdSrr)r|or'r'r(rsz(Style.element_options..rrjr)rwrr'r'r(element_optionsszStyle.element_optionsc CsN|r t|nd}|r2|j|jdd|d|d|n|j|jdd|d|dS)a.Creates a new theme. It is an error if themename already exists. If parent is specified, the new theme will inherit styles, elements and layouts from the specified parent theme. If settings are present, they are expected to have the same syntax used for theme_settings.r8themerz-parentz -settingsNrYr#rhry)rw themenameparentrUr.r'r'r( theme_createszStyle.theme_createcCs"t|}|j|jdd||dS)aTemporarily sets the current theme to themename, apply specified settings and then restore the previous theme. Each key in settings is a style and each value may contain the keys 'configure', 'map', 'layout' and 'element create' and they are expected to have the same format as specified by the methods configure, map, layout and element_create respectively.rrUNr)rwrrUr.r'r'r(theme_settingsszStyle.theme_settingscCs|j|j|jddS)z#Returns a list of all known themes.rr)r#rcrhryrr'r'r( theme_namesszStyle.theme_namescCs&|dkr|jdS|jd|dS)zIf themename is None, returns the theme in use, otherwise, set the current theme to themename, refreshes all widgets and emits a <> event.Nzreturn $ttk::currentThemez ttk::setTheme)r#r$rh)rwrr'r'r( theme_uses zStyle.theme_use)N)N)N)NN)N)NN)N)__name__ __module__ __qualname____doc__ryrxrQrRrrMrrrrrrrr'r'r'r(rds  +  c@s6eZdZdZd ddZddZd ddZd d d ZdS)Widgetz!Base class for Tk themed widgets.NcCs4t|}t|ddst|tjj||||ddS)aConstructs a Ttk Widget with the parent master. STANDARD OPTIONS class, cursor, takefocus, style SCROLLABLE WIDGET OPTIONS xscrollcommand, yscrollcommand LABEL WIDGET OPTIONS text, textvariable, underline, image, compound, width WIDGET STATES active, disabled, focus, pressed, selected, background, readonly, alternate, invalid r%F)rFN)rrur)rvrrx)rwr&Z widgetnamerFr'r'r(rxs zWidget.__init__cCs|j|jd||S)zReturns the name of the element at position x, y, or the empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget.identifyr#rh_wrwrryr'r'r(r+szWidget.identifyc Os6|j|j|jdd|}|r2|r2|||S|S)a1Test the widget's state. If callback is not specified, returns True if the widget state matches statespec and False otherwise. If callback is specified, then it will be invoked with *args, **kw if the widget state matches statespec. statespec is expected to be a sequence.instater9)r# getbooleanrhrr;)rw statespeccallbackrErFZretr'r'r(r3s  zWidget.instatecCs0|dk rd|}|jt|j|jd|S)aModify or inquire widget state. Widget state is returned if statespec is None, otherwise it is set according to the statespec flags and then a new state spec is returned indicating which flags were changed. statespec is expected to be a sequence.Nr9r<)r;r#rcr[rhr)rwrr'r'r(r<Bs z Widget.state)N)N)N)rrrrrxrrr<r'r'r'r(r s   rc@s"eZdZdZdddZddZdS)rzcTtk Button widget, displays a textual label and/or image, and evaluates a command when pressed.NcKst||d|dS)aConstruct a Ttk Button widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, default, width z ttk::buttonNrrxrwr&rFr'r'r(rxSs zButton.__init__cCs|j|jdS)z/Invokes the command associated with the button.invokerrr'r'r(rbsz Button.invoke)Nrrrrrxrr'r'r'r(rOs c@s"eZdZdZdddZddZdS)rz;Ttk Checkbutton widget which is either in on- or off-state.NcKst||d|dS)a'Construct a Ttk Checkbutton widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, offvalue, onvalue, variable zttk::checkbuttonNrrr'r'r(rxjs zCheckbutton.__init__cCs|j|jdS)aWToggles between the selected and deselected states and invokes the associated command. If the widget is currently selected, sets the option variable to the offvalue option and deselects the widget; otherwise, sets the option variable to the option onvalue. Returns the result of the associated command.rrrr'r'r(ryszCheckbutton.invoke)Nrr'r'r'r(rgs c@s2eZdZdZd ddZddZddZd d ZdS) rzeTtk Entry widget displays a one-line text string and allows that string to be edited by the user.NcKst|||pd|dS)aConstructs a Ttk Entry widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand WIDGET-SPECIFIC OPTIONS exportselection, invalidcommand, justify, show, state, textvariable, validate, validatecommand, width VALIDATION MODES none, key, focus, focusin, focusout, all z ttk::entryNr)rwr&ZwidgetrFr'r'r(rxszEntry.__init__cCs||j|jd|S)zqReturn a tuple of (x, y, width, height) which describes the bounding box of the character given by index.bboxZ_getintsr#rhr)rwindexr'r'r(rsz Entry.bboxcCs|j|jd||S)zxReturns the name of the element at position x, y, or the empty string if the coordinates are outside the window.rrrr'r'r(rszEntry.identifycCs|j|j|jdS)zForce revalidation, independent of the conditions specified by the validate option. Returns False if validation fails, True if it succeeds. Sets or clears the invalid state accordingly.validater#rrhrrr'r'r(rszEntry.validate)NN)rrrrrxrrrr'r'r'r(rs  c@s,eZdZdZd ddZd ddZddZdS) rzMTtk Combobox widget combines a text field with a pop-down list of values.NcKstj||df|dS)aConstruct a Ttk Combobox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS exportselection, justify, height, postcommand, state, textvariable, values, width z ttk::comboboxNrrxrr'r'r(rxs zCombobox.__init__cCs2|dkr |j|j|jdS|j|jd|S)aIf newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, returns the index of the current value in the list of values or -1 if the current value does not appear in the list.Ncurrentr#Zgetintrhr)rwZnewindexr'r'r(rszCombobox.currentcCs|j|jd|dS)z(Sets the value of the combobox to value.setNrrwr-r'r'r(rsz Combobox.set)N)N)rrrrrxrrr'r'r'r(rs  c@seZdZdZdddZdS)rzJTtk Frame widget is a container, used to group other widgets together.NcKst||d|dS)zConstruct a Ttk Frame with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS borderwidth, relief, padding, width, height z ttk::frameNrrr'r'r(rxs zFrame.__init__)Nrrrrrxr'r'r'r(rsc@seZdZdZdddZdS)rz7Ttk Label widget displays a textual label and/or image.NcKst||d|dS)aGConstruct a Ttk Label with parent master. STANDARD OPTIONS class, compound, cursor, image, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS anchor, background, font, foreground, justify, padding, relief, text, wraplength z ttk::labelNrrr'r'r(rxs zLabel.__init__)Nrr'r'r'r(rsc@seZdZdZdddZdS)rzTtk Labelframe widget is a container used to group other widgets together. It has an optional label, which may be a plain text string or another widget.NcKst||d|dS)zConstruct a Ttk Labelframe with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS labelanchor, text, underline, padding, labelwidget, width, height zttk::labelframeNrrr'r'r(rxs zLabelframe.__init__)Nrr'r'r'r(rsc@seZdZdZdddZdS)r zbTtk Menubutton widget displays a textual label and/or image, and displays a menu when pressed.NcKst||d|dS)aConstruct a Ttk Menubutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS direction, menu zttk::menubuttonNrrr'r'r(rxs zMenubutton.__init__)Nrr'r'r'r(r sc@sneZdZdZdddZddZddZd d Zd d Zd dZ ddZ dddZ dddZ ddZ ddZdS)r zTtk Notebook widget manages a collection of windows and displays a single one at a time. Each child window is associated with a tab, which the user may select to change the currently-displayed window.NcKst||d|dS)a\Construct a Ttk Notebook with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS height, padding, width TAB OPTIONS state, sticky, padding, text, image, compound, underline TAB IDENTIFIERS (tab_id) The tab_id argument found in several methods may take any of the following forms: * An integer between zero and the number of tabs * The name of a child window * A positional specification of the form "@x,y", which defines the tab * The string "current", which identifies the currently-selected tab * The string "end", which returns the number of tabs (only valid for method index) z ttk::notebookNrrr'r'r(rx"szNotebook.__init__cKs |jj|jd|ft|dS)zAdds a new tab to the notebook. If window is currently managed by the notebook but hidden, it is restored to its previous position.addNr#rhrr6)rwchildrFr'r'r(rBsz Notebook.addcCs|j|jd|dS)zXRemoves the tab specified by tab_id, unmaps and unmanages the associated window.forgetNrrwtab_idr'r'r(rJszNotebook.forgetcCs|j|jd|dS)zHides the tab specified by tab_id. The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the add command.hideNrrr'r'r(rPsz Notebook.hidecCs|j|jd||S)zZReturns the name of the tab element at position x, y, or the empty string if none.rrrr'r'r(rYszNotebook.identifycCs|j|j|jd|S)z|Returns the numeric index of the tab specified by tab_id, or the total number of tabs if tab_id is the string "end".rrrr'r'r(r_szNotebook.indexcKs"|jj|jd||ft|dS)zInserts a pane at the specified position. pos is either the string end, an integer index, or the name of a managed child. If child is already managed by the notebook, moves it to the specified position.insertNrrwposrrFr'r'r(reszNotebook.insertcCs|j|jd|S)zSelects the specified tab. The associated child window will be displayed, and the previously-selected window (if different) is unmapped. If tab_id is omitted, returns the widget name of the currently selected pane.selectrrr'r'r(rnszNotebook.selectcKs$|dk rd||<t|j||jd|S)zQuery or modify the options of the specific tab_id. If kw is not given, returns a dict of the tab option values. If option is specified, returns the value of that option. Otherwise, sets the options to the corresponding values.Ntabrkr#r)rwrrrFr'r'r(rxsz Notebook.tabcCs|j|j|jdpdS)z2Returns a list of windows managed by the notebook.tabsr'r#rcrhrrr'r'r(rsz Notebook.tabscCs|jd|jdS)aEnable keyboard traversal for a toplevel window containing this notebook. This will extend the bindings for the toplevel window containing this notebook as follows: Control-Tab: selects the tab following the currently selected one Shift-Control-Tab: selects the tab preceding the currently selected one Alt-K: where K is the mnemonic (underlined) character of any tab, will select that tab. Multiple notebooks in a single toplevel may be enabled for traversal, including nested notebooks. However, notebook traversal only works properly if all panes are direct children of the notebook.zttk::notebook::enableTraversalNrrr'r'r(enable_traversalszNotebook.enable_traversal)N)N)N)rrrrrxrrrrrrrrrrr'r'r'r(r s   c@s>eZdZdZd ddZejjZddZd ddZ d d d Z dS)r zfTtk Panedwindow widget displays a number of subwindows, stacked either vertically or horizontally.NcKst||d|dS)zConstruct a Ttk Panedwindow with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient, width, height PANE OPTIONS weight zttk::panedwindowNrrr'r'r(rxszPanedwindow.__init__cKs"|jj|jd||ft|dS)zInserts a pane at the specified positions. pos is either the string end, and integer index, or the name of a child. If child is already managed by the paned window, moves it to the specified position.rNrrr'r'r(rszPanedwindow.insertcKs$|dk rd||<t|j||jd|S)aQQuery or modify the options of the specified pane. pane is either an integer index or the name of a managed subwindow. If kw is not given, returns a dict of the pane option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.Npaner)rwrrrFr'r'r(rszPanedwindow.panecCs|j|j|jd||S)aLIf newpos is specified, sets the position of sash number index. May adjust the positions of adjacent sashes to ensure that positions are monotonically increasing. Sash positions are further constrained to be between 0 and the total size of the widget. Returns the new position of sash number index.sashposr)rwrZnewposr'r'r(rszPanedwindow.sashpos)N)N)N) rrrrrxrvr rrrrr'r'r'r(r s   c@s6eZdZdZd ddZd ddZd ddZd d ZdS)r a6Ttk Progressbar widget shows the status of a long-running operation. They can operate in two modes: determinate mode shows the amount completed relative to the total amount of work to be done, and indeterminate mode provides an animated display to let the user know that something is happening.NcKst||d|dS)zConstruct a Ttk Progressbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient, length, mode, maximum, value, variable, phase zttk::progressbarNrrr'r'r(rxs zProgressbar.__init__cCs|j|jd|dS)zBegin autoincrement mode: schedules a recurring timer event that calls method step every interval milliseconds. interval defaults to 50 milliseconds (20 steps/second) if omitted.startNr)rwZintervalr'r'r(rszProgressbar.startcCs|j|jd|dS)zRIncrements the value option by amount. amount defaults to 1.0 if omitted.stepNr)rwZamountr'r'r(rszProgressbar.stepcCs|j|jddS)zVStop autoincrement mode: cancels any recurring timer event initiated by start.stopNrrr'r'r(rszProgressbar.stop)N)N)N)rrrrrxrrrr'r'r'r(r s    c@s"eZdZdZdddZddZdS)rzeTtk Radiobutton widgets are used in groups to show or change a set of mutually-exclusive options.NcKst||d|dS)aConstruct a Ttk Radiobutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, value, variable zttk::radiobuttonNrrr'r'r(rx s zRadiobutton.__init__cCs|j|jdS)zSets the option variable to the option value, selects the widget, and invokes the associated command. Returns the result of the command, or an empty string if no command is specified.rrrr'r'r(rszRadiobutton.invoke)Nrr'r'r'r(rs c@s.eZdZdZd ddZd ddZd ddZdS) rzTtk Scale widget is typically used to control the numeric value of a linked variable that varies uniformly over some range.NcKst||d|dS)zConstruct a Ttk Scale with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, from, length, orient, to, value, variable z ttk::scaleNrrr'r'r(rx's zScale.__init__cKsTtj||f|}t|tdtfs,||td|kd|kd|kgrP|d|S)zModify or query scale options. Setting a value for any of the "from", "from_" or "to" options generates a <> event.NrCfrom_to<>)rrQr*typer[updateanyZevent_generate)rwZcnfrFZretvalr'r'r(rQ5s   zScale.configurecCs|j|jd||S)zGet the current value of the value option, or the value corresponding to the coordinates x, y if they are specified. x and y are pixel coordinates relative to the scale widget origin.r"rrr'r'r(r"Bsz Scale.get)N)N)NN)rrrrrxrQr"r'r'r'r(r#s  c@seZdZdZdddZdS)rz;Ttk Scrollbar controls the viewport of a scrollable widget.NcKst||d|dS)zConstruct a Ttk Scrollbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, orient zttk::scrollbarNrrr'r'r(rxNs zScrollbar.__init__)Nrr'r'r'r(rKsc@seZdZdZdddZdS)rzITtk Separator widget displays a horizontal or vertical separator bar.NcKst||d|dS)zConstruct a Ttk Separator with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient zttk::separatorNrrr'r'r(rx`s zSeparator.__init__)Nrr'r'r'r(r\sc@seZdZdZdddZdS)rzlTtk Sizegrip allows the user to resize the containing toplevel window by pressing and dragging the grip.NcKst||d|dS)zConstruct a Ttk Sizegrip with parent master. STANDARD OPTIONS class, cursor, state, style, takefocus z ttk::sizegripNrrr'r'r(rxrszSizegrip.__init__)Nrr'r'r'r(rnsc@s"eZdZdZdddZddZdS)rzTtk Spinbox is an Entry with increment and decrement arrows It is commonly used for number entry or to select from a list of string values. NcKstj||df|dS)a/Construct a Ttk Spinbox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, validate, validatecommand, xscrollcommand, invalidcommand WIDGET-SPECIFIC OPTIONS to, from_, increment, values, wrap, format, command z ttk::spinboxNrrr'r'r(rxs zSpinbox.__init__cCs|j|jd|dS)z'Sets the value of the Spinbox to value.rNrrr'r'r(rsz Spinbox.set)N)rrrrrxrr'r'r'r(r|s c@s4eZdZdZdEddZdFddZdGddZd d ZdHd d Zd dZ ddZ ddZ dIddZ dJddZ ddZddZddZddZdd Zd!d"ZdKd#d$ZdLd%d&Zd'd(ZeZd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!dMd=d>Z"dNd?d@Z#dOdAdBZ$dPdCdDZ%dS)QrzTtk Treeview widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label.NcKst||d|dS)aConstruct a Ttk Treeview with parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand, yscrollcommand WIDGET-SPECIFIC OPTIONS columns, displaycolumns, height, padding, selectmode, show ITEM OPTIONS text, image, values, open, tags TAG OPTIONS foreground, background, font, image z ttk::treeviewNrrr'r'r(rxszTreeview.__init__cCs||j|jd||pdS)aTReturns the bounding box (relative to the treeview widget's window) of the specified item in the form x y width height. If column is specified, returns the bounding box of that cell. If the item is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.rr8r)rwitemcolumnr'r'r(rsz Treeview.bboxcCs"|j|j|jd|pdpdS)zhReturns a tuple of children belonging to item. If item is not specified, returns root children.rJr8r'rrwrr'r'r( get_childrenszTreeview.get_childrencGs|j|jd||dS)zReplaces item's child with newchildren. Children present in item that are not present in newchildren are detached from tree. No items in newchildren may be an ancestor of item.rJNr)rwrZ newchildrenr'r'r( set_childrenszTreeview.set_childrencKs$|dk rd||<t|j||jd|S)a Query or modify the options for the specified column. If kw is not given, returns a dict of the column option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.Nrr)rwrrrFr'r'r(rszTreeview.columncGs|j|jd|dS)z_Delete all specified items and all their descendants. The root item may not be deleted.deleteNrrwr1r'r'r(rszTreeview.deletecGs|j|jd|dS)zUnlinks all of the specified items from the tree. The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed. The root item may not be detached.detachNrrr'r'r(rszTreeview.detachcCs|j|j|jd|S)zSReturns True if the specified item is present in the tree, False otherwise.existsrrr'r'r(rszTreeview.existscCs|j|jd|S)z}If item is specified, sets the focus item to item. Otherwise, returns the current focus item, or '' if there is none.focusrrr'r'r(rszTreeview.focuscKsP|d}|r,t|ts,|j||j|d<|dk rt|dkr&t|dttfr&|d}|j|jd||dS)Nr7rr)r:r*r,r+r#rhr)rwZselopr1r'r'r( _selectionszTreeview._selectioncGs|d|dS)z.The specified items becomes the new selection.rNrrr'r'r( selection_setszTreeview.selection_setcGs|d|dS)z0Add all of the specified items to the selection.rNrrr'r'r( selection_addszTreeview.selection_addcGs|d|dS)z5Remove all of the specified items from the selection.removeNrrr'r'r(selection_removeszTreeview.selection_removecGs|d|dS)z2Toggle the selection state of each specified item.ZtoggleNrrr'r'r(selection_toggleszTreeview.selection_togglecCs@|j|jd|||}|dkr8|dkr8t|j|dtdS|SdS)a;Query or set the value of given item. With one argument, return a dictionary of column/value pairs for the specified item. With two arguments, return the current value of the specified column. With three arguments, set the value of given column in given item to the specified value.rNF)Z cut_minusrg)r#rhrrri)rwrrr-rfr'r'r(rsz Treeview.setcCs |j|jdd|f||dddS)zBind a callback for the given event sequence to the tag tagname. When an event is delivered to an item, the callbacks for each of the item's tags option are called.tagbindr)rN)Z_bindr)rwtagnameZsequencerr'r'r(tag_bindszTreeview.tag_bindcKs&|dk rd||<t|j||jdd|S)aBQuery or modify the options for the specified tagname. If kw is not given, returns a dict of the option settings for tagname. If option is specified, returns the value for that option for the specified tagname. Otherwise, sets the options to the corresponding values for the given tagname.NrrQr)rwrrrFr'r'r( tag_configures zTreeview.tag_configurec CsF|dkr$|j|j|jdd|S|j|j|jdd||SdS)zIf item is specified, returns 1 or 0 depending on whether the specified item has the given tagname. Otherwise, returns a list of all items which have the specified tag. * Availability: Tk 8.6NrZhas)r#rcrhrr)rwrrr'r'r(tag_hasszTreeview.tag_has)N)N)N)N)N)N)N)N)NN)NN)N)N)&rrrrrxrrrrrrrrrrrrrrrrrrZreattachrrrrrrrrrrrrrrr'r'r'r(rsF              csLeZdZdZdddZfddZd d Zed d Zej d d ZZ S)rzA Ttk Scale widget with a Ttk Label widget indicating its current value. The Ttk Scale can be accessed through instance.scale, and Ttk Label can be accessed through instance.labelNr c Ks|dddk|_tj||f||p.t||_|j|||_t ||_ t ||j||d|_ |j d|j|jr|dnd}|dkrdnd}|j j|ddt |}|j|d||j j|dkrd nd d |jd |j|_| d |j| d|jdS)aConstruct a horizontal LabeledScale with parent master, a variable to be associated with the Ttk Scale widget and its range. If variable is not specified, a tkinter.IntVar is created. WIDGET-SPECIFIC OPTIONS compound: 'top' or 'bottom' Specifies how to display the label relative to the scale. Defaults to 'top'. Zcompoundtop)variablerrrZbottomrr)sideZfill)rrrW)Zanchorwz zN)pop _label_toprrxrvZIntVar _variabler _last_validrlabelrscaler_adjustZpacklowerZplaceZtrace_variable_LabeledScale__tracecb) rwr&rrrrFZ scale_sideZ label_sideZdummyr'r'r(rxs$    zLabeledScale.__init__csHz|jd|jWntk r(YnX|`td|_d|_dS)z9Destroy this widget and possibly its associated variable.rN)rZ trace_vdeleterAttributeErrorsuperdestroyrrr __class__r'r(r s zLabeledScale.destroycsfdd}tjd}tjd}||kr:||}}j}||krX|ksfnj_dS|_|jd<|dS)z1Adjust the label position according to the scale.csZj\}}jr2jj}njj}jj||ddS)Nrrr)Zupdate_idletasksrZcoordsrZwinfo_yrZwinfo_reqheightZplace_configurer rr'r( adjust_labels z*LabeledScale._adjust..adjust_labelrCrNtext)rsrrr"rr-rZ after_idle)rwrEr rrZnewvalr'rr(rs    zLabeledScale._adjustcCs |jS)zReturn current scale value.)rr"rr'r'r(r-4szLabeledScale.valuecCs|j|dS)zSet new scale value.N)rr)rwr=r'r'r(r-9s)NNrr) rrrrrxrrpropertyr-setter __classcell__r'r'r r(rs &  cs<eZdZdZd ddZddZd ddZfd d ZZS) rzmThemed OptionMenu, based after tkinter's OptionMenu, which allows the user to select a value from a menu.NcOs||dd|ddd}tj||f|tj|dd|d<||_|dd|_|rptd tt | |j |f|dS) a9Construct a themed OptionMenu widget with master as the parent, the resource textvariable set to variable, the initially selected value specified by the default parameter, the menu values given by *values and additional keywords. WIDGET-SPECIFIC OPTIONS style: stylename Menubutton style. direction: 'above', 'below', 'left', 'right', or 'flush' Menubutton direction. command: callback A callback that will be invoked after selecting an item. r{N direction)Z textvariabler{rF)Ztearoffmenurzunknown option -%s) rr rxrvZMenur _callbackZTclErrorrr\keysset_menu)rwr&rrvalueskwargsrFr'r'r(rxCs  zOptionMenu.__init__cCs&|dkr|t||St||S)Nr)Z nametowidgetr __getitem__rr'r'r(r`szOptionMenu.__getitem__cGsR|d}|dd|D]$}|j|t|j||j|jdq|rN|j|dS)zUBuild a new menu of radiobuttons with *values and optionally a default value.rrend)rrrN)rZadd_radiobuttonrvZ_setitrrr)rwrrrr=r'r'r(rgs zOptionMenu.set_menucs,z|`Wntk rYnXtdS)z0Destroy this widget and its associated variable.N)rrrrrr r'r(rus zOptionMenu.destroy)N)N) rrrrrxrrrrr'r'r r(r?s   )F)FN)F)F)rrB)N)6r __version__ __author____all__rvrrrrZ TkVersionrr)r/r6r>r@rIrLrYrarerkrorsrirrobjectrrrrrrrrrrr r r r r rrrrrrZXViewZYViewrrrr'r'r'r(s     % 1*   *B*"8*(J`PK!i((+__pycache__/filedialog.cpython-38.opt-2.pycnu[U e5d8@s ddlTddlmZddlmZddlmZddlZddlZiZGdddZ Gdd d e Z Gd d d e Z Gd d d ejZ Gddde Z Gddde ZGdddejZddZddZddZd'ddZd(ddZd)d d!Zd"d#Zd$d%Zed&kredS)*)*)Dialog) commondialog) _setup_dialogNc@seZdZdZd#ddZejdddfddZd$d d Zd d Z d dZ ddZ ddZ ddZ ddZd%ddZddZddZd&ddZdd Zd!d"ZdS)' FileDialogzFile Selection DialogNcCs|dkr|j}||_d|_t||_|j||j|t|jt|j|_|jj t t dt |j|_ |j j t t d|j d|jt |j|_|jj tt d|jd|jt|j|_|jj ttdt|j|_|jj ttdt|jd|jdfd|_|jj tttd|j}|j|dd|dd|jd |j|jd |j|jj|jd fd t|j|_ |j j t!tdt|jd|j dfd|_"|j"j t!ttd|j j|j"d fd |j"}|j"|dd|dd|j"d |j#|j"d |j$t%|jd |j&d|_'|j'j t!dt%|jd|jd|_(|j(j t!tdt%|jd|j)d|_*|j*j td|j+d|j)|jd|j)|jd|j)dS)N)sidefillz)expandrrset)ZexportselectionZyscrollcommand)rr rzzZyview)commandZOK)textr )rZFilter)rr CancelZWM_DELETE_WINDOWzz),titlemaster directoryZTopleveltopZiconnamerZFrameZbotframeZpackZBOTTOMXZEntry selectionZbindok_eventfilterZTOPfilter_commandZmidframeZYESZBOTHZ ScrollbarZfilesbarZRIGHTYZListboxfilesZbindtagsfiles_select_eventfiles_double_eventZconfigZdirsbarZLEFTdirsdirs_select_eventdirs_double_eventZButton ok_commandZ ok_buttonZ filter_buttoncancel_commandZ cancel_buttonZprotocol)selfrrZbtagsr"*/usr/lib64/python3.8/tkinter/filedialog.py__init__4st              zFileDialog.__init__rcCs|r|tkrt|\|_}n2tj|}tj|r<||_ntj|\|_}||j|||| |j |j |j d|_|j|r|\}}|jrtj|j}||ft|<|j |jSN) dialogstatesrospath expanduserisdirsplit set_filter set_selectionrrZ focus_setrZwait_visibilityZgrab_sethowrZmainloop get_filterdirnameZdestroy)r!Z dir_or_filepatterndefaultkeyrr"r"r#gots*           z FileDialog.gocCs||_|jdSr&)r/rquit)r!r/r"r"r#r6szFileDialog.quitcCs |dSr&)rr!eventr"r"r#rszFileDialog.dirs_double_eventcCs@|\}}|jd}tjtj|j|}|||dSNZactive) r0rgetr(r)normpathjoinrr-)r!r8dirpatZsubdirr"r"r#rs  zFileDialog.dirs_select_eventcCs |dSr&rr7r"r"r#rszFileDialog.files_double_eventcCs|jd}||dSr9)rr:r.)r!r8filer"r"r#rs zFileDialog.files_select_eventcCs |dSr&r?r7r"r"r#rszFileDialog.ok_eventcCs||dSr&)r6 get_selectionr!r"r"r#rszFileDialog.ok_commandc Cs&|\}}zt|}Wn tk r:|jYdSX||_||||tj g}g}|D]@}tj ||}tj |r| |qft||rf| |qf|jdt|D]}|jt|q|jdt|D]}|jt|qtj |\} } | tjkrd} || dS)Nrr%)r0r(listdirOSErrorrbellrr-sortpardirr)r<r+appendfnmatchrdeleteENDinsertrr,rAcurdirr.) r!r8r=r>namesZsubdirsZ matchingfilesnamefullnameheadtailr"r"r#rs6        zFileDialog.filter_commandcCsN|j}tj|}|ddtjks4tj|rBtj|d}tj|S)Nr) rr:r(r)r*sepr+r<r,)r!rr"r"r#r0s   zFileDialog.get_filtercCs|j}tj|}|Sr&)rr:r(r)r*r!r@r"r"r#rAs  zFileDialog.get_selectioncCs |dSr&)r6r7r"r"r#r szFileDialog.cancel_commandcCstj|sPz t}Wntk r0d}YnX|rPtj||}tj|}|jdt |j t tj|pttj |pzddS)Nrr) r(r)isabsgetcwdrDr<r;rrJrKrLrM)r!r=r>pwdr"r"r#r-s    zFileDialog.set_filtercCs,|jdt|jttj|j|dS)Nr)rrJrKrLr(r)r<rrUr"r"r#r.szFileDialog.set_selection)N)N)N)N)__name__ __module__ __qualname__rr$r(rMr5r6rrrrrrrr0rAr r-r.r"r"r"r#rs  @    rc@seZdZdZddZdS)LoadFileDialogzLoad File Selection DialogcCs.|}tj|s |jn ||dSr&)rAr(r)isfilerrEr6rUr"r"r#rs  zLoadFileDialog.ok_commandNrYrZr[rrr"r"r"r#r\sr\c@seZdZdZddZdS)SaveFileDialogzSave File Selection DialogcCs|}tj|rZtj|r.|jdSt|jdd|fdddd}|j dkrdSn*tj |\}}tj|s|jdS| |dS)Nz Overwrite Existing File QuestionzOverwrite existing file %r?Z questheadr )ZYesr)rr Zbitmapr3Zstringsr) rAr(r)existsr+rrErrZnumr,r6)r!r@drQrRr"r"r#rs&      zSaveFileDialog.ok_commandNr^r"r"r"r#r_sr_c@seZdZddZddZdS)_DialogcCs2zt|jd|jd<Wntk r,YnXdS)N filetypes)tupleoptionsKeyErrorrBr"r"r# _fixoptions,sz_Dialog._fixoptionscCsR|rHz |j}Wntk r"YnXtj|\}}||jd<||jd<||_|S)N initialdirZ initialfile)stringAttributeErrorr(r)r,refilenamer!widgetresultr)r@r"r"r# _fixresult3s   z_Dialog._fixresultN)rYrZr[rgror"r"r"r#rb*srbc@seZdZdZddZdS)OpenZtk_getOpenFilecCsxt|trBtdd|D}|r>tj|d\}}||jd<|S|jsjd|jkrj|||j |St |||S)NcSsg|]}t|d|qS)ri)getattr).0rr"r"r# Nsz#Open._fixresult..rrhmultiple) isinstancerdr(r)r,reZtkZ wantobjectsroZ splitlistrbrlr"r"r#roKs  zOpen._fixresultNrYrZr[r ror"r"r"r#rpFsrpc@seZdZdZdS)SaveAsZtk_getSaveFileN)rYrZr[r r"r"r"r#rxZsrxc@seZdZdZddZdS) DirectoryZtk_chooseDirectorycCs8|r.z |j}Wntk r"YnX||jd<||_|S)Nrh)rirjrer)r!rmrnr"r"r#rofs  zDirectory._fixresultNrwr"r"r"r#ryasrycKstf|Sr&rpshowrer"r"r#askopenfilenamewsr}cKstf|Sr&)rxr{r|r"r"r#asksaveasfilename}sr~cKsd|d<tf|S)Nr rurzr|r"r"r#askopenfilenamessrrscKs tf|}|rt||SdSr&)rpr{openmodererkr"r"r# askopenfiles rcKs4tf|}|r0g}|D]}|t||q|}|Sr&)rrHr)rrerZofilesrkr"r"r# askopenfiless rwcKs tf|}|rt||SdSr&)rxr{rrr"r"r# asksaveasfiles rcKstf|Sr&)ryr{r|r"r"r# askdirectorysrc Cst}|t|}|jdd}t|}|jdd}t||d}ddl}z&ddl}||j d| |j }Wnt t fk rYnXtdgd}zt|d}|Wn$td t|d YnXtd ||t} td | |dS) Ntest)r4zutf-8rr%)z all filesr)rcrszCould not open File: r rZsaveas)ZTkZwithdrawr\r5r_printsyslocale setlocaleLC_ALL nl_langinfoCODESET ImportErrorrjr}rcloseexc_infoencoder~) rootfdZloadfileZsavefileencrrZ openfilenamefpZsaveasfilenamer"r"r#rs2      r__main__)rs)rs)r)ZtkinterZtkinter.dialogrrZtkinter.simpledialogrr(rIr'rr\r_rbrprxryr}r~rrrrrrrYr"r"r"r#s0   I9  , PK!vZZ-__pycache__/commondialog.cpython-38.opt-1.pycnu[U e5d@sddlTGdddZdS))*c@s2eZdZdZd ddZddZddZdd ZdS) DialogNcKs|s|d}||_||_dS)Nparent)getmasteroptions)selfrrr ,/usr/lib64/python3.8/tkinter/commondialog.py__init__s zDialog.__init__cCsdSNr )rr r r _fixoptionsszDialog._fixoptionscCs|Sr r )rZwidgetresultr r r _fixresultszDialog._fixresultc Ks||D]\}}||j|<q|t|j}z,|jj|jf| |j}| ||}W5z |Wn YnXX|Sr ) itemsrr ZFramerZdestroyZtkZcallcommandZ_optionsr)rrkvwsr r r shows   z Dialog.show)N)__name__ __module__ __qualname__rr r rrr r r r rs  rN)Ztkinterrr r r r  sPK!T—||__pycache__/ttk.cpython-38.pycnu[U e5d@sdZdZdZddddddd d d d d ddddddddddddddgZddlZddlmZmZmZmZej dkrpd nd!Z d"d#Z dXd$d%Z dYd&d'Z d(d)ZdZd*d+Zd[d,d-Zd\d/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Zd?dZd]d@dZGdAddeZGdBdCdCejZGdDddeZGdEddeZGdFddeej Z GdGdde Z!GdHddeZ"GdIddeZ#GdJd d eZ$e$Z%GdKd d eZ&GdLd d eZ'GdMd d eej(Z)e)Z(GdNddeZ*GdOddeZ+GdPddeej,Z,GdQddeej-Z-GdRddeZ.GdSddeZ/GdTdde Z0GdUddeej1ej2Z3GdVdde"Z4GdWdde&Z5dS)^aTtk wrapper. This module provides classes to allow using Tk themed widget set. Ttk is based on a revised and enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style engine. Its basic idea is to separate, to the extent possible, the code implementing a widget's behavior from the code implementing its appearance. Widget class bindings are primarily responsible for maintaining the widget state and invoking callbacks, all aspects of the widgets appearance lies at Themes. z0.3.1z!Guilherme Polo Button CheckbuttonComboboxEntryFrameLabel Labelframe LabelFrame MenubuttonNotebook Panedwindow PanedWindow Progressbar RadiobuttonScale Scrollbar SeparatorSizegripSpinboxStyleTreeview LabeledScale OptionMenu tclobjs_to_py setup_masterN)_flatten_join _stringify _splitdictg!@TFcCsBtr>ddl}|jd}|r,|jd||jdd|_dS)NrZ TILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT) _REQUIRE_TILEosenvirongettkeval _tile_loaded)masterr Ztilelibr'#/usr/lib64/python3.8/tkinter/ttk.py _load_tile"s  r)cCs(|rt|}nt|ttfr$t|}|S)zInternal function.)r isinstancelisttupler)valuescriptr'r'r(_format_optvalue1s  r/cCsPg}|D]:\}}|r ||kr |d||dk r |t||q t|S)zFormats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')-%sN)itemsappendr/r)Zoptdictr.ignoreoptsoptr-r'r'r(_format_optdict;s r6cCsXg}|D]J^}}t|dkr,|dp(d}n d|}|||dk r||q|S)Nr )lenjoinr2)r1Zopt_valstatevalr'r'r(_mapdict_valuesKs    r>cCs:g}|D]$\}}|d|tt||fq t|S)zFormats mapdict to pass it to tk.call. E.g. (script=False): {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]} returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')r0)r1extendr/r>r)Zmapdictr.r4r5r-r'r'r(_format_mapdict`s   r@c Osd}d}|dkr|dkrB|d}tt|dd}d||f}n2|dd\}} tt|dd} d || | f}t||}n,|d kr|d}t|dkrt|d|f}|rd |}d |}||fS) zAFormats args and kw according to the given element factory etype.Nr')imageZvsapirArr7z%s %sz%s %s %sfromz{%s}r9)rr>r6r:r/r;) etyper.argskwspecr4ZinameZ imagespec class_nameZpart_idZstatemapr'r'r(_format_elemcreateqs&   rIrBc Csg}|D]}|\}}|pi}dt|dd}dd|||rDd|ndf}d|kr||d||7}t|d||\} }|| ||8}|d d|q||qd ||fS) a$Formats a layout list so we can pass the result to ttk::style layout and ttk::style settings. Note that the layout doesn't have to be a list necessarily. E.g.: [("Menubutton.background", None), ("Menubutton.button", {"children": [("Menubutton.focus", {"children": [("Menubutton.padding", {"children": [("Menubutton.label", {"side": "left", "expand": 1})] })] })] }), ("Menubutton.indicator", {"side": "right"}) ] returns: Menubutton.background Menubutton.button -children { Menubutton.focus -children { Menubutton.padding -children { Menubutton.label -side left -expand 1 } } } Menubutton.indicator -side rightr9T)childrenz%s%s%sz %sr8rJz -children {z%s} )r;r6r2_format_layoutlist) layoutindentZ indent_sizer.Z layout_elemelemr4ZfoptsheadZ newscriptr'r'r(rLs"   rLc CsXg}|D]>\}}|drFdt|dd}|d||f|drvdt|dd}|d||fd|kr|dsd}nt|d\}}|d ||f|d r |d }|d }d }|t|krt||d s|d 7}q|d |} |t|kr||r||ni} t |df| | \} }|d||| |fq d|S)zReturns an appropriate script, based on settings, according to theme_settings definition to be used by theme_settings and theme_create. configurer9Tzttk::style configure %s %s;mapzttk::style map %s %s;rMnullzttk::style layout %s { %s }zelement createrr7r1z%ttk::style element create %s %s %s %srK) r1r"r;r6r2r@rLr:hasattrrI) settingsr.namer4s_ZeoptsrDZargcZelemargsZelemkwrGr'r'r(_script_from_settingss:     $ rYcCst|tr|Sg}t|}t||D]j\}}t|drDt|}n(t|trX|}nt|ttfsl|f}t|dr~t|}|||fq$|S)ztConstruct a list from the given statespec tuple according to the accepted statespec accepted by _format_mapdict.typename) r*striterziprTsplitr,r+r2)Zstupleresultitr<r=r'r'r(_list_from_statespecs     racCs||}g}d}|t|kr||}i}|||f|d7}|t|kr|||d\}}|dslq|dd}|d7}|dkrt||}|||<q@q|S)zpConstruct a list from the tuple returned by ttk::layout, this is somewhat the reverse of _format_layoutlist.rr7rB-NrJ) splitlistr:r2 startswith_list_from_layouttuple)r#ZltupleresZindxrVr4r5r=r'r'r(res$       recGs4t|}|j||}t|dr&|St||tdS)ahFormat options then call Tk command with args and options and return the appropriate result. If no option is specified, a dict is returned. If an option is specified with the None value, the value for that option is returned. Otherwise, the function just sets the passed options and the caller shouldn't be expecting a return value anyway.rB)conv)r6callr:r _tclobj_to_py)r#optionsrErfr'r'r( _val_or_dict!s  rkc Cs2t|}z t|}Wnttfk r,YnX|S)zAConverts a value to, hopefully, a more appropriate Python object.)r[int ValueError TypeError)r-r'r'r(_convert_stringval1s  rocCs(t|tr$d|krt|}nt|}|S)N.)r*r[floatrl)xr'r'r( _to_number;s   rscCs\|rFt|drFt|tsFt|ddddkr6t|}qXttt|}nt|drXt|}|S)z8Return value converted from Tcl object to Python object.__len__rrZNZ StateSpec)rTr*r[getattrrar+rRro)r=r'r'r(riCs  ricCs"|D]\}}t|||<q|S)zOReturns adict with its values converted from Tcl objects to Python objects.)r1ri)Zadictr5r=r'r'r(rPscCs|dkrt}|S)aIf master is not None, itself is returned. If master is None, the default master is returned if there is one, otherwise a new master is created and returned. If it is not allowed to use the default root and master is None, RuntimeError is raised.N)tkinterZ_get_default_root)r&r'r'r(rXsc@seZdZdZdZdddZdddZddd Zdd d Zd d d Z ddZ ddZ ddZ d!ddZ ddZddZd"ddZdS)#rzManipulate style database.z ttk::styleNcCs0t|}t|ddst|||_|jj|_dS)Nr%F)rrur)r&r#)selfr&r'r'r(__init__is  zStyle.__init__cKs4|dk rd||<t|j||jd|}|s,|r0|SdS)zQuery or sets the default value of the specified option(s) in style. Each key in kw is an option and each value is either a string or a sequence identifying the value for that option.NrQ)rkr#_namerwstyleZ query_optrFr_r'r'r(rQts zStyle.configurec sj|dk r0jjd|d|}tj|Sjjjd|ft|}fddtj|DS)aSQuery or sets dynamic values of the specified option(s) in style. Each key in kw is an option and each value should be a list or a tuple (usually) containing statespecs grouped in tuples, or list, or something else of your preference. A statespec is compound of one or more states and then a value.NrRr0cs"i|]\}}|tj|qSr')rar#rc).0kvrwr'r( szStyle.map..)r#rhryrarcr@rr1rzr'rr(rRs z Style.mapcCs.|rd|nd}|j|jd|d|||S)aReturns the value specified for option in style. If state is specified it is expected to be a sequence of one or more states. If the default argument is set, it is used as a fallback value in case no specification for option is found.r9r8lookupr0)r;r#rhry)rwr{optionr<defaultr'r'r(rs z Style.lookupcCs>d}|rt|d}n |dk r"d}t|j|j|jd||S)aDefine the widget layout for given style. If layoutspec is omitted, return the layout specification for given style. layoutspec is expected to be a list or an object different than None that evaluates to False if you want to "turn off" that style. If it is a list (or tuple, or something else), each item should be a tuple where the first item is the layout name and the second item should have the format described below: LAYOUTS A layout can contain the value None, if takes no options, or a dict of options specifying how to arrange the element. The layout mechanism uses a simplified version of the pack geometry manager: given an initial cavity, each element is allocated a parcel. Valid options/values are: side: whichside Specifies which side of the cavity to place the element; one of top, right, bottom or left. If omitted, the element occupies the entire cavity. sticky: nswe Specifies where the element is placed inside its allocated parcel. children: [sublayout... ] Specifies a list of elements to place inside the element. Each element is a tuple (or other sequence) where the first item is the layout name, and the other is a LAYOUT.NrrSrM)rLrer#rhry)rwr{Z layoutspecZlspecr'r'r(rMs z Style.layoutcOs8t|df||\}}|jj|jdd|||f|dS)z9Create a new element in the current theme of given etype.FelementcreateN)rIr#rhry)rw elementnamerDrErFrGr4r'r'r(element_creates zStyle.element_createc Cs(tdd|j|j|jddDS)z:Returns the list of elements defined in the current theme.css|]}|dVqdSrbNlstrip)r|nr'r'r( sz&Style.element_names..rnamesr,r#rcrhryrr'r'r( element_namesszStyle.element_namesc Cs*tdd|j|j|jdd|DS)z)Return the list of elementname's options.css|]}|dVqdSrr)r|or'r'r(rsz(Style.element_options..rrjr)rwrr'r'r(element_optionsszStyle.element_optionsc CsN|r t|nd}|r2|j|jdd|d|d|n|j|jdd|d|dS)a.Creates a new theme. It is an error if themename already exists. If parent is specified, the new theme will inherit styles, elements and layouts from the specified parent theme. If settings are present, they are expected to have the same syntax used for theme_settings.r8themerz-parentz -settingsNrYr#rhry)rw themenameparentrUr.r'r'r( theme_createszStyle.theme_createcCs"t|}|j|jdd||dS)aTemporarily sets the current theme to themename, apply specified settings and then restore the previous theme. Each key in settings is a style and each value may contain the keys 'configure', 'map', 'layout' and 'element create' and they are expected to have the same format as specified by the methods configure, map, layout and element_create respectively.rrUNr)rwrrUr.r'r'r(theme_settingsszStyle.theme_settingscCs|j|j|jddS)z#Returns a list of all known themes.rr)r#rcrhryrr'r'r( theme_namesszStyle.theme_namescCs&|dkr|jdS|jd|dS)zIf themename is None, returns the theme in use, otherwise, set the current theme to themename, refreshes all widgets and emits a <> event.Nzreturn $ttk::currentThemez ttk::setTheme)r#r$rh)rwrr'r'r( theme_uses zStyle.theme_use)N)N)N)NN)N)NN)N)__name__ __module__ __qualname____doc__ryrxrQrRrrMrrrrrrrr'r'r'r(rds  +  c@s6eZdZdZd ddZddZd ddZd d d ZdS)Widgetz!Base class for Tk themed widgets.NcCs4t|}t|ddst|tjj||||ddS)aConstructs a Ttk Widget with the parent master. STANDARD OPTIONS class, cursor, takefocus, style SCROLLABLE WIDGET OPTIONS xscrollcommand, yscrollcommand LABEL WIDGET OPTIONS text, textvariable, underline, image, compound, width WIDGET STATES active, disabled, focus, pressed, selected, background, readonly, alternate, invalid r%F)rFN)rrur)rvrrx)rwr&Z widgetnamerFr'r'r(rxs zWidget.__init__cCs|j|jd||S)zReturns the name of the element at position x, y, or the empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget.identifyr#rh_wrwrryr'r'r(r+szWidget.identifyc Os6|j|j|jdd|}|r2|r2|||S|S)a1Test the widget's state. If callback is not specified, returns True if the widget state matches statespec and False otherwise. If callback is specified, then it will be invoked with *args, **kw if the widget state matches statespec. statespec is expected to be a sequence.instater9)r# getbooleanrhrr;)rw statespeccallbackrErFZretr'r'r(r3s  zWidget.instatecCs0|dk rd|}|jt|j|jd|S)aModify or inquire widget state. Widget state is returned if statespec is None, otherwise it is set according to the statespec flags and then a new state spec is returned indicating which flags were changed. statespec is expected to be a sequence.Nr9r<)r;r#rcr[rhr)rwrr'r'r(r<Bs z Widget.state)N)N)N)rrrrrxrrr<r'r'r'r(r s   rc@s"eZdZdZdddZddZdS)rzcTtk Button widget, displays a textual label and/or image, and evaluates a command when pressed.NcKst||d|dS)aConstruct a Ttk Button widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, default, width z ttk::buttonNrrxrwr&rFr'r'r(rxSs zButton.__init__cCs|j|jdS)z/Invokes the command associated with the button.invokerrr'r'r(rbsz Button.invoke)Nrrrrrxrr'r'r'r(rOs c@s"eZdZdZdddZddZdS)rz;Ttk Checkbutton widget which is either in on- or off-state.NcKst||d|dS)a'Construct a Ttk Checkbutton widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, offvalue, onvalue, variable zttk::checkbuttonNrrr'r'r(rxjs zCheckbutton.__init__cCs|j|jdS)aWToggles between the selected and deselected states and invokes the associated command. If the widget is currently selected, sets the option variable to the offvalue option and deselects the widget; otherwise, sets the option variable to the option onvalue. Returns the result of the associated command.rrrr'r'r(ryszCheckbutton.invoke)Nrr'r'r'r(rgs c@s2eZdZdZd ddZddZddZd d ZdS) rzeTtk Entry widget displays a one-line text string and allows that string to be edited by the user.NcKst|||pd|dS)aConstructs a Ttk Entry widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand WIDGET-SPECIFIC OPTIONS exportselection, invalidcommand, justify, show, state, textvariable, validate, validatecommand, width VALIDATION MODES none, key, focus, focusin, focusout, all z ttk::entryNr)rwr&ZwidgetrFr'r'r(rxszEntry.__init__cCs||j|jd|S)zqReturn a tuple of (x, y, width, height) which describes the bounding box of the character given by index.bboxZ_getintsr#rhr)rwindexr'r'r(rsz Entry.bboxcCs|j|jd||S)zxReturns the name of the element at position x, y, or the empty string if the coordinates are outside the window.rrrr'r'r(rszEntry.identifycCs|j|j|jdS)zForce revalidation, independent of the conditions specified by the validate option. Returns False if validation fails, True if it succeeds. Sets or clears the invalid state accordingly.validater#rrhrrr'r'r(rszEntry.validate)NN)rrrrrxrrrr'r'r'r(rs  c@s,eZdZdZd ddZd ddZddZdS) rzMTtk Combobox widget combines a text field with a pop-down list of values.NcKstj||df|dS)aConstruct a Ttk Combobox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS exportselection, justify, height, postcommand, state, textvariable, values, width z ttk::comboboxNrrxrr'r'r(rxs zCombobox.__init__cCs2|dkr |j|j|jdS|j|jd|S)aIf newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, returns the index of the current value in the list of values or -1 if the current value does not appear in the list.Ncurrentr#Zgetintrhr)rwZnewindexr'r'r(rszCombobox.currentcCs|j|jd|dS)z(Sets the value of the combobox to value.setNrrwr-r'r'r(rsz Combobox.set)N)N)rrrrrxrrr'r'r'r(rs  c@seZdZdZdddZdS)rzJTtk Frame widget is a container, used to group other widgets together.NcKst||d|dS)zConstruct a Ttk Frame with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS borderwidth, relief, padding, width, height z ttk::frameNrrr'r'r(rxs zFrame.__init__)Nrrrrrxr'r'r'r(rsc@seZdZdZdddZdS)rz7Ttk Label widget displays a textual label and/or image.NcKst||d|dS)aGConstruct a Ttk Label with parent master. STANDARD OPTIONS class, compound, cursor, image, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS anchor, background, font, foreground, justify, padding, relief, text, wraplength z ttk::labelNrrr'r'r(rxs zLabel.__init__)Nrr'r'r'r(rsc@seZdZdZdddZdS)rzTtk Labelframe widget is a container used to group other widgets together. It has an optional label, which may be a plain text string or another widget.NcKst||d|dS)zConstruct a Ttk Labelframe with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS labelanchor, text, underline, padding, labelwidget, width, height zttk::labelframeNrrr'r'r(rxs zLabelframe.__init__)Nrr'r'r'r(rsc@seZdZdZdddZdS)r zbTtk Menubutton widget displays a textual label and/or image, and displays a menu when pressed.NcKst||d|dS)aConstruct a Ttk Menubutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS direction, menu zttk::menubuttonNrrr'r'r(rxs zMenubutton.__init__)Nrr'r'r'r(r sc@sneZdZdZdddZddZddZd d Zd d Zd dZ ddZ dddZ dddZ ddZ ddZdS)r zTtk Notebook widget manages a collection of windows and displays a single one at a time. Each child window is associated with a tab, which the user may select to change the currently-displayed window.NcKst||d|dS)a\Construct a Ttk Notebook with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS height, padding, width TAB OPTIONS state, sticky, padding, text, image, compound, underline TAB IDENTIFIERS (tab_id) The tab_id argument found in several methods may take any of the following forms: * An integer between zero and the number of tabs * The name of a child window * A positional specification of the form "@x,y", which defines the tab * The string "current", which identifies the currently-selected tab * The string "end", which returns the number of tabs (only valid for method index) z ttk::notebookNrrr'r'r(rx"szNotebook.__init__cKs |jj|jd|ft|dS)zAdds a new tab to the notebook. If window is currently managed by the notebook but hidden, it is restored to its previous position.addNr#rhrr6)rwchildrFr'r'r(rBsz Notebook.addcCs|j|jd|dS)zXRemoves the tab specified by tab_id, unmaps and unmanages the associated window.forgetNrrwtab_idr'r'r(rJszNotebook.forgetcCs|j|jd|dS)zHides the tab specified by tab_id. The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the add command.hideNrrr'r'r(rPsz Notebook.hidecCs|j|jd||S)zZReturns the name of the tab element at position x, y, or the empty string if none.rrrr'r'r(rYszNotebook.identifycCs|j|j|jd|S)z|Returns the numeric index of the tab specified by tab_id, or the total number of tabs if tab_id is the string "end".rrrr'r'r(r_szNotebook.indexcKs"|jj|jd||ft|dS)zInserts a pane at the specified position. pos is either the string end, an integer index, or the name of a managed child. If child is already managed by the notebook, moves it to the specified position.insertNrrwposrrFr'r'r(reszNotebook.insertcCs|j|jd|S)zSelects the specified tab. The associated child window will be displayed, and the previously-selected window (if different) is unmapped. If tab_id is omitted, returns the widget name of the currently selected pane.selectrrr'r'r(rnszNotebook.selectcKs$|dk rd||<t|j||jd|S)zQuery or modify the options of the specific tab_id. If kw is not given, returns a dict of the tab option values. If option is specified, returns the value of that option. Otherwise, sets the options to the corresponding values.Ntabrkr#r)rwrrrFr'r'r(rxsz Notebook.tabcCs|j|j|jdpdS)z2Returns a list of windows managed by the notebook.tabsr'r#rcrhrrr'r'r(rsz Notebook.tabscCs|jd|jdS)aEnable keyboard traversal for a toplevel window containing this notebook. This will extend the bindings for the toplevel window containing this notebook as follows: Control-Tab: selects the tab following the currently selected one Shift-Control-Tab: selects the tab preceding the currently selected one Alt-K: where K is the mnemonic (underlined) character of any tab, will select that tab. Multiple notebooks in a single toplevel may be enabled for traversal, including nested notebooks. However, notebook traversal only works properly if all panes are direct children of the notebook.zttk::notebook::enableTraversalNrrr'r'r(enable_traversalszNotebook.enable_traversal)N)N)N)rrrrrxrrrrrrrrrrr'r'r'r(r s   c@s>eZdZdZd ddZejjZddZd ddZ d d d Z dS)r zfTtk Panedwindow widget displays a number of subwindows, stacked either vertically or horizontally.NcKst||d|dS)zConstruct a Ttk Panedwindow with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient, width, height PANE OPTIONS weight zttk::panedwindowNrrr'r'r(rxszPanedwindow.__init__cKs"|jj|jd||ft|dS)zInserts a pane at the specified positions. pos is either the string end, and integer index, or the name of a child. If child is already managed by the paned window, moves it to the specified position.rNrrr'r'r(rszPanedwindow.insertcKs$|dk rd||<t|j||jd|S)aQQuery or modify the options of the specified pane. pane is either an integer index or the name of a managed subwindow. If kw is not given, returns a dict of the pane option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.Npaner)rwrrrFr'r'r(rszPanedwindow.panecCs|j|j|jd||S)aLIf newpos is specified, sets the position of sash number index. May adjust the positions of adjacent sashes to ensure that positions are monotonically increasing. Sash positions are further constrained to be between 0 and the total size of the widget. Returns the new position of sash number index.sashposr)rwrZnewposr'r'r(rszPanedwindow.sashpos)N)N)N) rrrrrxrvr rrrrr'r'r'r(r s   c@s6eZdZdZd ddZd ddZd ddZd d ZdS)r a6Ttk Progressbar widget shows the status of a long-running operation. They can operate in two modes: determinate mode shows the amount completed relative to the total amount of work to be done, and indeterminate mode provides an animated display to let the user know that something is happening.NcKst||d|dS)zConstruct a Ttk Progressbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient, length, mode, maximum, value, variable, phase zttk::progressbarNrrr'r'r(rxs zProgressbar.__init__cCs|j|jd|dS)zBegin autoincrement mode: schedules a recurring timer event that calls method step every interval milliseconds. interval defaults to 50 milliseconds (20 steps/second) if omitted.startNr)rwZintervalr'r'r(rszProgressbar.startcCs|j|jd|dS)zRIncrements the value option by amount. amount defaults to 1.0 if omitted.stepNr)rwZamountr'r'r(rszProgressbar.stepcCs|j|jddS)zVStop autoincrement mode: cancels any recurring timer event initiated by start.stopNrrr'r'r(rszProgressbar.stop)N)N)N)rrrrrxrrrr'r'r'r(r s    c@s"eZdZdZdddZddZdS)rzeTtk Radiobutton widgets are used in groups to show or change a set of mutually-exclusive options.NcKst||d|dS)aConstruct a Ttk Radiobutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, value, variable zttk::radiobuttonNrrr'r'r(rx s zRadiobutton.__init__cCs|j|jdS)zSets the option variable to the option value, selects the widget, and invokes the associated command. Returns the result of the command, or an empty string if no command is specified.rrrr'r'r(rszRadiobutton.invoke)Nrr'r'r'r(rs c@s.eZdZdZd ddZd ddZd ddZdS) rzTtk Scale widget is typically used to control the numeric value of a linked variable that varies uniformly over some range.NcKst||d|dS)zConstruct a Ttk Scale with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, from, length, orient, to, value, variable z ttk::scaleNrrr'r'r(rx's zScale.__init__cKsTtj||f|}t|tdtfs,||td|kd|kd|kgrP|d|S)zModify or query scale options. Setting a value for any of the "from", "from_" or "to" options generates a <> event.NrCfrom_to<>)rrQr*typer[updateanyZevent_generate)rwZcnfrFZretvalr'r'r(rQ5s   zScale.configurecCs|j|jd||S)zGet the current value of the value option, or the value corresponding to the coordinates x, y if they are specified. x and y are pixel coordinates relative to the scale widget origin.r"rrr'r'r(r"Bsz Scale.get)N)N)NN)rrrrrxrQr"r'r'r'r(r#s  c@seZdZdZdddZdS)rz;Ttk Scrollbar controls the viewport of a scrollable widget.NcKst||d|dS)zConstruct a Ttk Scrollbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, orient zttk::scrollbarNrrr'r'r(rxNs zScrollbar.__init__)Nrr'r'r'r(rKsc@seZdZdZdddZdS)rzITtk Separator widget displays a horizontal or vertical separator bar.NcKst||d|dS)zConstruct a Ttk Separator with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient zttk::separatorNrrr'r'r(rx`s zSeparator.__init__)Nrr'r'r'r(r\sc@seZdZdZdddZdS)rzlTtk Sizegrip allows the user to resize the containing toplevel window by pressing and dragging the grip.NcKst||d|dS)zConstruct a Ttk Sizegrip with parent master. STANDARD OPTIONS class, cursor, state, style, takefocus z ttk::sizegripNrrr'r'r(rxrszSizegrip.__init__)Nrr'r'r'r(rnsc@s"eZdZdZdddZddZdS)rzTtk Spinbox is an Entry with increment and decrement arrows It is commonly used for number entry or to select from a list of string values. NcKstj||df|dS)a/Construct a Ttk Spinbox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, validate, validatecommand, xscrollcommand, invalidcommand WIDGET-SPECIFIC OPTIONS to, from_, increment, values, wrap, format, command z ttk::spinboxNrrr'r'r(rxs zSpinbox.__init__cCs|j|jd|dS)z'Sets the value of the Spinbox to value.rNrrr'r'r(rsz Spinbox.set)N)rrrrrxrr'r'r'r(r|s c@s4eZdZdZdEddZdFddZdGddZd d ZdHd d Zd dZ ddZ ddZ dIddZ dJddZ ddZddZddZddZdd Zd!d"ZdKd#d$ZdLd%d&Zd'd(ZeZd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!dMd=d>Z"dNd?d@Z#dOdAdBZ$dPdCdDZ%dS)QrzTtk Treeview widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label.NcKst||d|dS)aConstruct a Ttk Treeview with parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand, yscrollcommand WIDGET-SPECIFIC OPTIONS columns, displaycolumns, height, padding, selectmode, show ITEM OPTIONS text, image, values, open, tags TAG OPTIONS foreground, background, font, image z ttk::treeviewNrrr'r'r(rxszTreeview.__init__cCs||j|jd||pdS)aTReturns the bounding box (relative to the treeview widget's window) of the specified item in the form x y width height. If column is specified, returns the bounding box of that cell. If the item is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.rr8r)rwitemcolumnr'r'r(rsz Treeview.bboxcCs"|j|j|jd|pdpdS)zhReturns a tuple of children belonging to item. If item is not specified, returns root children.rJr8r'rrwrr'r'r( get_childrenszTreeview.get_childrencGs|j|jd||dS)zReplaces item's child with newchildren. Children present in item that are not present in newchildren are detached from tree. No items in newchildren may be an ancestor of item.rJNr)rwrZ newchildrenr'r'r( set_childrenszTreeview.set_childrencKs$|dk rd||<t|j||jd|S)a Query or modify the options for the specified column. If kw is not given, returns a dict of the column option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.Nrr)rwrrrFr'r'r(rszTreeview.columncGs|j|jd|dS)z_Delete all specified items and all their descendants. The root item may not be deleted.deleteNrrwr1r'r'r(rszTreeview.deletecGs|j|jd|dS)zUnlinks all of the specified items from the tree. The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed. The root item may not be detached.detachNrrr'r'r(rszTreeview.detachcCs|j|j|jd|S)zSReturns True if the specified item is present in the tree, False otherwise.existsrrr'r'r(rszTreeview.existscCs|j|jd|S)z}If item is specified, sets the focus item to item. Otherwise, returns the current focus item, or '' if there is none.focusrrr'r'r(rszTreeview.focuscKsP|d}|r,t|ts,|j||j|d<|dk rt|dkr&t|dttfr&|d}|j|jd||dS)Nr7rr)r:r*r,r+r#rhr)rwZselopr1r'r'r( _selectionszTreeview._selectioncGs|d|dS)z.The specified items becomes the new selection.rNrrr'r'r( selection_setszTreeview.selection_setcGs|d|dS)z0Add all of the specified items to the selection.rNrrr'r'r( selection_addszTreeview.selection_addcGs|d|dS)z5Remove all of the specified items from the selection.removeNrrr'r'r(selection_removeszTreeview.selection_removecGs|d|dS)z2Toggle the selection state of each specified item.ZtoggleNrrr'r'r(selection_toggleszTreeview.selection_togglecCs@|j|jd|||}|dkr8|dkr8t|j|dtdS|SdS)a;Query or set the value of given item. With one argument, return a dictionary of column/value pairs for the specified item. With two arguments, return the current value of the specified column. With three arguments, set the value of given column in given item to the specified value.rNF)Z cut_minusrg)r#rhrrri)rwrrr-rfr'r'r(rsz Treeview.setcCs |j|jdd|f||dddS)zBind a callback for the given event sequence to the tag tagname. When an event is delivered to an item, the callbacks for each of the item's tags option are called.tagbindr)rN)Z_bindr)rwtagnameZsequencerr'r'r(tag_bindszTreeview.tag_bindcKs&|dk rd||<t|j||jdd|S)aBQuery or modify the options for the specified tagname. If kw is not given, returns a dict of the option settings for tagname. If option is specified, returns the value for that option for the specified tagname. Otherwise, sets the options to the corresponding values for the given tagname.NrrQr)rwrrrFr'r'r( tag_configures zTreeview.tag_configurec CsF|dkr$|j|j|jdd|S|j|j|jdd||SdS)zIf item is specified, returns 1 or 0 depending on whether the specified item has the given tagname. Otherwise, returns a list of all items which have the specified tag. * Availability: Tk 8.6NrZhas)r#rcrhrr)rwrrr'r'r(tag_hasszTreeview.tag_has)N)N)N)N)N)N)N)N)NN)NN)N)N)&rrrrrxrrrrrrrrrrrrrrrrrrZreattachrrrrrrrrrrrrrrr'r'r'r(rsF              csLeZdZdZdddZfddZd d Zed d Zej d d ZZ S)rzA Ttk Scale widget with a Ttk Label widget indicating its current value. The Ttk Scale can be accessed through instance.scale, and Ttk Label can be accessed through instance.labelNr c Ks|dddk|_tj||f||p.t||_|j|||_t ||_ t ||j||d|_ |j d|j|jr|dnd}|dkrdnd}|j j|ddt |}|j|d||j j|dkrd nd d |jd |j|_| d |j| d|jdS)aConstruct a horizontal LabeledScale with parent master, a variable to be associated with the Ttk Scale widget and its range. If variable is not specified, a tkinter.IntVar is created. WIDGET-SPECIFIC OPTIONS compound: 'top' or 'bottom' Specifies how to display the label relative to the scale. Defaults to 'top'. Zcompoundtop)variablerrrZbottomrr)sideZfill)rrrW)Zanchorwz zN)pop _label_toprrxrvZIntVar _variabler _last_validrlabelrscaler_adjustZpacklowerZplaceZtrace_variable_LabeledScale__tracecb) rwr&rrrrFZ scale_sideZ label_sideZdummyr'r'r(rxs$    zLabeledScale.__init__csHz|jd|jWntk r(YnX|`td|_d|_dS)z9Destroy this widget and possibly its associated variable.rN)rZ trace_vdeleterAttributeErrorsuperdestroyrrr __class__r'r(r s zLabeledScale.destroycsfdd}tjd}tjd}||kr:||}}j}||krX|ksfnj_dS|_|jd<|dS)z1Adjust the label position according to the scale.csZj\}}jr2jj}njj}jj||ddS)Nrrr)Zupdate_idletasksrZcoordsrZwinfo_yrZwinfo_reqheightZplace_configurer rr'r( adjust_labels z*LabeledScale._adjust..adjust_labelrCrNtext)rsrrr"rr-rZ after_idle)rwrEr rrZnewvalr'rr(rs    zLabeledScale._adjustcCs |jS)zReturn current scale value.)rr"rr'r'r(r-4szLabeledScale.valuecCs|j|dS)zSet new scale value.N)rr)rwr=r'r'r(r-9s)NNrr) rrrrrxrrpropertyr-setter __classcell__r'r'r r(rs &  cs<eZdZdZd ddZddZd ddZfd d ZZS) rzmThemed OptionMenu, based after tkinter's OptionMenu, which allows the user to select a value from a menu.NcOs||dd|ddd}tj||f|tj|dd|d<||_|dd|_|rptd tt | |j |f|dS) a9Construct a themed OptionMenu widget with master as the parent, the resource textvariable set to variable, the initially selected value specified by the default parameter, the menu values given by *values and additional keywords. WIDGET-SPECIFIC OPTIONS style: stylename Menubutton style. direction: 'above', 'below', 'left', 'right', or 'flush' Menubutton direction. command: callback A callback that will be invoked after selecting an item. r{N direction)Z textvariabler{rF)Ztearoffmenurzunknown option -%s) rr rxrvZMenur _callbackZTclErrorrr\keysset_menu)rwr&rrvalueskwargsrFr'r'r(rxCs  zOptionMenu.__init__cCs&|dkr|t||St||S)Nr)Z nametowidgetr __getitem__rr'r'r(r`szOptionMenu.__getitem__cGsR|d}|dd|D]$}|j|t|j||j|jdq|rN|j|dS)zUBuild a new menu of radiobuttons with *values and optionally a default value.rrend)rrrN)rZadd_radiobuttonrvZ_setitrrr)rwrrrr=r'r'r(rgs zOptionMenu.set_menucs,z|`Wntk rYnXtdS)z0Destroy this widget and its associated variable.N)rrrrrr r'r(rus zOptionMenu.destroy)N)N) rrrrrxrrrrr'r'r r(r?s   )F)FN)F)F)rrB)N)6r __version__ __author____all__rvrrrrZ TkVersionrr)r/r6r>r@rIrLrYrarerkrorsrirrobjectrrrrrrrrrrr r r r r rrrrrrZXViewZYViewrrrr'r'r'r(s     % 1*   *B*"8*(J`PK! MС__pycache__/font.cpython-38.pycnu[U e5d@@szdZddlZddlZdZdZdZdZddZGd d d Zd d d Z d!d dZ e dkrve Z eddedZeeeedeedeeeedeedee eededeeje deddZeedejde deje dedZeeje de jdZeeeddZejedejededS)"z0.9NZnormalZromanboldZitaliccCs t|ddS)zFGiven the name of a tk named font, returns a Font representation. T)nameexists)Fontrr$/usr/lib64/python3.8/tkinter/font.py nametofontsr c@seZdZdZedZddZddZddZ d#d d Z d dZ ddZ ddZ ddZddZddZd$ddZddZddZeZd%dd Zd!d"Zd S)&raRepresents a named font. Constructor options are: font -- font specifier (name, system font, or (family, size, style)-tuple) name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new named font if False, points to the existing font if True. Raises _tkinter.TclError if the assertion is false. the following are ignored if font is specified: family -- font 'family', e.g. Courier, Times, Helvetica size -- font size in points weight -- font thickness: NORMAL, BOLD slant -- font slant: ROMAN, ITALIC underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) cCs:g}|D]$\}}|d||t|q t|SN-)itemsappendstrtuple)selfkwoptionskvrrr_set1s z Font._setcCs$g}|D]}|d|qt|Sr )rr)rargsrrrrr_get8sz Font._getcCs:i}tdt|dD] }||d|||dd<q|S)Nrr )rangelen)rrrirrr_mkdict>sz Font._mkdictNFcKs|std}t|d|}|r4||dd|}n ||}|sTdtt|j}||_ |rd|_ |j ||ddkrtj d|j f|r|jdd|j f|n|jdd |j f|d |_ ||_ |j|_|j|_dS) Nzuse fonttkfontactualFnamesz$named font %s does not already exist configureZcreateT)tkinter_get_default_rootgetattr splitlistcallrrnextcounterr delete_fontZ_tkinterZTclError_tk_split_call)rrootrrrrrrrr__init__Ds,    z Font.__init__cCs|jSNrrrrr__str__csz Font.__str__cCs&t|tstS|j|jko$|j|jkSr0) isinstancerNotImplementedrr+)rotherrrr__eq__fs z Font.__eq__cCs ||Sr0)cget)rkeyrrr __getitem__kszFont.__getitem__cCs|jf||idSr0)r")rr8valuerrr __setitem__nszFont.__setitem__cCs4z|jr|dd|jWntk r.YnXdS)Nrdelete)r*r-r Exceptionr1rrr__del__qs z Font.__del__cCst|jf|S)z*Return a distinct copy of the current font)rr+r r1rrrcopyxsz Font.copycCs^d}|rd|f}|r8|d|f}|jdd|jf|S|||jdd|jf|SdS)zReturn actual font attributesr -displayofr rr N)r-rrr,)roption displayofrrrrr |sz Font.actualcCs|dd|jd|S)zGet font attributerconfigr )r-r)rrArrrr7sz Font.cgetc KsB|r"|jdd|jf||n|||dd|jSdS)zModify font attributesrrCN)r-rrrr,)rrrrrrCsz Font.configcCs2|f}|rd||f}|j|jdd|jf|S)zReturn text widthr@rmeasure)r+getintr-r)rtextrBrrrrrDs z Font.measurecOsd}|dd}|rd|f}|rL|||}|j|jdd|jf|S||jdd|jf|}i}tdt|dD](}|j||d |||d d<q||SdS) z}Return font metrics. For best performance, create a dummy widget using this font before calling this method.rrBNr@rmetricsrrr ) poprr+rEr-rr,rr)rrrrrBresrrrrrGs &z Font.metrics)NNNF)NN)N)__name__ __module__ __qualname____doc__ itertoolscountr)rrrr/r2r6r9r;r>r?r r7rCr"rDrGrrrrrs$     rcCs6|std}d}|rd|f}|j|jjd|S)zGet font families (as a tuple)zuse font.families()rr@rfamilies)rrPr#r$rr&r')r.rBrrrrrPs  rPcCs$|std}|j|jddS)z'Get names of defined fonts (as a tuple)zuse font.names()rr!rQ)r.rrrr!s r!__main__times)familysizeweightrUrWZhelloZ linespace)rB)ZCourierr)rz Hello, world)rFrzQuit!)rFZcommandr)rW)NN)N) __version__rNr#ZNORMALZROMANZBOLDZITALICr rrPr!rJZTkr.fprintr rCr7rDrGZLabelwZpackZButtonZdestroyr?ZfbZmainlooprrrrsB       PK!s'__pycache__/scrolledtext.cpython-38.pycnu[U e5d@sldZdgZddlmZmZmZmZmZmZddl m Z m Z m Z m Z GdddeZddZedkrhed S) aA ScrolledText widget feels like a text widget but also has a vertical scroll bar on its right. (Later, options may be added to add a horizontal bar as well, to make the bars disappear automatically when not needed, to move them to the other side of the window, etc.) Configuration options are passed to the Text widget. A Frame widget is inserted between the master and the text, to hold the Scrollbar widget. Most methods calls are inherited from the Text widget; Pack, Grid and Place methods are redirected to the Frame widget however. ScrolledText)FrameText ScrollbarPackGridPlace)RIGHTLEFTYBOTHc@seZdZdddZddZdS)rNcKst||_t|j|_|jjttd|d|jjit j ||jf||jt t dd|j |jd<tt }ttttBttB}||}|D]4}|ddkr|dkr|d krt||t|j|qdS) N)sidefillZyscrollcommandT)r rexpandZcommandr_ZconfigZ configure)rframerZvbarpackr r updatesetr__init__r r Zyviewvarskeysrrr differencesetattrgetattr)selfZmasterkwZ text_methsmethodsmr,/usr/lib64/python3.8/tkinter/scrolledtext.pyrs    $ zScrolledText.__init__cCs t|jS)N)strr)rrrr __str__)szScrolledText.__str__)N)__name__ __module__ __qualname__rr"rrrr rs cCsHddlm}tddd}||t|jttdd|| dS)Nr)ENDZwhite )ZbgZheightT)rr r) tkinter.constantsr&rinsert__doc__rr r Z focus_setZmainloop)r&Zstextrrr example-s    r+__main__N)r*__all__Ztkinterrrrrrrr(r r r r rr+r#rrrr s   PK!#N'__pycache__/colorchooser.cpython-38.pycnu[U e5dA @s>ddlmZGdddeZd ddZedkr:ededS) )Dialogc@s$eZdZdZdZddZddZdS)ChooseraCreate a dialog for the tk_chooseColor command. Args: master: The master widget for this dialog. If not provided, defaults to options['parent'] (if defined). options: Dictionary of options for the tk_chooseColor call. initialcolor: Specifies the selected color when the dialog is first displayed. This can be a tk color string or a 3-tuple of ints in the range (0, 255) for an RGB triplet. parent: The parent window of the color dialog. The color dialog is displayed on top of this. title: A string for the title of the dialog box. Ztk_chooseColorcCs@z&|jd}t|tr$d||jd<Wntk r:YnXdS)zvEnsure initialcolor is a tk color string. Convert initialcolor from a RGB triplet to a color string. initialcolorz #%02x%02x%02xN)options isinstancetupleKeyError)selfcolorr ,/usr/lib64/python3.8/tkinter/colorchooser.py _fixoptions!s   zChooser._fixoptionscCs>|r t|sdS||\}}}|d|d|dft|fS)zAdjust result returned from call to tk_chooseColor. Return both an RGB tuple of ints in the range (0, 255) and the tk color string in the form #rrggbb. )NN)strZ winfo_rgb)r Zwidgetresultrgbr r r _fixresult.s zChooser._fixresultN)__name__ __module__ __qualname____doc__Zcommandr rr r r r rs rNcKs"|r|}||d<tf|S)zDisplay dialog window for selection of a color. Convenience wrapper for the Chooser class. Displays the color chooser dialog with color as the initial value. r)copyrZshow)r rr r r askcolorBsr__main__r )N)Ztkinter.commondialogrrrrprintr r r r  s 3 PK!<,22)__pycache__/__main__.cpython-38.opt-1.pycnu[U e5d@s<dZddlZejddr&dejd<ddlmZedS)zMain entry pointNz __main__.pyzpython -m tkinter)_test)__doc__sysargvendswithrmainr r (/usr/lib64/python3.8/tkinter/__main__.pys   PK!F9QQ#__pycache__/__init__.cpython-38.pycnu[U e5d͕@sdZddlZddlZddlZejZddlTddlZdZeej Z eej Z ej Z ejZejZedZedejZddZd d Zd d Zz ejZWnek rYnXd dZz ejZWnek rYnXdyddZGdddeejZGdddZdadaddZ dzddZ!ddZ"d{ddZ#da$GdddZ%Gd d!d!e%Z&Gd"d#d#e%Z'Gd$d%d%e%Z(Gd&d'd'e%Z)d|d(d)Z*e+Z,eZ-d*d+Z.Gd,d-d-Z/Gd.d/d/Z0Gd0d1d1Z1Gd2d3d3Z2Gd4d5d5Z3Gd6d7d7e/e3Z4d}d8d9Z5Gd:d;d;Z6Gdd?d?Z8Gd@dAdAe/Z9GdBdCdCe9e6e7e8Z:GdDdEdEe9e3Z;GdFdGdGe:ZGdLdMdMe:e1Z?GdNdOdOe:Z@GdPdQdQe:ZAGdRdSdSe:e1e2ZBGdTdUdUe:ZCGdVdWdWe:ZDGdXdYdYe:ZEGdZd[d[e:ZFGd\d]d]e:ZGGd^d_d_e:ZHGd`dadae:e1e2ZIGdbdcdcZJGdddedeeDZKGdfdgdgZLGdhdidieLZMGdjdkdkeLZNdldmZOdndoZPGdpdqdqe:e1ZQGdrdsdse:ZRGdtdudue:ZSdvdwZTeUdxkreTdS)~a8Wrapper functions for Tcl/Tk. Tkinter provides classes which allow the display, positioning and control of widgets. Toplevel widgets are Tk and Toplevel. Other widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox LabelFrame and PanedWindow. Properties of the widgets are specified with keyword arguments. Keyword arguments have the same name as the corresponding resource under Tk. Widgets are positioned with one of the geometry managers Place, Pack or Grid. These managers can be called with methods place, pack, grid available in every Widget. Actions are bound to events by resources (e.g. keyword argument command) or with the method bind. Example (Hello, World): import tkinter from tkinter.constants import * tk = tkinter.Tk() frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = tkinter.Label(frame, text="Hello, World") label.pack(fill=X, expand=1) button = tkinter.Button(frame,text="Exit",command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop() N)*z([\\{}])z([\s])cCsdtt|S)Internal function. )joinmap _stringifyvaluer (/usr/lib64/python3.8/tkinter/__init__.py_join8sr cCst|ttfrHt|dkr:t|d}t|rFd|}qdt|}ntt|}|sZd}nbt|rt d|}| dd}t d|}|ddkrd |}n|ddkst |rd|}|S) rrrz{%s}z{}z\\\1 z\n"\) isinstancelisttuplelenr _magic_researchr strsubreplace _space_rer r r r r=s$          rcCs@d}|D]2}t|ttfr(|t|}q|dk r||f}q|S)rr N)rrr_flatten)seqresitemr r r rVs rc Cst|tr|St|tdtfr$|Si}t|D]^}z||Wq0ttfk r}z(td|| D]\}}|||<qjW5d}~XYq0Xq0|SdS)rNz_cnfmerge: fallback due to:) rdicttyperrupdateAttributeError TypeErrorprintitems)Zcnfscnfcmsgkvr r r _cnfmergees   r+Tc Csz||}t|drtdt|}i}t||D]@\}}t|}|r`|ddkr`|dd}|rl||}|||<q4|S)aReturn a properly formatted dict built from Tcl list pairs. If cut_minus is True, the supposed '-' prefix will be removed from keys. If conv is specified, it is used to convert values. Tcl list is expected to contain an even number of elements. zNTcl list representing a dict is expected to contain an even number of elementsr-rN) splitlistr RuntimeErroriterzipr) tkr*Z cut_minusconvtitrkeyr r r r _splitdict{s    r7c@seZdZdZeZdZdZeZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)e*j+Z+d&S)' EventType23456789Z10Z11Z12Z13Z14Z15Z16Z17Z18Z19Z20Z21Z22Z23Z24Z25Z26Z27Z28Z29Z30Z31Z32Z33Z34Z35Z36Z37Z38N),__name__ __module__ __qualname__ZKeyPressZKeyZ KeyReleaseZ ButtonPressButtonZ ButtonReleaseZMotionZEnterZLeaveZFocusInZFocusOutZKeymapZExposeZGraphicsExposeZNoExposeZ VisibilityZCreateZDestroyZUnmapZMapZ MapRequestZReparentZ ConfigureZConfigureRequestZGravityZ ResizeRequestZ CirculateZCirculateRequestZPropertyZSelectionClearZSelectionRequestZ SelectionZColormapZ ClientMessageMappingZ VirtualEventZActivateZ DeactivateZ MouseWheelr__str__r r r r r8sPr8c@seZdZdZddZdS)EventaContainer for the properties of an event. Instances of this type are generated if one of the following events occurs: KeyPress, KeyRelease - for keyboard events ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for mouse events Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate, Colormap, Gravity, Reparent, Property, Destroy, Activate, Deactivate - for window events. If a callback function for one of these events is registered using bind, bind_all, bind_class, or tag_bind, the callback is called with an Event as first argument. It will have the following attributes (in braces are the event types for which the attribute is valid): serial - serial number of event num - mouse button pressed (ButtonPress, ButtonRelease) focus - whether the window has the focus (Enter, Leave) height - height of the exposed window (Configure, Expose) width - width of the exposed window (Configure, Expose) keycode - keycode of the pressed key (KeyPress, KeyRelease) state - state of the event as a number (ButtonPress, ButtonRelease, Enter, KeyPress, KeyRelease, Leave, Motion) state - state as a string (Visibility) time - when the event occurred x - x-position of the mouse y - y-position of the mouse x_root - x-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) y_root - y-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) char - pressed character (KeyPress, KeyRelease) send_event - see X/Windows documentation keysym - keysym of the event as a string (KeyPress, KeyRelease) keysym_num - keysym of the event as a number (KeyPress, KeyRelease) type - type of the event as a number widget - widget in which the event occurred delta - delta of wheel movement (MouseWheel) csdd|jD|js"d=n|jdkr:t|jd<t|ddsLd=|jdkr^d=n|t|jtr|j}d }g}t|D]\}}|d |>@r| |q|d t |>d @}|s|s| t |d |d<|j dkrd =d }dt|jd|jd fdd|DfS)NcSsi|]\}}|dkr||qS)??r .0r)r*r r r sz"Event.__repr__..charrH send_eventTrstate) ZShiftZLockZControlZMod1ZMod2ZMod3ZMod4ZMod5ZButton1ZButton2ZButton3ZButton4ZButton5r|delta) rMrNkeysymkeycoderLnumrPfocusxywidthheightz <%s event%s>namec3s&|]}|krd||fVqdS)z %s=%sNr )rJr)attrsr r sz!Event.__repr__..)__dict__r%rLreprgetattrrNrint enumerateappendrhexrrPr )selfrNZmodssinkeysr r[r __repr__s6       zEvent.__repr__N)rArBrC__doc__rjr r r r rGs*rGcCsdadabdS)zInhibit setting of default root window. Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window. FN)_support_default_root _default_rootr r r r NoDefaultRootsrncCs:ts tdts6|r$td|dt}t|ks6ttS)NzINo master specified and tkinter is configured to not support default rootz Too early to z: no default root window)rlr/rmTkAssertionError)whatrootr r r _get_default_root#s rscCsdSrNr )errr r r _tkerror/srvcCs.z t|}Wntk r YnXt|dS)zBInternal function. Calling it will raise the exception SystemExit.N)ra ValueError SystemExit)coder r r _exit4s  rzc@seZdZdZdZdZdZdddZddZdd Z d d Z e Z d d Z ddZ ddZddZddZddZeZddZddZddZdS)VariablezClass to define value holders for e.g. buttons. Subclasses StringVar, IntVar, DoubleVar, BooleanVar are specializations that constrain the type of the value returned from get().rZNcCs|dk rt|tstd|s&td}||_|j|_|rD||_ndtt |_t d7a |dk rn| |n&|j |j dd|js| |j dS)a.Construct a variable MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nzname must be a stringzcreate variablePY_VARrinfoexists)rrr#rs_rootr2_tk_namer__varnum initialize getbooleancall_defaultremasterr rYr r r __init__Is   zVariable.__init__cCsb|jdkrdS|j|jdd|jr6|j|j|jdk r^|jD]}|j|qFd|_dS)zUnset the variable in Tcl.Nr}r~)rrrrZglobalunsetvar _tclCommands deletecommandrerYr r r __del__gs   zVariable.__del__cCs|jS)z'Return the name of the variable in Tcl.)rrer r r rFsszVariable.__str__cCs|j|j|SzSet the variable to VALUE.)r globalsetvarrrer r r r setwsz Variable.setcCs|j|jS)zReturn value of variable.)r globalgetvarrrr r r get}sz Variable.getcCst|d|jj}tt|}z |j}Wntk r:YnXz||j}Wntk r^YnX|j |||j dkr~g|_ |j ||SN) CallWrapperr__call__r_id__func__r"rAr createcommandrrc)recallbackfcbnamer r r _registers    zVariable._registercCs(||}|jddd|j||f|S)a#Define a trace callback for the variable. Mode is one of "read", "write", "unset", or a list or tuple of such strings. Callback must be a function which is called when the variable is read, written or unset. Return the name of the callback. traceaddvariablerrrrremoderrr r r trace_adds  zVariable.trace_addcCsx|jddd|j|||D] \}}|j|d|kr qtq |j|z|j|Wntk rrYnXdS)aDelete the trace callback for a variable. Mode is one of "read", "write", "unset" or a list or tuple of such strings. Must be same as were specified in trace_add(). cbname is the name of the callback returned from trace_add(). rremoverrN) rrr trace_infor.rrrrwrerrmZcar r r trace_removes  zVariable.trace_removec s4|jjfddt|jddd|jDS)z&Return all trace callback information.csg|]\}}||fqSr r rIr.r r sz'Variable.trace_info..rr}r)rr.rrrrr rr rszVariable.trace_infocCs$||}|jdd|j|||S)aDefine a trace callback for the variable. MODE is one of "r", "w", "u" for read, write, undefine. CALLBACK must be a function which is called when the variable is read, written or undefined. Return the name of the callback. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_add() instead. rrrrr r r trace_variables zVariable.trace_variablecCs|jdd|j|||j|d}|D] \}}|j|d|kr.qq.|j|z|j|Wntk rYnXdS)aSDelete the trace callback for a variable. MODE is one of "r", "w", "u" for read, write, undefine. CBNAME is the name of the callback returned from trace_variable or trace. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_remove() instead. rZvdeleterN) rrrr.rrrrrwrr r r trace_vdeletes  zVariable.trace_vdeletecs(fddjjddjDS)zReturn all trace callback information. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_info() instead. csg|]}j|qSr )rr.rJrUrr r rsz(Variable.trace_vinfo..rZvinfo)rr.rrrr rr trace_vinfoszVariable.trace_vinfocCs6t|tstS|j|jko4|jj|jjko4|j|jkSr)rr{NotImplementedr __class__rAr)reotherr r r __eq__s   zVariable.__eq__)NNN)rArBrCrkrrrrrrFrrrrrrrrrrrrr r r r r{@s&   r{c@s&eZdZdZdZdddZddZdS) StringVarz#Value holder for strings variables.rZNcCst||||dS)a6Construct a string variable. MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nr{rrr r r rs zStringVar.__init__cCs$|j|j}t|tr|St|S)z#Return value of variable as string.)rrrrrrr r r rs z StringVar.get)NNNrArBrCrkrrrr r r r rs rc@s&eZdZdZdZdddZddZdS) IntVarz#Value holder for integer variables.rNcCst||||dS)a7Construct an integer variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrrr r r rs zIntVar.__init__c CsJ|j|j}z|j|WSttfk rDt|j|YSXdS)z/Return the value of the variable as an integer.N)rrrgetintr#TclErrorra getdoublerr r r rs z IntVar.get)NNNrr r r r r s rc@s&eZdZdZdZdddZddZdS) DoubleVarz!Value holder for float variables.gNcCst||||dS)a6Construct a float variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0.0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrrr r r r*s zDoubleVar.__init__cCs|j|j|jS)z,Return the value of the variable as a float.)rrrrrr r r r6sz DoubleVar.get)NNNrr r r r r&s rc@s2eZdZdZdZd ddZddZeZdd ZdS) BooleanVarz#Value holder for boolean variables.FNcCst||||dS)a:Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nrrr r r r?s zBooleanVar.__init__cCs|j|j|j|Sr)rrrrrr r r rKszBooleanVar.setcCs:z|j|j|jWStk r4tdYnXdS)z+Return the value of the variable as a bool. invalid literal for getboolean()N)rrrrrrwrr r r rQszBooleanVar.get)NNN) rArBrCrkrrrrrr r r r r;s  rcCstdj|dS)zRun the main loop of Tcl.zrun the main loopN)rsr2mainloop)rhr r r rYsrcCs4ztdj|WStk r.tdYnXdS)z$Convert Tcl object to True or False.zuse getboolean()rN)rsr2rrrwrfr r r rcsrc@seZdZdZdZdZddZddZd1ddZd d Z d d Z d2ddZ e Z d3ddZ d4ddZd5ddZd6ddZddZddZddZdd ZeZd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd7d/d0Zd1d2Zd3d4Zd8d6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(d9dHdIZ)dJdKZ*dLdMZ+d:dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d;d\d]Z3ddbdcZ7dddeZ8dfdgZ9dhdiZ:djdkZ;d?dldmZdrdsZ?dtduZ@dvdwZAdxdyZBd@dzd{ZCd|d}ZDd~dZEddZFddZGdAddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^dBddZ_ddZ`ddZaddZbddZcddZdddZedd„ZfddĄZgddƄZhddȄZiddʄZjdCdd̄ZkdDddτZldEddфZmdFddӄZndGddՄZoddׄZpdHddلZqddۄZrdIdd݄Zsdd߄ZtddZuddZvddZwddZxeyddZzdJddZ{ddZ|e|Z}dKddZ~e~ZddZdZdeZddZddZddZddZddZdLddZeZddZeZddZddZddZdd Zd gZefd d ZeZd dZeZddZdMddZeZdNddZeZddZddZifddZeZddZefddZifdd ZeZd!d"ZeZdOd#d$Zd%d&Zd'd(Zd)d*ZdPd+d,Zd-d.Zd/d0ZdS(QMisczRInternal class. Base class which defines methods common for interior widgets.NcCs,|jdk r(|jD]}|j|qd|_dS)zkInternal function. Delete all Tcl commands created for this widget in the Tcl interpreter.N)rr2rrr r r destroyxs  z Misc.destroycCs6|j|z|j|Wntk r0YnXdS)zDInternal function. Delete the Tcl command provided in NAME.N)r2rrrrwrr r r rs  zMisc.deletecommandcCs|j|jdd|S)zSet Tcl internal variable, whether the look and feel should adhere to Motif. A parameter of 1 means adhere to Motif (e.g. no color change if mouse passes over slider). Returns the set value.rtk_strictMotif)r2rrrebooleanr r r rs  zMisc.tk_strictMotifcCs|jddS)zDChange the color scheme to light brown as used in Tk 3.6 and before. tk_bisqueNr2rrr r r rszMisc.tk_bisquecOs(|jdt|tt|dS)a Set a new color scheme for all widget elements. A single color as argument will cause that all colors of Tk widget elements are derived from this. Alternatively several keyword parameters and its associated colors can be given. The following keywords are valid: activeBackground, foreground, selectColor, activeForeground, highlightBackground, selectBackground, background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.) tk_setPaletteN)r2rrrr%reargskwr r r rs zMisc.tk_setPaletter|cCs|jdd|dS)zWait until the variable is modified. A parameter of type IntVar, StringVar, DoubleVar or BooleanVar must be given.tkwaitrNrrr r r wait_variableszMisc.wait_variablecCs"|dkr |}|jdd|jdS)zQWait until a WIDGET is destroyed. If no parameter is given self is used.Nrwindowr2r_wrerr r r wait_windowszMisc.wait_windowcCs"|dkr |}|jdd|jdS)zxWait until the visibility of a WIDGET changes (e.g. it appears). If no parameter is given self is used.NrZ visibilityrrr r r wait_visibilityszMisc.wait_visibility1cCs|j||dS)zSet Tcl variable NAME to VALUE.N)r2setvar)rerYr r r r rsz Misc.setvarcCs |j|S)z"Return value of Tcl variable NAME.)r2getvarrr r r rsz Misc.getvarc CsBz|j|WStk r<}ztt|W5d}~XYnXdSr)r2rrrwrrerfexcr r r rsz Misc.getintc CsBz|j|WStk r<}ztt|W5d}~XYnXdSr)r2rrrwrrr r r rszMisc.getdoublecCs0z|j|WStk r*tdYnXdS)zPReturn a boolean value for Tcl boolean values true and false given as parameter.rN)r2rrrw)rerfr r r rszMisc.getbooleancCs|jd|jdS)zDirect input focus to this widget. If the application currently does not have the focus this widget will get the focus if the application gets the focus through the window manager.rTNrrr r r focus_setszMisc.focus_setcCs|jdd|jdS)ztDirect input focus to this widget even if the application does not have the focus. Use with caution!rTz-forceNrrr r r focus_forceszMisc.focus_forcecCs&|jd}|dks|sdS||S)zReturn the widget which has currently the focus in the application. Use focus_displayof to allow working with several displays. Return None if application does not have the focus.rTnoneN)r2r _nametowidgetrr r r focus_gets  zMisc.focus_getcCs,|jdd|j}|dks|s"dS||S)zReturn the widget which has currently the focus on the display where this widget is located. Return None if the application does not have the focus.rT -displayofrNr2rrrrr r r focus_displayofs zMisc.focus_displayofcCs,|jdd|j}|dks|s"dS||S)zyReturn the widget which would have the focus if top level for this widget gets the focus from the window manager.rTz-lastforrNrrr r r focus_lastfors zMisc.focus_lastforcCs|jddS)zXThe widget under mouse will get automatically focus. Can not be disabled easily.tk_focusFollowsMouseNrrr r r rszMisc.tk_focusFollowsMousecCs"|jd|j}|sdS||S)anReturn the next widget in the focus order which follows widget which has currently the focus. The focus order first goes to the next child, then to the children of the child recursively and then to the next sibling which is higher in the stacking order. A widget is omitted if it has the takefocus resource set to 0. tk_focusNextNrrr r r r s zMisc.tk_focusNextcCs"|jd|j}|sdS||S)zHReturn previous widget in the focus order. See tk_focusNext for details. tk_focusPrevNrrr r r rszMisc.tk_focusPrevcsNsjd|dSfdd}j|_|jd|SdS)aCall function once after given time. MS specifies the time in milliseconds. FUNC gives the function which shall be called. Additional parameters are given as parameters to the function call. Return identifier to cancel scheduling with after_cancel.afterNcs8z W5zWntk r0YnXXdSr)rrr rfuncrYrer r callit,s  zMisc.after..callit)r2rrAr)reZmsrrrr rr r s z Misc.aftercGs|jd|f|S)zCall FUNC once if the Tcl main loop has no event to process. Return an identifier to cancel the scheduling with after_cancel.Zidle)r)rerrr r r after_idle8szMisc.after_idlecCsd|s tdz.|jdd|}|j|d}||Wntk rNYnX|jdd|dS)zCancel scheduling of function identified with ID. Identifier returned by after or after_idle must be given as first parameter. z?id must be a valid identifier returned from after or after_idlerr}rZcancelN)rwr2rr.rr)rerdataZscriptr r r after_cancel@szMisc.after_cancelrcCs|jd||dS)zRing a display's bell.)bellN)r2r _displayofre displayofr r r rQsz Misc.bellcKsdd|krN|jdkrNz d|d<|jd||WStk rL|d=YnX|jd||S)aRetrieve data from the clipboard on window's display. The window keyword defaults to the root window of the Tkinter application. The type keyword specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING, except on X11, where the default is to try UTF8_STRING and fall back to STRING. This command is equivalent to: selection_get(CLIPBOARD) r x11 UTF8_STRING) clipboardr)_windowingsystemr2r_optionsrrerr r r clipboard_getVs zMisc.clipboard_getcKs,d|kr|j|d<|jd||dS)zClear the data in the Tk clipboard. A widget specified for the optional displayof keyword argument specifies the target display.r)rclearNrr2rrrr r r clipboard_clearms zMisc.clipboard_clearcKs4d|kr|j|d<|jd||d|fdS)zAppend STRING to the Tk clipboard. A widget specified at the optional displayof keyword argument specifies the target display. The clipboard can be retrieved with selection_get.r)rrc--Nr)restringrr r r clipboard_appendus  zMisc.clipboard_appendcCs$|jdd|j}|sdS||S)zOReturn widget which has currently the grab in this application or None.grabZcurrentNrrr r r grab_currentszMisc.grab_currentcCs|jdd|jdS)z.Release grab for this widget if currently set.rreleaseNrrr r r grab_releaseszMisc.grab_releasecCs|jdd|jdS)zwSet grab for this widget. A grab directs all events to this and descendant widgets in the application.rrNrrr r r grab_setsz Misc.grab_setcCs|jddd|jdS)zSet global grab for this widget. A global grab directs all events to this and descendant widgets on the display. Use with caution - other applications do not get events anymore.rrz-globalNrrr r r grab_set_globalszMisc.grab_set_globalcCs"|jdd|j}|dkrd}|S)zYReturn None, "local" or "global" if this widget has no, a local or a global grab.rstatusrNr)rerr r r grab_statusszMisc.grab_statuscCs|jdd|||dS)zSet a VALUE (second parameter) for an option PATTERN (first parameter). An optional third parameter gives the numeric priority (defaults to 80).optionrNr)repatternr priorityr r r option_addszMisc.option_addcCs|jdddS)zPClear the option database. It will be reloaded if option_add is called.rrNrrr r r option_clearszMisc.option_clearcCs|jdd|j||S)zReturn the value for an option NAME for this widget with CLASSNAME. Values with higher priority override lower values.rrr)rerY classNamer r r option_getszMisc.option_getcCs|jdd||dS)zvRead file FILENAME into the option database. An optional second parameter gives the numeric priority.rZreadfileNr)reZfileNamerr r r option_readfileszMisc.option_readfilecKs,d|kr|j|d<|jd||dS)zClear the current X selection.r) selectionrNrrr r r selection_clears zMisc.selection_clearcKsvd|kr|j|d<d|kr`|jdkr`z d|d<|jd||WStk r^|d=YnX|jd||S)aReturn the contents of the current X selection. A keyword parameter selection specifies the name of the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display to use. A keyword parameter type specifies the form of data to be fetched, defaulting to STRING except on X11, where UTF8_STRING is tried before STRING.rr rr)r r)rrr2rrrrr r r selection_gets   zMisc.selection_getcKs.||}|jd|||j|fdS)aSpecify a function COMMAND to call if the X selection owned by this widget is queried by another application. This function must return the contents of the selection. The function will be called with the arguments OFFSET and LENGTH which allows the chunking of very long selections. The following keyword parameters can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).)r ZhandleN)rr2rrr)recommandrrYr r r selection_handles zMisc.selection_handlecKs"|jd|||jfdS)zBecome owner of X selection. A keyword parameter selection specifies the name of the selection (default PRIMARY).r ZownN)r2rrrrr r r selection_owns zMisc.selection_owncKs:d|kr|j|d<|jd||}|s0dS||S)zReturn owner of X selection. The following keyword parameter can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).rrN)rr2rrr)rerrYr r r selection_own_gets  zMisc.selection_own_getcGs|jd||f|S)zDSend Tcl command CMD to different interpreter INTERP to be executed.sendr)reZinterpcmdrr r r rsz Misc.sendcCs|jd|j|dS)z(Lower this widget in the stacking order.lowerNr)re belowThisr r r rsz Misc.lowercCs|jd|j|dS)z(Raise this widget in the stacking order.raiseNr)re aboveThisr r r tkraisesz Misc.tkraisecCs(d|||f}|j|j|S)z*Return integer which represents atom NAME.)winfoZatom)rr2rr)rerYrrr r r winfo_atomszMisc.winfo_atomcCs d|||f}|j|S)z'Return name of atom with identifier ID.)rZatomnamerr2rrerrrr r r winfo_atomname s zMisc.winfo_atomnamecCs|j|jdd|jS)z7Return number of cells in the colormap for this widget.rZcellsr2rrrrr r r winfo_cellsszMisc.winfo_cellsc CsRg}|j|jdd|jD].}z|||Wqtk rJYqXq|S)z?Return a list of all widgets which are children of this widget.rchildren)r2r.rrrcrKeyError)reresultchildr r r winfo_childrenszMisc.winfo_childrencCs|jdd|jS)z(Return window class name of this widget.rclassrrr r r winfo_class#szMisc.winfo_classcCs|j|jdd|jS)z?Return True if at the last color request the colormap was full.rZ colormapfullr2rrrrr r r winfo_colormapfull'szMisc.winfo_colormapfullcCs4d||||f}|j|}|s*dS||S)z@Return the widget which is at the root coordinates ROOTX, ROOTY.)rZ containingN)rr2rr)reZrootXZrootYrrrYr r r winfo_containing,s zMisc.winfo_containingcCs|j|jdd|jS)z$Return the number of bits per pixel.rZdepthr!rr r r winfo_depth4szMisc.winfo_depthcCs|j|jdd|jS)z"Return true if this widget exists.rr~r!rr r r winfo_exists8szMisc.winfo_existscCs|j|jdd|j|S)zWReturn the number of pixels for the given distance NUMBER (e.g. "3c") as float.rZfpixelsr2rrrrenumberr r r winfo_fpixels=s  zMisc.winfo_fpixelscCs|jdd|jS)zFReturn geometry string for this widget in the form "widthxheight+X+Y".rgeometryrrr r r winfo_geometryCszMisc.winfo_geometrycCs|j|jdd|jS)zReturn height of this widget.rrXr!rr r r winfo_heightGszMisc.winfo_heightcCst|jdd|jdS)z%Return identifier ID for this widget.rrr)rar2rrrr r r winfo_idLsz Misc.winfo_idcCs"d||}|j|j|S)z9Return the name of all Tcl interpreters for this display.)rZinterps)rr2r.r)rerrr r r winfo_interpsPszMisc.winfo_interpscCs|j|jdd|jS)z%Return true if this widget is mapped.rZismappedr!rr r r winfo_ismappedUszMisc.winfo_ismappedcCs|jdd|jS)z/Return the window manager name for this widget.rZmanagerrrr r r winfo_managerZszMisc.winfo_managercCs|jdd|jS)zReturn the name of this widget.rrYrrr r r winfo_name^szMisc.winfo_namecCs|jdd|jS)z-Return the name of the parent of this widget.rparentrrr r r winfo_parentbszMisc.winfo_parentcCs d|||f}|j|S)z.Return the pathname of the widget given by ID.)rpathnamerrr r r winfo_pathnamefs zMisc.winfo_pathnamecCs|j|jdd|j|S)z'Rounded integer value of winfo_fpixels.rZpixelsr!r0r r r winfo_pixelslszMisc.winfo_pixelscCs|j|jdd|jS)z:Return the x coordinate of the pointer on the root window.rZpointerxr!rr r r winfo_pointerxqszMisc.winfo_pointerxcCs||jdd|jS)zHReturn a tuple of x and y coordinates of the pointer on the root window.rZ pointerxy_getintsr2rrrr r r winfo_pointerxyvszMisc.winfo_pointerxycCs|j|jdd|jS)z:Return the y coordinate of the pointer on the root window.rZpointeryr!rr r r winfo_pointery{szMisc.winfo_pointerycCs|j|jdd|jS)z'Return requested height of this widget.rZ reqheightr!rr r r winfo_reqheightszMisc.winfo_reqheightcCs|j|jdd|jS)z&Return requested width of this widget.rZreqwidthr!rr r r winfo_reqwidthszMisc.winfo_reqwidthcCs||jdd|j|S)zNReturn a tuple of integer RGB values in range(65536) for color in this widget.rZrgbrA)reZcolorr r r winfo_rgbszMisc.winfo_rgbcCs|j|jdd|jS)zSReturn x coordinate of upper left corner of this widget on the root window.rZrootxr!rr r r winfo_rootxszMisc.winfo_rootxcCs|j|jdd|jS)zSReturn y coordinate of upper left corner of this widget on the root window.rZrootyr!rr r r winfo_rootyszMisc.winfo_rootycCs|jdd|jS)z&Return the screen name of this widget.rscreenrrr r r winfo_screenszMisc.winfo_screencCs|j|jdd|jS)zTReturn the number of the cells in the colormap of the screen of this widget.rZ screencellsr!rr r r winfo_screencellsszMisc.winfo_screencellscCs|j|jdd|jS)z\Return the number of bits per pixel of the root window of the screen of this widget.rZ screendepthr!rr r r winfo_screendepthszMisc.winfo_screendepthcCs|j|jdd|jS)zXReturn the number of pixels of the height of the screen of this widget in pixel.rZ screenheightr!rr r r winfo_screenheightszMisc.winfo_screenheightcCs|j|jdd|jS)zUReturn the number of pixels of the height of the screen of this widget in mm.rZscreenmmheightr!rr r r winfo_screenmmheightszMisc.winfo_screenmmheightcCs|j|jdd|jS)zTReturn the number of pixels of the width of the screen of this widget in mm.rZ screenmmwidthr!rr r r winfo_screenmmwidthszMisc.winfo_screenmmwidthcCs|jdd|jS)zReturn one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the default colormodel of this screen.rZ screenvisualrrr r r winfo_screenvisualszMisc.winfo_screenvisualcCs|j|jdd|jS)zWReturn the number of pixels of the width of the screen of this widget in pixel.rZ screenwidthr!rr r r winfo_screenwidthszMisc.winfo_screenwidthcCs|jdd|jS)zxReturn information of the X-Server of the screen of this widget in the form "XmajorRminor vendor vendorVersion".rZserverrrr r r winfo_serverszMisc.winfo_servercCs||jdd|jS)z*Return the toplevel widget of this widget.rtoplevel)rr2rrrr r r winfo_toplevels  zMisc.winfo_toplevelcCs|j|jdd|jS)zBReturn true if the widget and all its higher ancestors are mapped.rZviewabler!rr r r winfo_viewableszMisc.winfo_viewablecCs|jdd|jS)zReturn one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the colormodel of this widget.rvisualrrr r r winfo_visualszMisc.winfo_visualcCs|jdd|jS)z7Return the X identifier for the visual for this widget.rZvisualidrrr r r winfo_visualidszMisc.winfo_visualidFcsHjddj|rdnd}fddj|D}fdd|DS)zReturn a list of all visuals available for the screen of this widget. Each item in the list consists of a visual name (see winfo_visual), a depth and if includeids is true is given also the X identifier.rZvisualsavailable includeidsNcsg|]}j|qSr )r2r.rrr r rsz/Misc.winfo_visualsavailable..csg|]}|qSr )_Misc__winfo_parseitemrrr r rs)r2rrr.)rerZrr rr winfo_visualsavailables  zMisc.winfo_visualsavailablecCs$|ddtt|j|ddS)rNr)rr_Misc__winfo_getint)rer4r r r Z__winfo_parseitemszMisc.__winfo_parseitemcCs t|dS)rr)rarerUr r r Z__winfo_getintszMisc.__winfo_getintcCs|j|jdd|jS)zReturn the height of the virtual root window associated with this widget in pixels. If there is no virtual root window return the height of the screen.rZ vrootheightr!rr r r winfo_vrootheightszMisc.winfo_vrootheightcCs|j|jdd|jS)zReturn the width of the virtual root window associated with this widget in pixel. If there is no virtual root window return the width of the screen.rZ vrootwidthr!rr r r winfo_vrootwidthszMisc.winfo_vrootwidthcCs|j|jdd|jS)ziReturn the x offset of the virtual root relative to the root window of the screen of this widget.rZvrootxr!rr r r winfo_vrootxszMisc.winfo_vrootxcCs|j|jdd|jS)ziReturn the y offset of the virtual root relative to the root window of the screen of this widget.rZvrootyr!rr r r winfo_vrooty szMisc.winfo_vrootycCs|j|jdd|jS)z Return the width of this widget.rrWr!rr r r winfo_widthszMisc.winfo_widthcCs|j|jdd|jS)zVReturn the x coordinate of the upper left corner of this widget in the parent.rrUr!rr r r winfo_xsz Misc.winfo_xcCs|j|jdd|jS)zVReturn the y coordinate of the upper left corner of this widget in the parent.rrVr!rr r r winfo_ysz Misc.winfo_ycCs|jddS)zEEnter event loop until all pending events have been processed by Tcl.r!Nrrr r r r! sz Misc.updatecCs|jdddS)zEnter event loop until all idle callbacks have been called. This will update the display of windows but not process events caused by the user.r!Z idletasksNrrr r r update_idletasks$szMisc.update_idletaskscCs6|dkr |j|jd|jS|jd|j|dS)a,Set or get the list of bindtags for this widget. With no argument return the list of all bindtags associated with this widget. With a list of strings as argument the bindtags are set to this list. The bindtags determine in which order events are processed (see bind).Nbindtagsr2r.rr)reZtagListr r r rg*s z Misc.bindtagsrcCst|tr |j|||fnn|rd|||j|}d|r>dp@d||jf}|j|||f|S|rz|j||fS|j|j|SdS)rz"%sif {"[%s %s]" == "break"} break +rZN)rrr2rr _substitute_subst_format_strr.)rerqsequencerr needcleanupfuncidrr r r _bind7s"   z Misc._bindcCs|d|jf|||S)aOBind to this widget at event SEQUENCE a call to function FUNC. SEQUENCE is a string of concatenated event patterns. An event pattern is of the form where MODIFIER is one of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4, Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3, B3, Alt, Button4, B4, Double, Button5, B5 Triple, Mod1, M1. TYPE is one of Activate, Enter, Map, ButtonPress, Button, Expose, Motion, ButtonRelease FocusIn, MouseWheel, Circulate, FocusOut, Property, Colormap, Gravity Reparent, Configure, KeyPress, Key, Unmap, Deactivate, KeyRelease Visibility, Destroy, Leave and DETAIL is the button number for ButtonPress, ButtonRelease and DETAIL is the Keysym for KeyPress and KeyRelease. Examples are for pressing Control and mouse button 1 or for pressing A and the Alt key (KeyPress can be omitted). An event pattern can also be a virtual event of the form <> where AString can be arbitrary. This event can be generated by event_generate. If events are concatenated they must appear shortly after each other. FUNC will be called if the event sequence occurs with an instance of Event as argument. If the return value of FUNC is "break" no further bound function is invoked. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. Bind will return an identifier to allow deletion of the bound function with unbind without memory leak. If FUNC or SEQUENCE is omitted the bound function or list of bound events are returned.bindrorrerlrrr r r rpIs'z Misc.bindcCs&|jd|j|d|r"||dS)zWUnbind for this widget for event SEQUENCE the function identified with FUNCID.rprZNr2rrr)rerlrnr r r unbindrsz Misc.unbindcCs|d|||dS)aBind to all widgets at an event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.)rpallrrorrr r r bind_allysz Misc.bind_allcCs|jdd|ddS)z8Unbind for all widgets for event SEQUENCE all functions.rprurZNr)rerlr r r unbind_allszMisc.unbind_allcCs|d|f|||dS)a=Bind to widgets with bindtag CLASSNAME at event SEQUENCE a call of function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rprrv)rer rlrrr r r bind_classszMisc.bind_classcCs|jd||ddS)zWUnbind for all widgets with bindtag CLASSNAME for event SEQUENCE all functions.rprZNr)rer rlr r r unbind_classszMisc.unbind_classcCs|j|dS)zCall the mainloop of Tk.N)r2r)rerhr r r rsz Misc.mainloopcCs|jdS)z8Quit the Tcl interpreter. All widgets will be destroyed.N)r2quitrr r r r{sz Misc.quitcCs"|rtt|jj|j|SdSrt)rrr2rr.rerr r r rBsz Misc._getintscCs"|rtt|jj|j|SdSrt)rrr2rr.r|r r r _getdoublesszMisc._getdoublescCs|r|j|SdSrt)r2rr|r r r _getbooleanszMisc._getbooleancCs"|r d|fS|dkrd|jfSdS)rrNr rrr r r rs  zMisc._displayofcCsBz |jWStk r<|jdd}|_|YSXdS)rr2ZwindowingsystemN)rZ_windowingsystem_cachedr"r2r)reZwsr r r rs   zMisc._windowingsystemcCs|rt||f}nt|}d}|D]\}}|dk r&|ddkrN|dd}t|rb||}n^t|ttfrg}|D]<}t|tr|t |qxt|t r|t |qxqqxd |}|d||f}q&|S)rr N_rr-) r+r%callablerrrrrarcrrr)rer&rrr)r*Znvrr r r rs*     z Misc._optionscCsNt|d}|}|ds.|}|dd}|D]}|s>qJ|j|}q2|S)zPReturn the Tkinter instance of a widget identified by its Tcl name NAME..rrN)rsplitrr#)rerYwrhr r r nametowidgets  zMisc.nametowidgetcCst|||j}tt|}z |j}Wntk r8YnXz||j}Wntk r\YnX|j|||r|j dkrg|_ |j ||S)zReturn a newly created Tcl function. If this function is called, the Python function FUNC will be executed. An optional function SUBST can be given which will be executed before FUNC.N) rrr_rrr"rAr2rrrc)rersubstrmrrYr r r rs     zMisc._registercCs|}|jr|j}q|S)rr)rerr r r rsz Misc._root)z%#z%bz%fz%hz%kz%sz%tz%wz%xz%yz%Az%Ez%Kz%Nz%Wz%Tz%Xz%Yz%Drcst|t|jkr|S|jj}|jjfdd}|\}}}}}} } } } } }}}}}}}}}t}||_|||_z|||_Wnt k rYnX|||_ |||_ || |_ || |_ || |_|| |_|| |_||_z|||_Wnt k r YnX||_|||_zt||_Wntk rF||_YnXz|||_Wntk rt||_YnX|||_|||_z||_Wn tt fk rd|_YnX|fS)rc s,z |WSttfk r&|YSXdS)z?Tk changed behavior in 8.4.2, returning "??" rather more often.N)rwrrrr r getint_events z&Misc._substitute..getint_eventr)r _subst_formatr2rrrGserialrSrTrrXrRrNtimerWrUrVrLrMrQZ keysym_numr8r rwrwidgetr$Zx_rootZy_rootrP)rerrrZnsignbrhr)rfr4rrUrVAEKNWTXYDer rr rj sT *               zMisc._substitutecCs(t\}}}|}||||dSrt)sysexc_inforreport_callback_exception)rervaltbrrr r r _report_exceptionHszMisc._report_exceptioncGs\i}|j|jj|D]>}|j|}|dddf|dd||ddd<q|S)z;Call Tcl configure command and return the result as a dict.rrNr2r.r)rerr&rUr r r _getconfigureNs  0zMisc._getconfigurecGs2|j|jj|}|dddf|ddS)Nrrr)rerrUr r r _getconfigure1VszMisc._getconfigure1cCs|rt||f}n |rt|}|dkr:|t|j|fSt|tr^|t|j|d|fS|jt|j|f| |dS)rNr-) r+rrrrrrr2rr)rerr&rr r r _configureZs zMisc._configurecKs|d||S)zConfigure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys. configurerrer&rr r r rgszMisc.configurecCs|j|jdd|S)z4Return the resource value for a KEY given as string.cgetr-rrer6r r r rrsz Misc.cgetcCs|||idSr)rrer6r r r r __setitem__xszMisc.__setitem__cs*|jjfdd|j|jdDS)z3Return a list of all resource names of this widget.cs g|]}|dddqS)rrNr rrr r r~szMisc.keys..rrhrr rr ri{s z Misc.keyscCs|jS)z+Return the window path name of this widget.rrr r r rFsz Misc.__str__cCsd|jj|jj|jfS)Nz<%s.%s object %s>)rrBrCrrr r r rjs z Misc.__repr___noarg_cCs:|tjkr"||jdd|jS|jdd|j|dS)aSet or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given the current setting will be returned. pack propagateNrrr~r2rrreflagr r r pack_propagates  zMisc.pack_propagatecs(fddjjddjDS)HReturn a list of all slaves of this widget in its packing order.csg|]}|qSr rrrr r rsz$Misc.pack_slaves..rslavesrhrr rr pack_slavess  zMisc.pack_slavescs(fddjjddjDS)rcsg|]}|qSr rrrr r rsz%Misc.place_slaves..placerrhrr rr place_slavess zMisc.place_slavescCs|jdd|j|dS)zThe anchor value controls how to place the grid within the master when no row/column has any weight. The default anchor is nw.gridanchorNr)rerr r r grid_anchorszMisc.grid_anchorcCsZdd|jf}|dk r(|dk r(|||f}|dk rD|dk rD|||f}||jj|pXdS)aReturn a tuple of integer coordinates for the bounding box of this widget controlled by the geometry manager grid. If COLUMN, ROW is given the bounding box applies from the cell with row and column 0 to the specified cell. If COL2 and ROW2 are given the bounding box starts at that cell. The returned integers specify the offset of the upper left corner in the master widget and the width and height. rbboxN)rrBr2r)recolumnrowZcol2Zrow2rr r r grid_bboxs   zMisc.grid_bboxc Csht|ttjfrdz:t|}|s$WdSd|kr:|j|WS|j|WSWnttfk rbYnX|S)Nr) rr_tkinterZTcl_Objr2rrrwr)rer Zsvaluer r r _gridconvvalueszMisc._gridconvvaluecCst|trJ|sJ|dddkr*|dd}|dddkrBd|}|f}n |||}|s|t|j|jd||j||jdS|jd||j|f|}t|dkr||SdS)rrNrrr-r)r3) rrrr7r2rrrr)rerindexr&roptionsrr r r _grid_configures(    zMisc._grid_configurecKs|d|||S)zConfigure column INDEX of a grid. Valid resources are minsize (minimum size of the column), weight (how much does additional space propagate to this column) and pad (how much space to let additionally).columnconfigurerrerr&rr r r grid_columnconfigureszMisc.grid_columnconfigurec Cs ||jdd|j||pdS)zReturn a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.rlocationNrArerUrVr r r grid_locationszMisc.grid_locationcCs:|tjkr"||jdd|jS|jdd|j|dS)aSet or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given, the current setting will be returned. rrNrrr r r grid_propagates  zMisc.grid_propagatecKs|d|||S)zConfigure row INDEX of a grid. Valid resources are minsize (minimum size of the row), weight (how much does additional space propagate to this row) and pad (how much space to let additionally). rowconfigurerrr r r grid_rowconfigureszMisc.grid_rowconfigurecCs||jdd|jpdS)z.rrrh)rerrrr rr grid_slaves s    zMisc.grid_slavescGsdd|f|}|j|dS)zBind a virtual event VIRTUAL (of the form <>) to an event SEQUENCE such that the virtual event is triggered whenever SEQUENCE occurs.eventrNrrevirtual sequencesrr r r event_add/szMisc.event_addcGsdd|f|}|j|dS)z-Unbind a virtual event VIRTUAL from SEQUENCE.rdeleteNrrr r r event_delete6szMisc.event_deletecKsDdd|j|f}|D]\}}|d|t|f}q|j|dS)zGenerate an event SEQUENCE. Additional keyword arguments specify parameter of the event (e.g. x, y, rootx, rooty).rZgenerate-%sN)rr%rr2r)rerlrrr)r*r r r event_generate;szMisc.event_generatecCs|j|jdd|S)zuReturn a list of all virtual events or the information about the SEQUENCE bound to the virtual event VIRTUAL.rr}r)rerr r r event_infoDszMisc.event_infocCs|j|jddS)z*Return a list of all existing image names.imagenamesrrr r r image_namesLszMisc.image_namescCs|j|jddS)z?Return a list of all available image types (e.g. photo bitmap).rtypesrrr r r image_typesPszMisc.image_types)N)r|)N)N)r|r)r|)N)r)N)N)N)N)r)r)r)r)r)F)N)r)NNN)N)NNN)NNN)r)N)Nr)N)N)NNNN)NN)N)rArBrCrk_last_child_idsrrrrrrrZwaitvarrrrrrrrrrTrrrrrrrrrrrrrrrrrrrrr r r rrrrrrrrliftrr r"r'r)r+r,r-r.r2r4r5r6r7r8r9r:r<r>r?r@rCrDrErFrGrHrIrKrLrMrNrOrPrQrRrSrUrVrXrYr\r[r]r_r`rarbrcrdrer!rfrgrorprtrwrxryrzrr{rBr}r~rpropertyrrrrrregisterrrrrkrjrrrrrconfigr __getitem__rrirFrjrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rmsP                          )       =                  rc@s eZdZdZddZddZdS)rzwInternal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.cCs||_||_||_dS)z(Store FUNC, SUBST and WIDGET as members.N)rrr)rerrrr r r rYszCallWrapper.__init__cGsLz|jr|j|}|j|WStk r2Yn|jYnXdS)z3Apply first function SUBST to arguments, than FUNC.N)rrrxrrrerr r r r_s  zCallWrapper.__call__NrArBrCrkrrr r r r rUsrc@s(eZdZdZddZddZddZdS) XViewzXMix-in class for querying and changing the horizontal position of a widget's window.cGs(|jj|jdf|}|s$||SdS)z5Query and change the horizontal position of the view.xviewNr2rrr}rerrr r r rosz XView.xviewcCs|j|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.rmovetoNrrefractionr r r xview_movetouszXView.xview_movetocCs|j|jdd||dS)z\Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).rscrollNrrer1rqr r r xview_scrollzszXView.xview_scrollN)rArBrCrkrrrr r r r rksrc@s(eZdZdZddZddZddZdS) YViewzVMix-in class for querying and changing the vertical position of a widget's window.cGs(|jj|jdf|}|s$||SdS)z3Query and change the vertical position of the view.yviewNrrr r r rsz YView.yviewcCs|j|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.rrNrrr r r yview_movetoszYView.yview_movetocCs|j|jdd||dS)z\Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).rrNrrr r r yview_scrollszYView.yview_scrollN)rArBrCrkrrrr r r r rsrc@seZdZdZdBddZeZddZeZdCddZeZ d d Z e Z dDd d Z e Z d dZeZdEddZeZddZeZddZeZdFddZeZdGddZeZdHddZeZdIddZeZddZeZdJdd Z e Z!dKd!d"Z"e"Z#dLd$d%Z$e$Z%dMd&d'Z&e&Z'dNd(d)Z(e(Z)d*d+Z*e*Z+dOd,d-Z,e,Z-dPd.d/Z.e.Z/dQd0d1Z0e0Z1dRd2d3Z2e2Z3dSd4d5Z4e4Z5dTd6d7Z6e6Z7dUd8d9Z8e8Z9dVd:d;Z:e:Z;dWdd?Z>e>Z?d@dAZ@e@ZAdS)YWmzAProvides functions for the communication with the window manager.Nc Cs ||jdd|j||||S)zInstruct the window manager to set the aspect ratio (width/height) of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. Return a tuple of the actual values if no argument is given.wmaspectrA)reZminNumerZminDenomZmaxNumerZmaxDenomr r r wm_aspectsz Wm.wm_aspectcGsdd|jf|}|j|S)aThis subcommand returns or sets platform specific attributes The first form returns a list of the platform specific flags and their values. The second form returns the value for the specific option. The third form sets one or more of the values. The values are as follows: On Windows, -disabled gets or sets whether the window is in a disabled state. -toolwindow gets or sets the style of the window to toolwindow (as defined in the MSDN). -topmost gets or sets whether this is a topmost window (displays above all other windows). On Macintosh, XXXXX On Unix, there are currently no special attribute values. r attributes)rr2rrr r r wm_attributesszWm.wm_attributescCs|jdd|j|S)zVStore NAME in WM_CLIENT_MACHINE property of this widget. Return current value.rclientrrr r r wm_clientsz Wm.wm_clientcsZt|dkr|f}ddjf|}|r4j|n"fddjj|DSdS)zStore list of window names (WLIST) into WM_COLORMAPWINDOWS property of this widget. This list contains windows whose colormaps differ from their parents. Return current list of widgets if WLIST is empty.rrcolormapwindowscsg|]}|qSr rrrr r rsz)Wm.wm_colormapwindows..N)rrr2rr.)reZwlistrr rr wm_colormapwindowss  zWm.wm_colormapwindowscCs|jdd|j|S)zStore VALUE in WM_COMMAND property. It is the command which shall be used to invoke the application. Return current command if VALUE is None.rrrrr r r wm_commandsz Wm.wm_commandcCs|jdd|jS)zDeiconify this widget. If it was never mapped it will not be mapped. On Windows it will raise this widget and give it the focus.r deiconifyrrr r r wm_deiconifyszWm.wm_deiconifycCs|jdd|j|S)zSet focus model to MODEL. "active" means that this widget will claim the focus itself, "passive" means that the window manager shall give the focus. Return current focus model if MODEL is None.r focusmodelr)reZmodelr r r wm_focusmodelszWm.wm_focusmodelcCs|jdd|dS)aAThe window will be unmapped from the screen and will no longer be managed by wm. toplevel windows will be treated like frame windows once they are no longer managed by wm, however, the menu option configuration will be remembered and the menus will return once the widget is managed again.rforgetNrrr r r wm_forgetsz Wm.wm_forgetcCs|jdd|jS)zAReturn identifier for decorative frame of this widget if present.rframerrr r r wm_framesz Wm.wm_framecCs|jdd|j|S)ziSet geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return current value if None is given.rr3r)reZ newGeometryr r r wm_geometryszWm.wm_geometryc Cs ||jdd|j||||S)aInstruct the window manager that this widget shall only be resized on grid boundaries. WIDTHINC and HEIGHTINC are the width and height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are the number of grid units requested in Tk_GeometryRequest.rrrA)reZ baseWidthZ baseHeightZwidthIncZ heightIncr r r wm_grids z Wm.wm_gridcCs|jdd|j|S)z~Set the group leader widgets for related widgets to PATHNAME. Return the group leader of this widget if None is given.rgrouprreZpathNamer r r wm_group sz Wm.wm_groupcCs2|r|jdd|jd|S|jdd|j|SdS)aSet bitmap for the iconified widget to BITMAP. Return the bitmap if None is given. Under Windows, the DEFAULT parameter can be used to set the icon for the widget and any descendents that don't have an icon set explicitly. DEFAULT can be the relative path to a .ico file (example: root.iconbitmap(default='myicon.ico') ). See Tk documentation for more information.r iconbitmap-defaultNr)rebitmapdefaultr r r wm_iconbitmaps zWm.wm_iconbitmapcCs|jdd|jS)zDisplay widget as icon.riconifyrrr r r wm_iconify$sz Wm.wm_iconifycCs|jdd|j|S)zVSet mask for the icon bitmap of this widget. Return the mask if None is given.riconmaskr)rerr r r wm_iconmask*szWm.wm_iconmaskcCs|jdd|j|S)zSSet the name of the icon for this widget. Return the name if None is given.riconnamer)reZnewNamer r r wm_iconname1szWm.wm_iconnameFcGs<|r |jjdd|jdf|n|jjdd|jf|dS)aSets the titlebar icon for this window based on the named photo images passed through args. If default is True, this is applied to all future created toplevels as well. The data in the images is taken as a snapshot at the time of invocation. If the images are later changed, this is not reflected to the titlebar icons. Multiple images are accepted to allow different images sizes to be provided. The window manager may scale provided icons to an appropriate size. On Windows, the images are packed into a Windows icon structure. This will override an icon specified to wm_iconbitmap, and vice versa. On X, the images are arranged into the _NET_WM_ICON X property, which most modern window managers support. An icon specified by wm_iconbitmap may exist simultaneously. On Macintosh, this currently does nothing.r iconphotorNr)rerrr r r wm_iconphoto8szWm.wm_iconphotoc Cs||jdd|j||S)zSet the position of the icon of this widget to X and Y. Return a tuple of the current values of X and X if None is given.r iconpositionrArr r r wm_iconpositionSs zWm.wm_iconpositioncCs|jdd|j|S)zgSet widget PATHNAME to be displayed instead of icon. Return the current value if None is given.r iconwindowrrr r r wm_iconwindow[szWm.wm_iconwindowcCs|jdd|dS)zThe widget specified will become a stand alone top-level window. The window will be decorated with the window managers title bar, etc.rmanageNr)rerr r r wm_managebsz Wm.wm_managec Cs||jdd|j||S)zSet max WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.rmaxsizerArerWrXr r r wm_maxsizejs z Wm.wm_maxsizec Cs||jdd|j||S)zSet min WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.rminsizerAr$r r r wm_minsizess z Wm.wm_minsizecCs||jdd|j|S)zInstruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.roverrideredirect)r~r2rrrr r r wm_overrideredirect|s  zWm.wm_overrideredirectcCs|jdd|j|S)zInstruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".r positionfromrreZwhor r r wm_positionfromszWm.wm_positionfromcCs.t|r||}n|}|jdd|j||S)zBind function FUNC to command NAME for this widget. Return the function bound to NAME if None is given. NAME could be e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW".rprotocol)rrr2rr)rerYrrr r r wm_protocols zWm.wm_protocolcCs|jdd|j||S)zyInstruct the window manager whether this width can be resized in WIDTH or HEIGHT. Both values are boolean values.r resizablerr$r r r wm_resizableszWm.wm_resizablecCs|jdd|j|S)zInstruct the window manager that the size of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".rsizefromrr+r r r wm_sizefromszWm.wm_sizefromcCs|jdd|j|S)zQuery or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).rrNr)reZnewstater r r wm_statesz Wm.wm_statecCs|jdd|j|S)zSet the title of this widget.rtitlerr|r r r wm_titlesz Wm.wm_titlecCs|jdd|j|S)z_Instruct the window manager that this widget is transient with regard to widget MASTER.r transientr)rerr r r wm_transientszWm.wm_transientcCs|jdd|jS)zWithdraw this widget from the screen such that it is unmapped and forgotten by the window manager. Re-draw it with wm_deiconify.rwithdrawrrr r r wm_withdrawszWm.wm_withdraw)NNNN)N)N)N)N)NNNN)N)NN)N)N)F)NN)N)NN)NN)N)N)NN)NN)N)N)N)N)BrArBrCrkrrrrrrrrrrrrrrrrr r r r3r rrr rrrrrrrrrrrrr rr"r!r%r#r'r&r)r(r,r*r.r-r0r/r2r1r3rNr5r4r7r6r9r8r r r r rs                        rc@sNeZdZdZdZdddZdd Zd d Zd d ZddZ ddZ ddZ dS)rozzToplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.rNrrc Csd|_i|_d|_d|_|dkrZddl}|jtjd}|j |\}}|dkrZ||}d} t |||| t ||||_|r| tjjs|||dS)a@Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.NFr)z.pyz.pyc)rr# _tkloadedr2ospathbasenamerargvsplitextrcreate wantobjects_loadtkflagsignore_environment readprofile) re screenNamebaseNamer useTksyncZuser;Zext interactiver r r rs z Tk.__init__cCs|js|j|dSr)r:r2loadtkrBrr r r rKs z Tk.loadtkcCsd|_|jd}|tjkr.tdtj|ft|jd}|tjkrZtdtj|f|jdkrjg|_|j dt |j dt |j d|j dt rts|a|d|jdS) NT tk_versionz4tk.h version (%s) doesn't match libtk.a version (%s) tcl_versionz6tcl.h version (%s) doesn't match libtcl.a version (%s)ZtkerrorexitWM_DELETE_WINDOW)r:r2rr TK_VERSIONr/r TCL_VERSIONrrrvrzrcrlrmr-r)rerLrMr r r rBs(      z Tk._loadtkcCsJt|jD] }|q|jd|jt|trFt |krFda dS)zhDestroy this and all descendants widgets. This will end the application of this Tcl interpreter.rN) rr#valuesrr2rrrrlrmrer'r r r r s    z Tk.destroyc Csddl}d|jkr|jd}n|j}|j|d|}|j|d|}|j|d|}|j|d|}d|i} td| |j|r|jd||j|rtt | | |j|r|jd||j|rtt | | dS) zInternal function. It reads BASENAME.tcl and CLASSNAME.tcl into the Tcl Interpreter and calls exec on the contents of BASENAME.py and CLASSNAME.py if such a file exists in the home directory.rNHOMEz.%s.tclz.%s.pyrezfrom tkinter import *source) r;environcurdirr<rexecisfiler2ropenread) rerGr r;homeZ class_tclZclass_pyZbase_tclZbase_pydirr r r rE s$      zTk.readprofilecCs:ddl}tdtjd|t_|t_|t_||||dS)zReport callback exception on sys.stderr. Applications may want to override this internal function, and should when sys.stderr is None.rNzException in Tkinter callback)file) tracebackr$rstderr last_type last_valuelast_tracebackprint_exception)rerrrr_r r r r$ s zTk.report_callback_exceptioncCs t|j|S)z3Delegate attribute access to the interpreter object)r`r2)reattrr r r __getattr__0 szTk.__getattr__)NNrorrN) rArBrCrkrrrKrBrrErrfr r r r ros   rocCst||||Sr)ro)rFrGr rHr r r TclC srgc@sTeZdZdZifddZeZZZddZeZ ddZ e Z e j ZZ e jZZdS) PackzQGeometry manager Pack. Base class to use the methods pack_* in every widget.cKs$|jdd|jf|||dS)a(Pack a widget in the parent widget. Use as options: after=widget - pack it after you have packed widget anchor=NSEW (or subset) - position widget according to given direction before=widget - pack it before you will pack widget expand=bool - expand widget if parent size grows fill=NONE or X or Y or BOTH - fill widget if widget grows in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction side=TOP or BOTTOM or LEFT or RIGHT - where to add this widget. rrNr2rrrrr r r pack_configureL s   zPack.pack_configurecCs|jdd|jdS)z:Unmap this widget and do not use it for the packing order.rrNrrr r r pack_forgetb szPack.pack_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)zEReturn information about the packing options for this widget.rr}inr7r2rrrredr r r pack_infoh szPack.pack_infoN)rArBrCrkrjrrrrkrrpr}rrrrrr r r r rhG s   rhc@sJeZdZdZifddZeZZZddZeZ ddZ e Z e j ZZ dS) PlacezSGeometry manager Place. Base class to use the methods place_* in every widget.cKs$|jdd|jf|||dS)a Place a widget in the parent widget. Use as options: in=master - master relative to which the widget is placed in_=master - see 'in' option description x=amount - locate anchor of this widget at position x of master y=amount - locate anchor of this widget at position y of master relx=amount - locate anchor of this widget between 0.0 and 1.0 relative to width of master (1.0 is right edge) rely=amount - locate anchor of this widget between 0.0 and 1.0 relative to height of master (1.0 is bottom edge) anchor=NSEW (or subset) - position anchor according to given direction width=amount - width of this widget in pixel height=amount - height of this widget in pixel relwidth=amount - width of this widget between 0.0 and 1.0 relative to width of master (1.0 is the same width as the master) relheight=amount - height of this widget between 0.0 and 1.0 relative to height of master (1.0 is the same height as the master) bordermode="inside" or "outside" - whether to take border width of master widget into account rrNrirr r r place_configurez s   zPlace.place_configurecCs|jdd|jdS)Unmap this widget.rrNrrr r r place_forget szPlace.place_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)zEReturn information about the placing options for this widget.rr}rlrmrnr r r place_info szPlace.place_infoN)rArBrCrkrrrrrrtrrur}rrrr r r r rqu s  rqc@seZdZdZifddZeZZZej Z Z ej Z Z ddZ e ZddZdd ZeZejZZejZZejZZejZZejZZd S) GridzQGeometry manager Grid. Base class to use the methods grid_* in every widget.cKs$|jdd|jf|||dS)aPosition a widget in the parent widget in a grid. Use as options: column=number - use cell identified with given column (starting with 0) columnspan=number - this widget will span several columns in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction row=number - use cell identified with given row (starting with 0) rowspan=number - this widget will span several rows sticky=NSEW - if cell is larger on which sides will this widget stick to the cell boundary rrNrirr r r grid_configure s   zGrid.grid_configurecCs|jdd|jdS)rsrrNrrr r r grid_forget szGrid.grid_forgetcCs|jdd|jdS)z0Unmap this widget but remember the grid options.rrNrrr r r grid_remove szGrid.grid_removecCs8t|j|jdd|j}d|kr4||d|d<|S)zSReturn information about the options for positioning this widget in a grid.rr}rlrmrnr r r grid_info szGrid.grid_infoN)rArBrCrkrwrrrrrrrrrxrryrzr}rrrrrrrrrrr r r r rv s        rvc@s:eZdZdZddZiidfddZddZd d d Zd S) BaseWidgetzInternal class.cCs|s t}||_|j|_d}d|kr2|d}|d=|s|jj}|jdkrRi|_|j|dd}||j|<|dkrd|f}n d||f}||_|j dkrd||_ n|j d||_ i|_ |j|jj kr|jj |j ||jj |j<dS)z6Internal function. Sets up information about children.NrYrrz!%sz!%s%dr) rsrr2rrArrrrrr#r)rerr&rYcountr r r _setup s2       zBaseWidget._setupr c Cs|rt||f}||_t||||jdkr4g|_dd|D}|D]\}}||=qJ|j||jf|| ||D]\}}| ||q~dS)zdConstruct a widget with the parent widget MASTER, a name WIDGETNAME and appropriate options.NcSs"g|]\}}t|tr||fqSr )rr rIr r r r s z'BaseWidget.__init__..) r+ widgetNamer{r}rr%r2rrrr) rerr~r&rextraclassesr)r*r r r r s    zBaseWidget.__init__cCsTt|jD] }|q|jd|j|j|jjkrF|jj|j=t |dS)z)Destroy this and all descendants widgets.rN) rr#rRrr2rrrrrrSr r r r s   zBaseWidget.destroycCs|j|j|f|Srr)rerYrr r r _do szBaseWidget._doN)r )rArBrCrkr}rrrr r r r r{ s r{c@seZdZdZdS)WidgetzxInternal class. Base class for a widget which can be positioned with the geometry managers Pack, Place or Grid.N)rArBrCrkr r r r r src@seZdZdZdifddZdS)Toplevelz"Toplevel widget, e.g. for dialogs.Nc Ks|rt||f}d}dD]L}||kr||}|ddkrJd|dd}nd|}|||f}||=qt||d|i||}|||||d|jdS) a%Construct a toplevel widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, menu, relief, screen, takefocus, use, visual, width.r )rJclass_r(rWZcolormaprrr-NrTrO)r+r{rrrr4r-r) rerr&rrZwmkeyroptrrr r r r) s    zToplevel.__init__rArBrCrkrr r r r r& src@s.eZdZdZdifddZddZddZdS) rDzButton widget.NcKst||d||dS)aUConstruct a button widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, repeatdelay, repeatinterval, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS command, compound, default, height, overrelief, state, width ZbuttonNrrrerr&rr r r rG szButton.__init__cCs|j|jddS)a_Flash the button. This is accomplished by redisplaying the button several times, alternating between active and normal colors. At the end of the flash the button is left in the same normal/active state as when the command was invoked. This command is ignored if the button's state is disabled. flashNrrr r r r\ s z Button.flashcCs|j|jdS)aInvoke the command associated with the button. The return value is the return value from the command, or an empty string if there is no command associated with the button. This command is ignored if the button's state is disabled. invokerrr r r rh sz Button.invoke)rArBrCrkrrrr r r r rDD s rDc@seZdZdZdifddZddZddZd d Zd d Zdwd dZ ddZ ddZ ddZ ddZ dxddZdyddZdzddZd{ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#d|dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-d}dWdXZ.e.Z/dYdZZ0e0Z1d[d\Z2d~d^d_Z3ifd`daZ4dbdcZ5e5Z6Z7dddeZ8dfdgZ9ddidjZ:dkdlZ;dmdnZdsdtZ?dudvZ@dS)Canvasz?Canvas widget to display graphical elements like lines or text.NcKst||d||dS)aConstruct a canvas widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, closeenough, confine, cursor, height, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, offset, relief, scrollregion, selectbackground, selectborderwidth, selectforeground, state, takefocus, width, xscrollcommand, xscrollincrement, yscrollcommand, yscrollincrement.ZcanvasNrrr r r rv s zCanvas.__init__cGs|j|jdf|dS)raddtagNrrr r r r sz Canvas.addtagcCs||d|dS)z*Add tag NEWTAG to all items above TAGORID.aboveNrrenewtagtagOrIdr r r addtag_above szCanvas.addtag_abovecCs||ddS)zAdd tag NEWTAG to all items.ruNr)rerr r r addtag_all szCanvas.addtag_allcCs||d|dS)z*Add tag NEWTAG to all items below TAGORID.belowNrrr r r addtag_below szCanvas.addtag_belowcCs||d||||dS)zAdd tag NEWTAG to item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closests). If START is specified the next below this tag is taken.closestNr)rerrUrVhalostartr r r addtag_closest szCanvas.addtag_closestcCs||d||||dS)zLAdd tag NEWTAG to all items in the rectangle defined by X1,Y1,X2,Y2.enclosedNrrerx1y1x2y2r r r addtag_enclosed szCanvas.addtag_enclosedcCs||d||||dS)zWAdd tag NEWTAG to all items which overlap the rectangle defined by X1,Y1,X2,Y2. overlappingNrrr r r addtag_overlapping szCanvas.addtag_overlappingcCs||d|dS)z)Add tag NEWTAG to all items with TAGORID.withtagNrrr r r addtag_withtag szCanvas.addtag_withtagcGs ||j|jdf|pdS)z|Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses all items with tags specified as arguments.rNrArr r r r s z Canvas.bboxcCs(|j|jd||d|r$||dS)zbUnbind for all items with TAGORID for event SEQUENCE the function identified with FUNCID.rprZNrs)rerrlrnr r r tag_unbind szCanvas.tag_unbindcCs||jd|f|||S)a&Bind to all items with TAGORID at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rprq)rerrlrrr r r tag_bind s zCanvas.tag_bindcCs|j|j|jd||S)zrReturn the canvas x coordinate of pixel position SCREENX rounded to nearest multiple of GRIDSPACING units.canvasxr/)reZscreenx gridspacingr r r r s  zCanvas.canvasxcCs|j|j|jd||S)zrReturn the canvas y coordinate of pixel position SCREENY rounded to nearest multiple of GRIDSPACING units.canvasyr/)reZscreenyrr r r r s  zCanvas.canvasycs,fddjjjdf|DS)z8Return a list of coordinates for the item given in ARGS.csg|]}j|qSr )r2rrrr r r sz!Canvas.coords..coordsrhrr rr r s  z Canvas.coordsc Cs\t|}|d}t|ttfr,|dd}ni}|j|jj|jd|f||||S)rrNr@) rrrrr2rrrr)reitemTyperrr&r r r _create s zCanvas._createcOs|d||S)z6Create arc shaped region with coordinates x1,y1,x2,y2.Zarcrrr r r create_arc szCanvas.create_arccOs|d||S)z%Create bitmap with coordinates x1,y1.rrrr r r create_bitmap szCanvas.create_bitmapcOs|d||S)z)Create image item with coordinates x1,y1.rrrr r r create_image szCanvas.create_imagecOs|d||S)z-Create line with coordinates x1,y1,...,xn,yn.linerrr r r create_line szCanvas.create_linecOs|d||S)z)Create oval with coordinates x1,y1,x2,y2.Zovalrrr r r create_oval szCanvas.create_ovalcOs|d||S)z0Create polygon with coordinates x1,y1,...,xn,yn.Zpolygonrrr r r create_polygon szCanvas.create_polygoncOs|d||S)z.Create rectangle with coordinates x1,y1,x2,y2.Z rectanglerrr r r create_rectangle szCanvas.create_rectanglecOs|d||S)z#Create text with coordinates x1,y1.textrrr r r create_text szCanvas.create_textcOs|d||S)z+Create window with coordinates x1,y1,x2,y2.rrrr r r create_window szCanvas.create_windowcGs|j|jdf|dS)zDelete characters of text items identified by tag or id in ARGS (possibly several times) from FIRST to LAST character (including).dcharsNrrr r r r sz Canvas.dcharscGs|j|jdf|dS)zeZdZdZdifddZddZddZd d Zd d ZdS) RadiobuttonzGRadiobutton widget which shows only one of several buttons in on-state.NcKst||d||dS)aConstruct a radiobutton widget with the parent MASTER. Valid resource names: activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor, disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, padx, pady, relief, selectcolor, selectimage, state, takefocus, text, textvariable, underline, value, variable, width, wraplength.rNrrr r r rV s zRadiobutton.__init__cCs|j|jddSrrrr r r rb szRadiobutton.deselectcCs|j|jddSrrrr r r rg szRadiobutton.flashcCs|j|jdSrrrr r r rk szRadiobutton.invokecCs|j|jddSrrrr r r ro szRadiobutton.select) rArBrCrkrrrrrr r r r r+S s  r+c@s@eZdZdZdifddZddZddZd d d Zd d ZdS)Scalez1Scale widget which can display a numerical scale.NcKst||d||dS)aConstruct a scale widget with the parent MASTER. Valid resource names: activebackground, background, bigincrement, bd, bg, borderwidth, command, cursor, digits, fg, font, foreground, from, highlightbackground, highlightcolor, highlightthickness, label, length, orient, relief, repeatdelay, repeatinterval, resolution, showvalue, sliderlength, sliderrelief, state, takefocus, tickinterval, to, troughcolor, variable, width.rNrrr r r rw s zScale.__init__c CsJ|j|jd}z|j|WStttfk rD|j|YSXdS)z*Get the current value as integer or float.rN)r2rrrrwr#rrrr r r r s z Scale.getcCs|j|jd|dS)zSet the value to VALUE.rNrrr r r r sz Scale.setcCs||j|jd|S)zReturn a tuple (X,Y) of the point along the centerline of the trough that corresponds to VALUE or the current value if None is given.rrArr r r r sz Scale.coordscCs|j|jd||S)zcReturn where the point X,Y lies. Valid return values are "slider", "though1" and "though2".identifyrrr r r r- szScale.identify)N) rArBrCrkrrrrr-r r r r r,t s   r,c@sPeZdZdZdifddZdddZddZd d Zd d Zd dZ ddZ dS) Scrollbarz?Scrollbar widget which displays a slider at a certain position.NcKst||d||dS)alConstruct a scrollbar widget with the parent MASTER. Valid resource names: activebackground, activerelief, background, bd, bg, borderwidth, command, cursor, elementborderwidth, highlightbackground, highlightcolor, highlightthickness, jump, orient, relief, repeatdelay, repeatinterval, takefocus, troughcolor, width.Z scrollbarNrrr r r r s zScrollbar.__init__cCs|j|jd|pdS)aMarks the element indicated by index as active. The only index values understood by this method are "arrow1", "slider", or "arrow2". If any other value is specified then no element of the scrollbar will be active. If index is not specified, the method returns the name of the element that is currently active, or None if no element is active.rNrrr r r r szScrollbar.activatecCs|j|j|jd||S)znReturn the fractional change of the scrollbar setting if it would be moved by DELTAX or DELTAY pixels.rPr/)reZdeltaxZdeltayr r r rP szScrollbar.deltacCs|j|j|jd||S)zRReturn the fractional value which corresponds to a slider position of X,Y.rr/rr r r r szScrollbar.fractioncCs|j|jd||S)zYReturn the element under position X,Y as one of "arrow1","slider","arrow2" or "".r-rrr r r r- szScrollbar.identifycCs||j|jdS)zZReturn the current fractional values (upper and lower end) of the slider position.r)r}r2rrrr r r r sz Scrollbar.getcCs|j|jd||dS)ziSet the fractional values of the slider position (upper and lower ends as value between 0 and 1).rNrrr r r r sz Scrollbar.set)N) rArBrCrkrrrPrr-rrr r r r r. s r.c@seZdZdZdifddZddZddZd d Zdkd d Zdld dZ ddZ dmddZ ddZ dnddZ ddZddZddZddZdodd Zd!d"Zdpd#d$Zifd%d&Zd'd(Zd)d*Zd+d,Zdqd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zifd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#drdCdDZ$dEdFZ%dGdHZ&dsdIdJZ'dtdKdLZ(dMdNZ)dudOdPZ*e*Z+dQdRZ,dvdSdTZ-dwdUdVZ.dxdWdXZ/dydYdZZ0dzd[d\Z1d]d^Z2d{d_d`Z3dadbZ4d|dcddZ5e5Z6ifdedfZ7dgdhZ8didjZ9dS)}Textz4Text widget which can display text in various forms.NcKst||d||dS)aConstruct a text widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, padx, pady, relief, selectbackground, selectborderwidth, selectforeground, setgrid, takefocus, xscrollcommand, yscrollcommand, WIDGET-SPECIFIC OPTIONS autoseparators, height, maxundo, spacing1, spacing2, spacing3, state, tabs, undo, width, wrap, rNrrr r r r sz Text.__init__cCs||j|jd|pdS)zReturn a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the given index.rNrArr r r r s z Text.bboxc Cs|j|j|jd|||S)zReturn whether between index INDEX1 and index INDEX2 the relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=.comparer*)rer opr!r r r r0 s z Text.comparecGsVdd|D}|||g7}|jj|jdf|p2d}|dk rNt|dkrN|fS|SdS)aCounts the number of relevant things between the two indices. If index1 is after index2, the result will be a negative number (and this holds for each of the possible options). The actual items which are counted depends on the options given by args. The result is a list of integers, one for the result of each counting option given. Valid counting options are "chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels" and "ypixels". There is an additional possible option "update", which if given then all subsequent options ensure that any possible out of date information is recalculated.cSsg|]}|dsd|qS)r-r) startswith)rJargr r r rs zText.count..r|N)r2rrr)rer r!rrr r r r| s  z Text.countcCs6|dkr |j|j|jdS|j|jd|dS)zjTurn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.Ndebugr*rr r r r5 sz Text.debugcCs|j|jd||dS)z?Delete the characters between INDEX1 and INDEX2 (not included).rNrrer r!r r r rsz Text.deletecCs||j|jd|S)zReturn tuple (x,y,width,height,baseline) giving the bounding box and baseline position of the visible part of the line containing the character at INDEX. dlineinforArr r r r7szText.dlineinfoc Ksg}d}d}|s$g}|fdd}|}zzt|ts>||}}|d|g7}|D]} || rN|d| qN|||r|||jj|jdf||WS|r||XdS)aReturn the contents of the widget between index1 and index2. The type of contents returned in filtered based on the keyword parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are given and true, then the corresponding items are returned. The result is a list of triples of the form (key, value, index). If none of the keywords are true then 'all' is used by default. If the 'command' argument is given, it is called once for each element of the list of triples, with the values of each triple serving as the arguments to the function. In this case the list is not returned.NcSs||||fdSr)rc)r6r rr%r r r append_triple/sz Text.dump..append_triplez-commandr-dump)rrrrrcr2rr) rer r!rrrZ func_namer%r8r6r r r r9s*      z Text.dumpcGs|jj|jdf|S)arInternal method This method controls the undo mechanism and the modified flag. The exact behavior of the command depends on the option argument that follows the edit argument. The following forms of the command are currently supported: edit_modified, edit_redo, edit_reset, edit_separator and edit_undo editrrr r r r:Bs z Text.editcCs |d|S)a;Get or Set the modified flag If arg is not specified, returns the modified flag of the widget. The insert, delete, edit undo and edit redo commands or the user can set or clear the modified flag. If boolean is specified, sets the modified flag of the widget to arg. Zmodifiedr:)rer3r r r edit_modifiedQs zText.edit_modifiedcCs |dS)a Redo the last undone edit When the undo option is true, reapplies the last undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the undo option is false. Zredor;rr r r edit_redo\szText.edit_redocCs |dS)z(Clears the undo and redo stacks resetr;rr r r edit_resetfszText.edit_resetcCs |dS)znInserts a separator (boundary) on the undo stack. Does nothing when the undo option is false rr;rr r r edit_separatorkszText.edit_separatorcCs |dS)aDUndoes the last edit action If the undo option is true. An edit action is defined as all the insert and delete commands that are recorded on the undo stack in between two separators. Generates an error when the undo stack is empty. Does nothing when the undo option is false Zundor;rr r r edit_undors zText.edit_undocCs|j|jd||S)z5Return the text from INDEX1 to INDEX2 (not included).rrr6r r r r}szText.getcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z9Return the value of OPTION of an embedded image at INDEX.Nrr-rrrrrr r r r image_cgets  zText.image_cgetcKs|dd|f||S)z%Configure an embedded image at INDEX.rrrrr r r image_configureszText.image_configurecKs"|jj|jdd|f|||S)z"Create an embedded image at INDEX.rr@rirr r r image_creates zText.image_createcCs|j|jddS)z3Return all names of embedded images in this widget.rrrrr r r rszText.image_namescCst|j|jd|S)z1Return the index in the form line.char for INDEX.r)rr2rrrr r r rsz Text.indexcGs|j|jd||f|dS)zInsert CHARS before the characters at INDEX. An additional tag can be given in ARGS. Additional CHARS and tags can follow in ARGS.rNr)rercharsrr r r rsz Text.insertcCs|j|jdd||fS)zChange the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT). Return the current value if None is given for DIRECTION.rZgravityr)remarkName directionr r r mark_gravityszText.mark_gravitycCs|j|j|jddS)zReturn all mark names.rrrhrr r r mark_namess  zText.mark_namescCs|j|jdd||dS)z0Set mark MARKNAME before the character at INDEX.rrNr)rerFrr r r mark_setsz Text.mark_setcGs|j|jddf|dS)zDelete all marks in MARKNAMES.rZunsetNr)reZ markNamesr r r mark_unsetszText.mark_unsetcCs|j|jdd|pdS)z-Return the name of the next mark after INDEX.rnextNrrr r r mark_nextszText.mark_nextcCs|j|jdd|pdS)z2Return the name of the previous mark before INDEX.rZpreviousNrrr r r mark_previousszText.mark_previouscKs&|jj|jdd|f|||dS)aCreates a peer text widget with the given newPathName, and any optional standard configuration options. By default the peer will have the same start and end line as the parent widget, but these can be overridden with the standard configuration options.peerr@Nri)reZ newPathNamer&rr r r peer_creates zText.peer_createcCs|j|j|jddS)zYReturns a list of peers of this widget (this does not include the widget itself).rOrrhrr r r peer_namesszText.peer_namescGs |jj|jd|||f|dS)zReplaces the range of characters between index1 and index2 with the given characters and tags specified by args. See the method insert for some more information about args, and the method delete for information about the indices.rNr)rer r!rErr r r rsz Text.replacecCs|j|jdd||dSrrrr r r rszText.scan_markcCs|j|jdd||dS)z~Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.rrNrrr r r rszText.scan_dragtoc Cs|jdg} |r| d|r&| d|r4| d|rB| d|rP| d| r^| d| rv| d| | |r|d d kr| d | || ||r| |t|jt| S) zSearch PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.rz -forwardsz -backwardsz-exactz-regexpz-nocasez-elidez-countrr-r)rrcrr2rr) rerrZ stopindexZforwardsZ backwardsexactZregexpZnocaser|Zeliderr r r rs.            z Text.searchcCs|j|jd|dS)z3Scroll such that the character at INDEX is visible.rNrrr r r rszText.seecGs |j|jdd||f|dS)z|Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS. Additional pairs of indices may follow in ARGS.tagrNr)retagNamer rr r r tag_addsz Text.tag_addcCs*|j|jdd||d|r&||dS)zgUnbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.rSrprZNrs)rerTrlrnr r r rszText.tag_unbindcCs||jdd|f|||S)a+Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rSrprq)rerTrlrrr r r rs z Text.tag_bindcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z+Return the value of OPTION for tag TAGNAME.Nrr-rrrSrr)rerTrr r r tag_cget s  z Text.tag_cgetcKs|dd|f||S)zConfigure a tag TAGNAME.rSrr)rerTr&rr r r tag_configureszText.tag_configurecGs|j|jddf|dS)zDelete all tags in TAGNAMES.rSrNr)reZtagNamesr r r tag_deleteszText.tag_deletecCs|j|jdd||dS)z`Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.rSrNr)rerTrr r r rszText.tag_lowercCs|j|j|jdd|S)zReturn a list of all tag names.rSrrhrr r r tag_names szText.tag_namesc Cs |j|j|jdd|||S)zReturn a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched forward from INDEX1.rSZ nextrangerhrerTr r!r r r tag_nextrange%s zText.tag_nextrangec Cs |j|j|jdd|||S)zReturn a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched backwards from INDEX1.rSZ prevrangerhrZr r r tag_prevrange,s zText.tag_prevrangecCs|j|jdd||dS)zaChange the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.rSrNr)rerTrr r r r3szText.tag_raisecCs|j|j|jdd|S)z7Return a list of ranges of text which have tag TAGNAME.rSZrangesrh)rerTr r r tag_ranges9s  zText.tag_rangescCs|j|jdd|||dS)zARemove tag TAGNAME from all characters between INDEX1 and INDEX2.rSrNrrZr r r tag_remove>szText.tag_removecCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z:Return the value of OPTION of an embedded window at INDEX.Nrr-rrrrrr r r r window_cgetCs  zText.window_cgetcKs|dd|f||S)z&Configure an embedded window at INDEX.rrrrr r r window_configureKszText.window_configurecKs&|j|jdd|f|||dS)zCreate a window at INDEX.rr@Nrirr r r window_createQs   zText.window_createcCs|j|j|jddS)z4Return all names of embedded windows in this widget.rrrhrr r r window_namesWszText.window_namescGs|j|jddf|dS)zObsolete function, use see.rz -pickplaceNr)rerqr r r yview_pickplace\szText.yview_pickplace)N)N)NN)N)N)N)N)NNNNNNNN)N)N)N)N)N)N)N)N)N)N):rArBrCrkrrr0r|r5rr7r9r:r<r=r?r@rArrBrCrDrrrrHrIrJrKrMrNrPrQrrrrrrUrrrVrWZ tag_configrXrrYr[r\rr]r^r_r`Z window_configrarbrcr r r r r/ s~   (                   r/c@s"eZdZdZdddZddZdS)_setitz>Internal class. It wraps the command in the widget OptionMenu.NcCs||_||_||_dSr) _setit__value _setit__var_setit__callback)revarr rr r r rdsz_setit.__init__cGs*|j|j|jr&|j|jf|dSr)rfrrergrr r r risz_setit.__call__)Nrr r r r rdas rdc@s(eZdZdZddZddZddZdS) OptionMenuz?OptionMenu which allows the user to select a value from a menu.c Osd|dtddd}t||d|d|_t|ddd }|_|j|_|d }d |kr\|d =|rtt d t t ||j |t |||d |D]} |j | t || |d q||d<d S)zConstruct an optionmenu widget with the parent MASTER, with the resource textvariable set to VARIABLE, the initially selected value VALUE, the other menu values VALUES and an additional keyword argument command.r,rr')Z borderwidthZ textvariableZ indicatoronZreliefrZhighlightthicknessr(Z tk_optionMenur r)rYZtearoffrzunknown option -)rrN)ZRAISEDrrr~r _OptionMenu__menurZmenunamerrrLr0rrd) rerrr rRkwargsrr rr*r r r rrs.   zOptionMenu.__init__cCs|dkr|jSt||S)Nr )rjrrrr r r rszOptionMenu.__getitem__cCst|d|_dS)z,Destroy this widget and the associated menu.N)r'rrjrr r r rs zOptionMenu.destroyN)rArBrCrkrrrr r r r riosric@sheZdZdZdZdidfddZddZdd Zd d Zd d Z ddZ e Z ddZ ddZ ddZdS)ImagezBase class for images.rNc Ksd|_|std}t|d||_|s>tjd7_dtjf}|rT|rTt||f}n|r\|}d}|D]*\}}t|r| |}|d||f}qh|j dd||f|||_dS) Nz create imager2rz pyimage%rr r-rr@) rYrsr`r2rl_last_idr+r%rrr) reZimgtyperYr&rrrr)r*r r r rs$  zImage.__init__cCs|jSr)rYrr r r rFz Image.__str__cCs6|jr2z|jdd|jWntk r0YnXdS)Nrr)rYr2rrrr r r rs z Image.__del__cCs|j|jdd||dSNrr-r2rrYrr r r rszImage.__setitem__cCs|j|jdd|Srorprr r r rszImage.__getitem__cKsvd}t|D]J\}}|dk r|ddkr8|dd}t|rJ||}|d||f}q|j|jdf|dS)zConfigure the image.r Nrrr-r)r+r%rrr2rrY)rerrr)r*r r r rs  zImage.configurecCs|j|jdd|jS)zReturn the height of the image.rrXr2rrrYrr r r rXsz Image.heightcCs|jdd|jS)z7Return the type of the image, e.g. "photo" or "bitmap".rr rprr r r r sz Image.typecCs|j|jdd|jS)zReturn the width of the image.rrWrqrr r r rWsz Image.width)rArBrCrkrmrrFrrrrrrXr rWr r r r rls rlc@seZdZdZdidfddZddZddZd d Zd d ZdddZ dddZ ddZ dddZ dddZ ddZddZdS) PhotoImagez=Widget which can display images in PGM, PPM, GIF, PNG format.NcKstj|d|||f|dS)ztCreate an image with NAME. Valid resource names: data, format, file, gamma, height, palette, width.ZphotoNrlrrerYr&rrr r r rszPhotoImage.__init__cCs|j|jddS)zDisplay a transparent image.blankNrprr r r ruszPhotoImage.blankcCs|j|jdd|S)zReturn the value of OPTION.rr-rp)rerr r r rszPhotoImage.cgetcCs|j|jdd|S)Nrr-rprr r r rszPhotoImage.__getitem__cCs"t|jd}|j|d|j|S)z;Return a new PhotoImage with the same image as this widget.rcopyrrr2rrY)re destImager r r rvs zPhotoImage.copyrZcCs4t|jd}|dkr|}|j|d|jd|||S)zReturn a new PhotoImage with the same image as this widget but zoom it with a factor of x in the X direction and y in the Y direction. If y is not given, the default value is the same as x. rrZrvz-zoomrwrerUrVrxr r r zooms  zPhotoImage.zoomcCs4t|jd}|dkr|}|j|d|jd|||S)zReturn a new PhotoImage based on the same image as this widget but use only every Xth or Yth pixel. If y is not given, the default value is the same as x. rrZrvz -subsamplerwryr r r subsamples  zPhotoImage.subsamplecCs|j|jd||S)z8Return the color (red, green, blue) of the pixel at X,Y.rrprr r r r szPhotoImage.getcCsH|jd|f}|r8|ddkr(|dd}|dt|}|j|dS)zzPut row formatted colors to image starting from position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))putr-torN)r}rYrr2r)rerrrr r r r| s    zPhotoImage.putcCs@|jd|f}|r|d|f}|r0|dt|}|j|dS)zRWrite image to file FILENAME in FORMAT starting from position FROM_COORDS.writez-format)z-fromNr~)refilenameformatZ from_coordsrr r r rs   zPhotoImage.writec Cs|j|j|jdd||S)z/Return True if the pixel at x,y is transparent. transparencyr)r2rrrYrr r r transparency_get"s zPhotoImage.transparency_getcCs|j|jdd|||dS)z)Set the transparency of the pixel at x,y.rrNrp)rerUrVrr r r transparency_set'szPhotoImage.transparency_set)rZ)rZ)N)NN)rArBrCrkrrurrrvrzr{rr|rrrr r r r rrs  rrc@s eZdZdZdidfddZdS) BitmapImagez.Widget which can display images in XBM format.NcKstj|d|||f|dS)zqCreate a bitmap with NAME. Valid resource names: background, data, file, foreground, maskdata, maskfile.rNrsrtr r r r/szBitmapImage.__init__rr r r r r,srcCstdj}||ddS)Nzuse image_names()rrrsr2r.rr2r r r r6s rcCstdj}||ddS)Nzuse image_types()rrrrr r r r;s rc@seZdZdZdifddZddZd+ddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd,d!d"Zd#d$Zd%d&Zd'd(Zd)d*ZdS)-Spinboxzspinbox widget.NcKst||d||dS)aConstruct a spinbox widget with the parent MASTER. STANDARD OPTIONS activebackground, background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, justify, relief, repeatdelay, repeatinterval, selectbackground, selectborderwidth selectforeground, takefocus, textvariable xscrollcommand. WIDGET-SPECIFIC OPTIONS buttonbackground, buttoncursor, buttondownrelief, buttonuprelief, command, disabledbackground, disabledforeground, format, from, invalidcommand, increment, readonlybackground, state, to, validate, validatecommand values, width, wrap, ZspinboxNrrr r r rCszSpinbox.__init__cCs||j|jd|pdS)aReturn a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the character given by index. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window. rNrArr r r r`s z Spinbox.bboxcCs|j|jd||S)aWDelete one or more elements of the spinbox. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last isn't specified it defaults to first+1, i.e. a single character is deleted. This command returns an empty string. rrrr r r rns zSpinbox.deletecCs|j|jdS)zReturns the spinbox's stringrrrr r r rysz Spinbox.getcCs|j|jd|S)zAlter the position of the insertion cursor. The insertion cursor will be displayed just before the character given by index. Returns an empty string rrrr r r r}szSpinbox.icursorcCs|j|jd||S)z{Returns the name of the widget at position x, y Return value is one of: none, buttondown, buttonup, entry r-rrr r r r-szSpinbox.identifycCs|j|jd|S)z;Returns the numerical index corresponding to index rrrr r r rsz Spinbox.indexcCs|j|jd||S)zDInsert string s at index Returns an empty string. rr)rerrfr r r rszSpinbox.insertcCs|j|jd|S)zCauses the specified element to be invoked The element could be buttondown or buttonup triggering the action associated with it. rrreelementr r r rszSpinbox.invokecGs ||j|jdf|pdS)rrr rArr r r rs z Spinbox.scancCs |d|S)zRecords x and the current view in the spinbox window; used in conjunction with later scan dragto commands. Typically this command is associated with a mouse button press in the widget. It returns an empty string. rrr^r r r rszSpinbox.scan_markcCs |d|S)aCompute the difference between the given x argument and the x argument to the last scan mark command It then adjusts the view left or right by 10 times the difference in x-coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the spinbox at high speed through the window. The return value is an empty string. rrr^r r r rs zSpinbox.scan_dragtocGs ||j|jdf|pdS)rr r rArr r r r s zSpinbox.selectioncCs |d|S)aLocate the end of the selection nearest to the character given by index, Then adjust that end of the selection to be at index (i.e including but not going beyond index). The other end of the selection is made the anchor point for future select to commands. If the selection isn't currently in the spinbox, then a new selection is created to include the characters between index and the most recent selection anchor point, inclusive. rr rr r r rs zSpinbox.selection_adjustcCs |dS)zsClear the selection If the selection isn't in this widget then the command has no effect. rrrr r r rszSpinbox.selection_clearcCs|j|jdd|S)zSets or gets the currently selected element. If a spinbutton element is specified, it will be displayed depressed. r rrrr r r selection_elementszSpinbox.selection_elementcCs|d|dS)rrNrrr r r rszSpinbox.selection_fromcCs|j|j|jddS)zUReturn True if there are characters selected in the spinbox, False otherwise.r rr*rr r r rszSpinbox.selection_presentcCs|d||dS)rrNrrr r r rszSpinbox.selection_rangecCs|d|dS)rrNrrr r r rszSpinbox.selection_to)N)N)rArBrCrkrrrrrr-rrrrrrr rrrrrrrr r r r r@s*    rc@seZdZdZdifddZdS) LabelFramezlabelframe widget.NcKst||d||dS)aConstruct a labelframe widget with the parent MASTER. STANDARD OPTIONS borderwidth, cursor, font, foreground, highlightbackground, highlightcolor, highlightthickness, padx, pady, relief, takefocus, text WIDGET-SPECIFIC OPTIONS background, class, colormap, container, height, labelanchor, labelwidget, visual, width Z labelframeNrrr r r rszLabelFrame.__init__rr r r r rsrc@seZdZdZdifddZddZddZeZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZd!ddZeZdd ZdS)" PanedWindowzpanedwindow widget.NcKst||d||dS)aTConstruct a panedwindow widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, height, orient, relief, width WIDGET-SPECIFIC OPTIONS handlepad, handlesize, opaqueresize, sashcursor, sashpad, sashrelief, sashwidth, showhandle, Z panedwindowNrrr r r r szPanedWindow.__init__cKs"|j|jd|f||dS)a+Add a child widget to the panedwindow in a new pane. The child argument is the name of the child widget followed by pairs of arguments that specify how to manage the windows. The possible options and values are the ones accepted by the paneconfigure method. rNri)rer&rr r r rszPanedWindow.addcCs|j|jd|dS)zRemove the pane containing child from the panedwindow All geometry management options for child will be forgotten. rNr)rer&r r r r'szPanedWindow.removecCs|j|jd||S)aIdentify the panedwindow component at point x, y If the point is over a sash or a sash handle, the result is a two element list containing the index of the sash or handle, and a word indicating whether it is over a sash or a handle, such as {0 sash} or {2 handle}. If the point is over any other part of the panedwindow, the result is an empty list. r-rrr r r r-0s zPanedWindow.identifycGs ||j|jdf|pdS)rproxyr rArr r r r<s zPanedWindow.proxycCs |dS)zBReturn the x and y pair of the most recent proxy location coordrrr r r proxy_coordAszPanedWindow.proxy_coordcCs |dS)z+Remove the proxy from the display. rrrr r r proxy_forgetFszPanedWindow.proxy_forgetcCs|d||S)z:Place the proxy at the given x and y coordinates. rrrr r r proxy_placeKszPanedWindow.proxy_placecGs ||j|jdf|pdS)rsashr rArr r r rPs zPanedWindow.sashcCs |d|S)aAReturn the current x and y pair for the sash given by index. Index must be an integer between 0 and 1 less than the number of panes in the panedwindow. The coordinates given are those of the top left corner of the region containing the sash. pathName sash dragto index x y This command computes the difference between the given coordinates and the coordinates given to the last sash coord command for the given sash. It then moves that sash the computed difference. The return value is the empty string. rrrr r r sash_coordUs zPanedWindow.sash_coordcCs |d|S)zRecords x and y for the sash given by index; Used in conjunction with later dragto commands to move the sash. rrrr r r sash_markcszPanedWindow.sash_markcCs|d|||S)z?Place the sash given by index at the given coordinates rr)rerrUrVr r r sash_placejszPanedWindow.sash_placecCs|j|jdf|d|fS)zwQuery a management option for window. Option may be any value allowed by the paneconfigure subcommand panecgetr-r)rer&rr r r roszPanedWindow.panecgetcKsd|dkr|s||jd|St|tr@|s@||jd|d|S|j|jd|f|||dS)a Query or modify the management options for window. If no option is specified, returns a list describing all of the available options for pathName. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. The following options are supported: after window Insert the window after the window specified. window should be the name of a window already managed by pathName. before window Insert the window before the window specified. window should be the name of a window already managed by pathName. height size Specify a height for the window. The height will be the outer dimension of the window including its border, if any. If size is an empty string, or if -height is not specified, then the height requested internally by the window will be used initially; the height may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. minsize n Specifies that the size of the window cannot be made less than n. This constraint only affects the size of the widget in the paned dimension -- the x dimension for horizontal panedwindows, the y dimension for vertical panedwindows. May be any value accepted by Tk_GetPixels. padx n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the X-direction. The value may have any of the forms accepted by Tk_GetPixels. pady n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the Y-direction. The value may have any of the forms accepted by Tk_GetPixels. sticky style If a window's pane is larger than the requested dimensions of the window, this option may be used to position (or stretch) the window within its pane. Style is a string that contains zero or more of the characters n, s, e or w. The string can optionally contains spaces or commas, but they are ignored. Each letter refers to a side (north, south, east, or west) that the window will "stick" to. If both n and s (or e and w) are specified, the window will be stretched to fill the entire height (or width) of its cavity. width size Specify a width for the window. The width will be the outer dimension of the window including its border, if any. If size is an empty string, or if -width is not specified, then the width requested internally by the window will be used initially; the width may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. N paneconfigurer-)rrrrrr2rrrr r r rwsD  zPanedWindow.paneconfigurecCs|j|j|jdS)z+Returns an ordered list of the child panes.panesrhrr r r rszPanedWindow.panes)N)rArBrCrkrrrrr-rrrrrrrrrrZ paneconfigrr r r r r s$   LrcCst}dt}|d7}t||d}|t|d|fddd}|||_t|d|jd}|||| | dS) NzThis is Tcl/Tk version %su This should be a cedilla: çrz Click me!cSs|jjd|jddS)Nz[%s]rr)testr)rrr r r s z_test..)rrZQUIT) ro TclVersionrrrDrrrr!rr)rrrrrr{r r r _tests   r__main__)TN)N)r)r)NNror)VrkenumrrrZtkinter.constantsrerAfloatrPZ TkVersionrQrZREADABLEZWRITABLEZ EXCEPTIONcompilerASCIIrr rrr"r+r7rEnumr8rGrlrmrnrsrvrzrr{rrrrrrarrrrrrrrrorgrhrqrvr{rrrDrrrrrrr r'r)r+r,r.r/rdrirlrrrrrrrrrrAr r r r s        ,R  6  q2~ .37?/8$Vt!'2'BT 3C PK!OU)__pycache__/__main__.cpython-38.opt-2.pycnu[U e5d@s8ddlZejddr"dejd<ddlmZedS)Nz __main__.pyzpython -m tkinter)_test)sysargvendswithrmainr r (/usr/lib64/python3.8/tkinter/__main__.pys  PK!pcommondialog.pynu[# base class for tk common dialogues # # this module provides a base class for accessing the common # dialogues available in Tk 4.2 and newer. use filedialog, # colorchooser, and messagebox to access the individual # dialogs. # # written by Fredrik Lundh, May 1997 # from tkinter import * class Dialog: command = None def __init__(self, master=None, **options): if not master: master = options.get('parent') self.master = master self.options = options def _fixoptions(self): pass # hook def _fixresult(self, widget, result): return result # hook def show(self, **options): # update instance options for k, v in options.items(): self.options[k] = v self._fixoptions() # we need a dummy widget to properly process the options # (at least as long as we use Tkinter 1.63) w = Frame(self.master) try: s = w.tk.call(self.command, *w._options(self.options)) s = self._fixresult(w, s) finally: try: # get rid of the widget w.destroy() except: pass return s PK!Ss-,,dnd.pynu["""Drag-and-drop support for Tkinter. This is very preliminary. I currently only support dnd *within* one application, between different windows (or within the same window). I am trying to make this as generic as possible -- not dependent on the use of a particular widget or icon type, etc. I also hope that this will work with Pmw. To enable an object to be dragged, you must create an event binding for it that starts the drag-and-drop process. Typically, you should bind to a callback function that you write. The function should call Tkdnd.dnd_start(source, event), where 'source' is the object to be dragged, and 'event' is the event that invoked the call (the argument to your callback function). Even though this is a class instantiation, the returned instance should not be stored -- it will be kept alive automatically for the duration of the drag-and-drop. When a drag-and-drop is already in process for the Tk interpreter, the call is *ignored*; this normally averts starting multiple simultaneous dnd processes, e.g. because different button callbacks all dnd_start(). The object is *not* necessarily a widget -- it can be any application-specific object that is meaningful to potential drag-and-drop targets. Potential drag-and-drop targets are discovered as follows. Whenever the mouse moves, and at the start and end of a drag-and-drop move, the Tk widget directly under the mouse is inspected. This is the target widget (not to be confused with the target object, yet to be determined). If there is no target widget, there is no dnd target object. If there is a target widget, and it has an attribute dnd_accept, this should be a function (or any callable object). The function is called as dnd_accept(source, event), where 'source' is the object being dragged (the object passed to dnd_start() above), and 'event' is the most recent event object (generally a event; it can also be or ). If the dnd_accept() function returns something other than None, this is the new dnd target object. If dnd_accept() returns None, or if the target widget has no dnd_accept attribute, the target widget's parent is considered as the target widget, and the search for a target object is repeated from there. If necessary, the search is repeated all the way up to the root widget. If none of the target widgets can produce a target object, there is no target object (the target object is None). The target object thus produced, if any, is called the new target object. It is compared with the old target object (or None, if there was no old target widget). There are several cases ('source' is the source object, and 'event' is the most recent event object): - Both the old and new target objects are None. Nothing happens. - The old and new target objects are the same object. Its method dnd_motion(source, event) is called. - The old target object was None, and the new target object is not None. The new target object's method dnd_enter(source, event) is called. - The new target object is None, and the old target object is not None. The old target object's method dnd_leave(source, event) is called. - The old and new target objects differ and neither is None. The old target object's method dnd_leave(source, event), and then the new target object's method dnd_enter(source, event) is called. Once this is done, the new target object replaces the old one, and the Tk mainloop proceeds. The return value of the methods mentioned above is ignored; if they raise an exception, the normal exception handling mechanisms take over. The drag-and-drop processes can end in two ways: a final target object is selected, or no final target object is selected. When a final target object is selected, it will always have been notified of the potential drop by a call to its dnd_enter() method, as described above, and possibly one or more calls to its dnd_motion() method; its dnd_leave() method has not been called since the last call to dnd_enter(). The target is notified of the drop by a call to its method dnd_commit(source, event). If no final target object is selected, and there was an old target object, its dnd_leave(source, event) method is called to complete the dnd sequence. Finally, the source object is notified that the drag-and-drop process is over, by a call to source.dnd_end(target, event), specifying either the selected target object, or None if no target object was selected. The source object can use this to implement the commit action; this is sometimes simpler than to do it in the target's dnd_commit(). The target's dnd_commit() method could then simply be aliased to dnd_leave(). At any time during a dnd sequence, the application can cancel the sequence by calling the cancel() method on the object returned by dnd_start(). This will call dnd_leave() if a target is currently active; it will never call dnd_commit(). """ import tkinter # The factory function def dnd_start(source, event): h = DndHandler(source, event) if h.root: return h else: return None # The class that does the work class DndHandler: root = None def __init__(self, source, event): if event.num > 5: return root = event.widget._root() try: root.__dnd return # Don't start recursive dnd except AttributeError: root.__dnd = self self.root = root self.source = source self.target = None self.initial_button = button = event.num self.initial_widget = widget = event.widget self.release_pattern = "" % (button, button) self.save_cursor = widget['cursor'] or "" widget.bind(self.release_pattern, self.on_release) widget.bind("", self.on_motion) widget['cursor'] = "hand2" def __del__(self): root = self.root self.root = None if root: try: del root.__dnd except AttributeError: pass def on_motion(self, event): x, y = event.x_root, event.y_root target_widget = self.initial_widget.winfo_containing(x, y) source = self.source new_target = None while target_widget: try: attr = target_widget.dnd_accept except AttributeError: pass else: new_target = attr(source, event) if new_target: break target_widget = target_widget.master old_target = self.target if old_target is new_target: if old_target: old_target.dnd_motion(source, event) else: if old_target: self.target = None old_target.dnd_leave(source, event) if new_target: new_target.dnd_enter(source, event) self.target = new_target def on_release(self, event): self.finish(event, 1) def cancel(self, event=None): self.finish(event, 0) def finish(self, event, commit=0): target = self.target source = self.source widget = self.initial_widget root = self.root try: del root.__dnd self.initial_widget.unbind(self.release_pattern) self.initial_widget.unbind("") widget['cursor'] = self.save_cursor self.target = self.source = self.initial_widget = self.root = None if target: if commit: target.dnd_commit(source, event) else: target.dnd_leave(source, event) finally: source.dnd_end(target, event) # ---------------------------------------------------------------------- # The rest is here for testing and demonstration purposes only! class Icon: def __init__(self, name): self.name = name self.canvas = self.label = self.id = None def attach(self, canvas, x=10, y=10): if canvas is self.canvas: self.canvas.coords(self.id, x, y) return if self.canvas: self.detach() if not canvas: return label = tkinter.Label(canvas, text=self.name, borderwidth=2, relief="raised") id = canvas.create_window(x, y, window=label, anchor="nw") self.canvas = canvas self.label = label self.id = id label.bind("", self.press) def detach(self): canvas = self.canvas if not canvas: return id = self.id label = self.label self.canvas = self.label = self.id = None canvas.delete(id) label.destroy() def press(self, event): if dnd_start(self, event): # where the pointer is relative to the label widget: self.x_off = event.x self.y_off = event.y # where the widget is relative to the canvas: self.x_orig, self.y_orig = self.canvas.coords(self.id) def move(self, event): x, y = self.where(self.canvas, event) self.canvas.coords(self.id, x, y) def putback(self): self.canvas.coords(self.id, self.x_orig, self.y_orig) def where(self, canvas, event): # where the corner of the canvas is relative to the screen: x_org = canvas.winfo_rootx() y_org = canvas.winfo_rooty() # where the pointer is relative to the canvas widget: x = event.x_root - x_org y = event.y_root - y_org # compensate for initial pointer offset return x - self.x_off, y - self.y_off def dnd_end(self, target, event): pass class Tester: def __init__(self, root): self.top = tkinter.Toplevel(root) self.canvas = tkinter.Canvas(self.top, width=100, height=100) self.canvas.pack(fill="both", expand=1) self.canvas.dnd_accept = self.dnd_accept def dnd_accept(self, source, event): return self def dnd_enter(self, source, event): self.canvas.focus_set() # Show highlight border x, y = source.where(self.canvas, event) x1, y1, x2, y2 = source.canvas.bbox(source.id) dx, dy = x2-x1, y2-y1 self.dndid = self.canvas.create_rectangle(x, y, x+dx, y+dy) self.dnd_motion(source, event) def dnd_motion(self, source, event): x, y = source.where(self.canvas, event) x1, y1, x2, y2 = self.canvas.bbox(self.dndid) self.canvas.move(self.dndid, x-x1, y-y1) def dnd_leave(self, source, event): self.top.focus_set() # Hide highlight border self.canvas.delete(self.dndid) self.dndid = None def dnd_commit(self, source, event): self.dnd_leave(source, event) x, y = source.where(self.canvas, event) source.attach(self.canvas, x, y) def test(): root = tkinter.Tk() root.geometry("+1+1") tkinter.Button(command=root.quit, text="Quit").pack() t1 = Tester(root) t1.top.geometry("+1+60") t2 = Tester(root) t2.top.geometry("+120+60") t3 = Tester(root) t3.top.geometry("+240+60") i1 = Icon("ICON1") i2 = Icon("ICON2") i3 = Icon("ICON3") i1.attach(t1.canvas) i2.attach(t2.canvas) i3.attach(t3.canvas) root.mainloop() if __name__ == '__main__': test() PK!c constants.pynu[# Symbolic constants for Tk # Booleans NO=FALSE=OFF=0 YES=TRUE=ON=1 # -anchor and -sticky N='n' S='s' W='w' E='e' NW='nw' SW='sw' NE='ne' SE='se' NS='ns' EW='ew' NSEW='nsew' CENTER='center' # -fill NONE='none' X='x' Y='y' BOTH='both' # -side LEFT='left' TOP='top' RIGHT='right' BOTTOM='bottom' # -relief RAISED='raised' SUNKEN='sunken' FLAT='flat' RIDGE='ridge' GROOVE='groove' SOLID = 'solid' # -orient HORIZONTAL='horizontal' VERTICAL='vertical' # -tabs NUMERIC='numeric' # -wrap CHAR='char' WORD='word' # -align BASELINE='baseline' # -bordermode INSIDE='inside' OUTSIDE='outside' # Special tags, marks and insert positions SEL='sel' SEL_FIRST='sel.first' SEL_LAST='sel.last' END='end' INSERT='insert' CURRENT='current' ANCHOR='anchor' ALL='all' # e.g. Canvas.delete(ALL) # Text widget and button states NORMAL='normal' DISABLED='disabled' ACTIVE='active' # Canvas state HIDDEN='hidden' # Menu item types CASCADE='cascade' CHECKBUTTON='checkbutton' COMMAND='command' RADIOBUTTON='radiobutton' SEPARATOR='separator' # Selection modes for list boxes SINGLE='single' BROWSE='browse' MULTIPLE='multiple' EXTENDED='extended' # Activestyle for list boxes # NONE='none' is also valid DOTBOX='dotbox' UNDERLINE='underline' # Various canvas styles PIESLICE='pieslice' CHORD='chord' ARC='arc' FIRST='first' LAST='last' BUTT='butt' PROJECTING='projecting' ROUND='round' BEVEL='bevel' MITER='miter' # Arguments to xview/yview MOVETO='moveto' SCROLL='scroll' UNITS='units' PAGES='pages' PK!scrolledtext.pynu["""A ScrolledText widget feels like a text widget but also has a vertical scroll bar on its right. (Later, options may be added to add a horizontal bar as well, to make the bars disappear automatically when not needed, to move them to the other side of the window, etc.) Configuration options are passed to the Text widget. A Frame widget is inserted between the master and the text, to hold the Scrollbar widget. Most methods calls are inherited from the Text widget; Pack, Grid and Place methods are redirected to the Frame widget however. """ __all__ = ['ScrolledText'] from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place from tkinter.constants import RIGHT, LEFT, Y, BOTH class ScrolledText(Text): def __init__(self, master=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) kw.update({'yscrollcommand': self.vbar.set}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = vars(Text).keys() methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys() methods = methods.difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m)) def __str__(self): return str(self.frame) def example(): from tkinter.constants import END stext = ScrolledText(bg='white', height=10) stext.insert(END, __doc__) stext.pack(fill=BOTH, side=LEFT, expand=True) stext.focus_set() stext.mainloop() if __name__ == "__main__": example() PK!6; dialog.pynu[# dialog.py -- Tkinter interface to the tk_dialog script. from tkinter import * from tkinter import _cnfmerge DIALOG_ICON = 'questhead' class Dialog(Widget): def __init__(self, master=None, cnf={}, **kw): cnf = _cnfmerge((cnf, kw)) self.widgetName = '__dialog__' Widget._setup(self, master, cnf) self.num = self.tk.getint( self.tk.call( 'tk_dialog', self._w, cnf['title'], cnf['text'], cnf['bitmap'], cnf['default'], *cnf['strings'])) try: Widget.destroy(self) except TclError: pass def destroy(self): pass def _test(): d = Dialog(None, {'title': 'File Modified', 'text': 'File "Python.h" has been modified' ' since the last time it was saved.' ' Do you want to save it before' ' exiting the application.', 'bitmap': DIALOG_ICON, 'default': 0, 'strings': ('Save File', 'Discard Changes', 'Return to Editor')}) print(d.num) if __name__ == '__main__': t = Button(None, {'text': 'Test', 'command': _test, Pack: {}}) q = Button(None, {'text': 'Quit', 'command': t.quit, Pack: {}}) t.mainloop() PK!}N  matt/pong-demo-1.pynu[PK!>;Pmatt/packer-simple.pycnu[PK!MhΩ & matt/canvas-moving-w-mouse.pycnu[PK!~ matt/00-HELLO-WORLD.pynu[PK!)7matt/canvas-reading-tag-info.pynu[PK!f 44# matt/window-creation-w-location.pyonu[PK!  (matt/canvas-gridding.pycnu[PK!k1matt/dialog-box.pyonu[PK!a>oQ"9matt/animation-w-velocity-ctrl.pyonu[PK!]!0Bmatt/animation-w-velocity-ctrl.pynu[PK!Vkk"2Gmatt/menu-all-types-of-entries.pycnu[PK!b*//Zmatt/window-creation-simple.pynu[PK!;U<"l^matt/subclass-existing-widgets.pyonu[PK!br; ; cmatt/canvas-with-scrollbars.pycnu[PK!;mDD mmatt/canvas-reading-tag-info.pycnu[PK!jHHtmatt/radiobutton-simple.pyonu[PK!gA|matt/00-HELLO-WORLD.pycnu[PK!ll#matt/packer-and-placer-together.pyonu[PK!D66Zmatt/placer-simple.pynu[PK!3(jjՋmatt/window-creation-simple.pycnu[PK!*hh#matt/entry-with-shared-variable.pycnu[PK!X "Imatt/packer-and-placer-together.pynu[PK!*hh#Tmatt/entry-with-shared-variable.pyonu[PK!t44matt/entry-simple.pyonu[PK!ZZmatt/window-creation-more.pycnu[PK!gmatt/00-HELLO-WORLD.pyonu[PK!3--"matt/window-creation-w-location.pynu[PK!P6ematt/slider-demo-1.pynu[PK!Vkk"matt/menu-all-types-of-entries.pyonu[PK!w Omatt/bind-w-mult-calls-p-type.pynu[PK!Fֳ matt/menu-simple.pynu[PK!F77#matt/not-what-you-might-think-2.pycnu[PK!ll#-matt/packer-and-placer-together.pycnu[PK!>;matt/packer-simple.pyonu[PK! yy!matt/bind-w-mult-calls-p-type.pyonu[PK!ʥE"matt/not-what-you-might-think-1.pynu[PK!v matt/rubber-band-box-demo-1.pycnu[PK!!  matt/READMEnu[PK!e̍ matt/canvas-demo-simple.pyonu[PK!a>oQ"matt/animation-w-velocity-ctrl.pycnu[PK! *matt/slider-demo-1.pyonu[PK!Ca33 "matt/packer-simple.pynu[PK!`MY!%matt/subclass-existing-widgets.pynu[PK!|=4>>(matt/canvas-with-scrollbars.pynu[PK!'1matt/canvas-gridding.pynu[PK!v @:matt/rubber-band-box-demo-1.pyonu[PK!;Dmatt/window-creation-more.pynu[PK!Q.Hmatt/killing-window-w-wm.pynu[PK!:Nmatt/animation-simple.pycnu[PK!;mDD ;Umatt/canvas-reading-tag-info.pyonu[PK!\matt/rubber-line-demo-1.pyonu[PK!S"  ematt/placer-simple.pyonu[PK!kNkmatt/dialog-box.pycnu[PK!  Ksmatt/canvas-gridding.pyonu[PK!aI  "|matt/canvas-moving-or-creating.pyonu[PK!0Lmatt/killing-window-w-wm.pycnu[PK! 0matt/slider-demo-1.pycnu[PK!0L&matt/killing-window-w-wm.pyonu[PK!S"  Gmatt/placer-simple.pycnu[PK!;U<"matt/subclass-existing-widgets.pycnu[PK!̆^#matt/not-what-you-might-think-1.pyonu[PK!3(jj%matt/window-creation-simple.pyonu[PK!ްmatt/animation-simple.pyonu[PK!MhΩ ߷matt/canvas-moving-w-mouse.pyonu[PK!nЈ matt/dialog-box.pynu[PK! NNmatt/canvas-moving-w-mouse.pynu[PK!;matt/rubber-line-demo-1.pycnu[PK!e̍gmatt/canvas-demo-simple.pycnu[PK!L  !?matt/printing-coords-of-items.pyonu[PK!br; ; matt/canvas-with-scrollbars.pyonu[PK!>kv v !0matt/canvas-moving-or-creating.pynu[PK!x##!matt/menu-all-types-of-entries.pynu[PK!: $matt/canvas-mult-item-sel.pyonu[PK!F77#!0matt/not-what-you-might-think-2.pyonu[PK!L  !5matt/printing-coords-of-items.pycnu[PK!aI  "@matt/canvas-moving-or-creating.pycnu[PK!d {Jmatt/canvas-w-widget-draw-el.pyonu[PK!uk/Pmatt/animation-simple.pynu[PK!t44Tmatt/entry-simple.pycnu[PK! yy!Ymatt/bind-w-mult-calls-p-type.pycnu[PK!~ǁ"^matt/not-what-you-might-think-2.pynu[PK! 4+bmatt/two-radio-groups.pycnu[PK!PPjmatt/pong-demo-1.pycnu[PK!: smatt/canvas-mult-item-sel.pycnu[PK!PP~matt/pong-demo-1.pyonu[PK!R۩cmatt/menu-simple.pycnu[PK!}` ` Pmatt/printing-coords-of-items.pynu[PK!_ matt/canvas-demo-simple.pynu[PK!>6matt/two-radio-groups.pynu[PK!̆^#,matt/not-what-you-might-think-1.pycnu[PK!d matt/canvas-w-widget-draw-el.pycnu[PK!#~"Ķmatt/entry-with-shared-variable.pynu[PK!Jmatt/radiobutton-simple.pynu[PK!matt/canvas-w-widget-draw-el.pynu[PK!oVVmatt/rubber-band-box-demo-1.pynu[PK!ZZmatt/window-creation-more.pyonu[PK!jHHmatt/radiobutton-simple.pycnu[PK!f 44#2matt/window-creation-w-location.pycnu[PK!(  matt/canvas-mult-item-sel.pynu[PK!Qmatt/rubber-line-demo-1.pynu[PK!R۩matt/menu-simple.pyonu[PK! 4+matt/two-radio-groups.pyonu[PK!#Umatt/entry-simple.pynu[PK!$&$&ttk/ttkcalendar.pycnu[PK![18ttk/mac_searchentry.pynu[PK!|&C]Fttk/combo_themes.pycnu[PK!|&C]Nttk/combo_themes.pyonu[PK!Rh|@@Vttk/listbox_scrollcmd.pyonu[PK!xa##]ttk/roundframe.pyonu[PK!/ QQvttk/combo_themes.pynu[PK!Rh|@@}ttk/listbox_scrollcmd.pycnu[PK!8~ ~ ttk/ttkcalendar.pynu[PK!O^ttk/dirbrowser.pyonu[PK!#gg(ttk/treeview_multicolumn.pyonu[PK!-ttk/listbox_scrollcmd.pynu[PK!>ttk/mac_searchentry.pyonu[PK!y5Lxttk/roundframe.pynu[PK!#ggttk/treeview_multicolumn.pycnu[PK!nnF M ttk/notebook_closebtn.pynu[PK!yTt%t%tttk/plastik_theme.pynu[PK!|!ee,:ttk/img/close_pressed.gifnu[PK!xUee:ttk/img/close.gifnu[PK!.PP;ttk/img/close_active.gifnu[PK!$&$&<ttk/ttkcalendar.pyonu[PK!"P P bttk/widget_state.pyonu[PK! w%> > pttk/theme_selector.pycnu[PK!aO{ttk/theme_selector.pynu[PK!xa##ttk/roundframe.pycnu[PK!^ttk/treeview_multicolumn.pynu[PK!J"_ խttk/notebook_closebtn.pyonu[PK!J"_ ttk/notebook_closebtn.pycnu[PK!"P P ttk/widget_state.pycnu[PK!j:^^;ttk/plastik_theme.pyonu[PK! w%> > ttk/theme_selector.pyonu[PK!>bttk/mac_searchentry.pycnu[PK!O2 ttk/dirbrowser.pycnu[PK!akJ ttk/widget_state.pynu[PK!qP &ttk/dirbrowser.pynu[PK!j:^^1ttk/plastik_theme.pycnu[PK!ԾaOREADMEnu[PK!#4Qguido/imageview.pynu[PK!^CRguido/wish.pycnu[PK!MdUUbUguido/MimeViewer.pycnu[PK!X\hguido/ManPage.pycnu[PK!kK\\Sguido/sortvisu.pyonu[PK!%LPguido/brownian2.pycnu[PK!+$RRguido/optionmenu.pycnu[PK!^ui i "guido/switch.pyonu[PK!-88guido/AttrDialog.pynu[PK!V -guido/rmt.pyonu[PK!,))Aguido/canvasevents.pycnu[PK!)tMIMI&kguido/AttrDialog.pycnu[PK!^guido/wish.pyonu[PK! Cxjjַguido/paint.pynu[PK!X\~guido/ManPage.pyonu[PK!X##guido/tkman.pyonu[PK!27O::guido/imageview.pycnu[PK!YYguido/brownian.pyonu[PK!MdUUguido/MimeViewer.pyonu[PK!.55Gguido/svkill.pycnu[PK!v0guido/canvasevents.pynuȯPK!`xIIJguido/hanoi.pyonu[PK!n`  VZguido/electrons.pynuȯPK!-ɖ55 cguido/mbox.pynuȯPK!LLguido/ShellWindow.pynu[PK!j'guido/imagedraw.pynu[PK!&S}E}Eguido/solitaire.pynuȯPK!"@@guido/kill.pycnu[PK!^ui i (guido/switch.pycnu[PK!1guido/switch.pynu[PK!~H+'guido/ShellWindow.pyonu[PK!DMguido/optionmenu.pynu[PK!kK\\Iguido/sortvisu.pycnu[PK!˗*KKFtguido/hello.pynu[PK!)YzKKuguido/sortvisu.pynuȯPK!hguido/imagedraw.pycnu[PK!Xj|0J|J| hguido/ss1.pyonu[PK!&YB guido/listtree.pycnu[PK!KѴQQ.I guido/solitaire.pycnu[PK!sl~~  guido/ss1.pycnu[PK!m.,,  guido/kill.pynuȯPK!+$RRc) guido/optionmenu.pyonu[PK!X##+ guido/tkman.pycnu[PK! 7E O guido/mbox.pycnu[PK!E`}eR R p guido/electrons.pycnu[PK!E7=z guido/listtree.pynu[PK!.55]~ guido/svkill.pyonu[PK!GfGf ҕ guido/ss1.pynu[PK!k>'U guido/hello.pyonu[PK!o o Q guido/dialog.pycnu[PK!,)) guido/canvasevents.pyonu[PK!qfXX"6 guido/newmenubardemo.pycnu[PK! 7E < guido/mbox.pyonu[PK!|D] guido/paint.pycnu[PK!') guido/hello.pycnu[PK!`&CC% guido/brownian.pynu[PK!Ṁ  guido/dialog.pynuȯPK!hi guido/imagedraw.pyonu[PK!)tMIMI/ guido/AttrDialog.pyonu[PK!.Voo Z guido/wish.pynu[PK!E`}eR R l] guido/electrons.pyonu[PK!qfXXg guido/newmenubardemo.pyonu[PK!V m guido/rmt.pycnu[PK!KѴQQ guido/solitaire.pyonu[PK!aAw guido/newmenubardemo.pynuȯPK!I  guido/rmt.pynuȯPK!27O::U guido/imageview.pyonu[PK!"@@ guido/kill.pyonu[PK!.,#,#P guido/tkman.pynuȯPK!~H+# guido/ShellWindow.pycnu[PK!$͕͕ 9 __init__.pynu[PK!a `A A colorchooser.pynu[PK!_ Y-,-,htix.pynu[PK! jttk.pynu[PK!q __main__.pynu[PK!@@font.pynu[PK!U}} *messagebox.pynu[PK!s88 filedialog.pynu[PK!&--Isimpledialog.pynu[PK!jxx*Fw__pycache__/constants.cpython-38.opt-1.pycnu[PK!00%~__pycache__/filedialog.cpython-38.pycnu[PK!z`,,$~__pycache__/dnd.cpython-38.opt-1.pycnu[PK!s-__pycache__/scrolledtext.cpython-38.opt-1.pycnu[PK!ҧ'__pycache__/dialog.cpython-38.opt-2.pycnu[PK!D@**'__pycache__/simpledialog.cpython-38.pycnu[PK!(1616__pycache__/tix.cpython-38.pycnu[PK! II$K__pycache__/tix.cpython-38.opt-2.pycnu[PK!寉CC-6/__pycache__/colorchooser.cpython-38.opt-2.pycnu[PK!xx$3__pycache__/constants.cpython-38.pycnu[PK!VFi%:__pycache__/font.cpython-38.opt-2.pycnu[PK!ҧ!N__pycache__/dialog.cpython-38.pycnu[PK!b pnn$U__pycache__/ttk.cpython-38.opt-2.pycnu[PK!x2$2$-__pycache__/simpledialog.cpython-38.opt-2.pycnu[PK!<,22#__pycache__/__main__.cpython-38.pycnu[PK!(1616$__pycache__/tix.cpython-38.opt-1.pycnu[PK!z`,, __pycache__/dnd.cpython-38.pycnu[PK!D@**-gL__pycache__/simpledialog.cpython-38.opt-1.pycnu[PK!zYVV-w__pycache__/scrolledtext.cpython-38.opt-2.pycnu[PK!\yd33)o~__pycache__/__init__.cpython-38.opt-1.pycnu[PK!00+.__pycache__/filedialog.cpython-38.opt-1.pycnu[PK!`Nxx)g___pycache__/__init__.cpython-38.opt-2.pycnu[PK!wbh^$8__pycache__/dnd.cpython-38.opt-2.pycnu[PK!#N-2__pycache__/colorchooser.cpython-38.opt-1.pycnu[PK!jxx*]__pycache__/constants.cpython-38.opt-2.pycnu[PK![_S S +/__pycache__/messagebox.cpython-38.opt-2.pycnu[PK!1& +)__pycache__/messagebox.cpython-38.opt-1.pycnu[PK! MС%5__pycache__/font.cpython-38.opt-1.pycnu[PK!ҧ'N__pycache__/dialog.cpython-38.opt-1.pycnu[PK!vZZ-T__pycache__/commondialog.cpython-38.opt-2.pycnu[PK!vZZ'Y__pycache__/commondialog.cpython-38.pycnu[PK!1& %`^__pycache__/messagebox.cpython-38.pycnu[PK!T—||$fj__pycache__/ttk.cpython-38.opt-1.pycnu[PK!i((+6H__pycache__/filedialog.cpython-38.opt-2.pycnu[PK!vZZ-q__pycache__/commondialog.cpython-38.opt-1.pycnu[PK!T—||:v__pycache__/ttk.cpython-38.pycnu[PK! MСT__pycache__/font.cpython-38.pycnu[PK!s'l__pycache__/scrolledtext.cpython-38.pycnu[PK!#N'u__pycache__/colorchooser.cpython-38.pycnu[PK!<,22)~__pycache__/__main__.cpython-38.opt-1.pycnu[PK!F9QQ#~__pycache__/__init__.cpython-38.pycnu[PK!OU)"1!__pycache__/__main__.cpython-38.opt-2.pycnu[PK!p2!commondialog.pynu[PK!Ss-,,7!dnd.pynu[PK!c d!constants.pynu[PK!j!scrolledtext.pynu[PK!6; r!dialog.pynu[PK`/x!