def MkSWindow(w): global demo top = Tix.Frame(w, width=330, height=330) bot = Tix.Frame(w) msg = Tix.Message(top, font='-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*', relief=Tix.FLAT, width=200, anchor=Tix.N, text='The TixScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.') win = Tix.ScrolledWindow(top, scrollbar='auto') image = Tix.Image('photo', file=demo.dir + "/bitmaps/tix.gif") lbl = Tix.Label(win.window, image=image) lbl.pack(expand=1, fill=Tix.BOTH) win.place(x=30, y=150, width=190, height=120) rh = Tix.ResizeHandle(top, bg='black', relief=Tix.RAISED, handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w,x)) top.propagate(0) msg.pack(fill=Tix.X) btn.pack(anchor=Tix.CENTER) top.pack(expand=1, fill=Tix.BOTH) bot.pack(fill=Tix.BOTH) win.bind('<Map>', func=lambda arg=0, rh=rh, win=win: win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
def MkSWindow(w): """The ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget. """ global demo text = 'The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.' file = os.path.join(demo.dir, 'bitmaps', 'tix.gif') if not os.path.isfile(file): text += ' (Image missing)' top = Tix.Frame(w, width=330, height=330) bot = Tix.Frame(w) msg = Tix.Message(top, relief=Tix.FLAT, width=200, anchor=Tix.N, text=text) win = Tix.ScrolledWindow(top, scrollbar='auto') if 0: global image1 # This image is not showing up in the Label unless it is set to a # global variable - no problem under Tcl/Tix. I assume it is being # garbage collected somehow, even though the Tcl command 'image names' # shows that as far as Tcl is concerned, the image exists and is # called pyimage1. What I find curious is that this if 0: branch # works only if image1 is global, *even though I give Label a string*. image1 = Tix.Image('photo', file=file) else: # No need for image1 to be global if I do it in pure Tcl. # When I do it in pure Tcl the image shows up in the Label. # The tcl command 'image names' shows as far as Tcl is concerned, # the image exists and is called image1. So I assume the problem # lies Tkinter.py Image.__init__, where the image gets the name # pyimage1, instead of what Tcl would have called it - image1. image1 = win.tk.eval('image create photo -file {%s}' % file) lbl = Tix.Label(win.window, image='%s' % image1) lbl.pack(expand=1, fill=Tix.BOTH) win.place(x=30, y=150, width=190, height=120) rh = Tix.ResizeHandle(top, bg='black', relief=Tix.RAISED, handlesize=8, gridded=1, minwidth=50, minheight=30) btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w, x)) top.propagate(0) msg.pack(fill=Tix.X) btn.pack(anchor=Tix.CENTER) top.pack(expand=1, fill=Tix.BOTH) bot.pack(fill=Tix.BOTH) win.bind('<Map>', func=lambda arg=0, rh=rh, win=win: win.tk.call( 'tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
def RunSample(w): w.img0 = Tix.Image('pixmap', data=network_pixmap) if not w.img0: w.img0 = Tix.Image('bitmap', data=network_bitmap) w.img1 = Tix.Image('pixmap', data=hard_disk_pixmap) if not w.img0: w.img1 = Tix.Image('bitmap', data=hard_disk_bitmap) hdd = Tix.Button(w, padx=4, pady=1, width=120) net = Tix.Button(w, padx=4, pady=1, width=120) # Create the first image: we create a line, then put a string, # a space and a image into this line, from left to right. # The result: we have a one-line image that consists of three # individual items # # The tk.calls should be methods in Tix ... w.hdd_img = Tix.Image('compound', window=hdd) w.hdd_img.tk.call(str(w.hdd_img), 'add', 'line') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'text', '-text', 'Hard Disk', '-underline', '0') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'space', '-width', '7') w.hdd_img.tk.call(str(w.hdd_img), 'add', 'image', '-image', w.img1) # Put this image into the first button # hdd['image'] = w.hdd_img # Next button w.net_img = Tix.Image('compound', window=net) w.net_img.tk.call(str(w.net_img), 'add', 'line') w.net_img.tk.call(str(w.net_img), 'add', 'text', '-text', 'Network', '-underline', '0') w.net_img.tk.call(str(w.net_img), 'add', 'space', '-width', '7') w.net_img.tk.call(str(w.net_img), 'add', 'image', '-image', w.img0) # Put this image into the first button # net['image'] = w.net_img close = Tix.Button(w, pady=1, text='Close', command=lambda w=w: w.destroy()) hdd.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1) net.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1) close.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1)
#!/usr/local/bin/python
def __init__(self, master=None, options={}): Tix.Frame.__init__(self, master) self.options = options self.hand_cursor = Tix.Image("pixmap", data=images_data["hand"]) master.option_add("*relief", "flat") master.option_add("*Menu*tearOff", "0") master.option_add("*Coolbar*relief", "groove") master.option_add("*Toolbar*relief", "flat") master.option_add("*Toolbar*Button.relief", "flat") master.option_add("*Toolbar*Button.overRelief", "groove") master.option_add("*Toolbar*Button.width", "8") master.option_add("*Toolbar*Menubutton.relief", "groove") master.option_add("*Entry.relief", "ridge") master.option_add("*Entry.highlightThickness", "0") master.option_add("*Menu*tearOff", "0") master.option_add("*Menubutton.relief", "groove") opt = options["style"].get("font", "TkFixedFont") master.option_add("*Text.font", opt) master.option_add("*TixHList.font", opt) opt = options["style"].get("background", "white") master.option_add("*Text.background", opt) master.option_add("*TixHList.background", opt) opt = options["style"].get("foreground", "black") master.option_add("*Text.foreground", opt) master.option_add("*TixHList.foreground", opt) opt = options["style"]["select"]["background"] master.option_add("*Text.selectBackground", opt) opt = options["style"]["select"]["foreground"] master.option_add("*Text.selectForeground", opt) opt = options["style"]["insert"]["background"] master.option_add("*Text.insertBackground", opt) master.option_add("*PanedWindow.showHandle", "False") master.option_add("*Panedwindow.sashWidth", "2") master.option_add("*Panedwindow.sashRelief", "groove") self.indent_width = options["style"].get("indent-width", 2) # 配置主窗口属性 master.rowconfigure(0, weight=1) master.columnconfigure(0, weight=1) self.rowconfigure(0) self.rowconfigure(1, weight=1) self.rowconfigure(2) self.columnconfigure(0, weight=1) self.symbol_list = [pascal.kwlist] x = filter(lambda k : k[0] != "_", dir(pascal)) x.remove("kwlist") self.symbol_list.append(x) self.symbol_list.append([]) # 创建子控件 self.__create_widgets() self.__configure_widgets() self.datapool = datapool.DataPool(self, filename="datapool.data") # 绑定窗口退出事件 master.protocol( 'WM_DELETE_WINDOW', lambda : self.__action_quit() ) # 设定属性 self.__set_status("none") self.__filename = None self.__builder = self.options.get("builder") self.__player = self.options.get("player")
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-