def __init__(self, guiParent, basePopup): # Base popup required to handle notification of data model changes # e.g. new peak lists, so that the GUI can update to the latest # state self.basePopup = basePopup self.guiParent = guiParent self.registerNotify = basePopup.registerNotify self.unregisterNotify = basePopup.unregisterNotify Frame.__init__(self, guiParent) # set up the grid self.grid_columnconfigure(0, weight=1, minsize=10) self.grid_columnconfigure(1, weight=0, minsize=10) self.grid_columnconfigure(2, weight=0, minsize=20) self.grid_columnconfigure(3, weight=1, minsize=10) self.grid_rowconfigure(0, weight=1, minsize=5) self.grid_rowconfigure(1, weight=0, minsize=10) self.grid_rowconfigure(2, weight=0, minsize=10) self.grid_rowconfigure(3, weight=0, minsize=10) self.grid_rowconfigure(4, weight=0, minsize=10) self.grid_rowconfigure(5, weight=0, minsize=10) self.grid_rowconfigure(6, weight=1, minsize=5) # build up the body. # Column headers self.name_label = Label(self, text='Repository Name:') self.name_label.grid(row=1, column=1, padx=5, pady=5, sticky='w') self.name_value = Text(self, width=20, height=1, text="") self.name_value.grid(row=1, column=2, padx=5, pady=5, sticky='w') self.rep_label = Label(self, text='Repository Url:') self.rep_label.grid(row=2, column=1, padx=5, pady=5, sticky='w') self.rep_value = Text(self, width=20, height=1, text="") self.rep_value.grid(row=2, column=2, padx=5, pady=5, sticky='w') self.user_label = Label(self, text='Username:'******'w') self.user_value = Text(self, width=20, height=1, text="") self.user_value.grid(row=3, column=2, padx=5, pady=5, sticky='w') self.pswd_label = Label(self, text='Password:'******'w') self.pswd_value = Text(self, width=20, height=1, text="") self.pswd_value.grid(row=4, column=2, padx=5, pady=5, sticky='w') self.cancel_button = Button(self, width=10, height=1, text="Cancel", command=self.quit) self.cancel_button.grid(row=5, column=1, padx=5, pady=5, sticky='e') self.login_botton = Button(self, width=10, height=1, text="Connect", command=self.connectRepository) self.login_botton.grid(row=5, column=2, padx=5, pady=5, sticky='w')
def __init__( self, parent, # arguments below are Tkinter.Scrollbar options orient=Tkinter.HORIZONTAL, width=15, borderwidth=1, background=None, troughcolor=None, repeatdelay=300, # msecs before repeat action on arrows and troughs repeatinterval=100, # msecs between repeat action on arrows and troughs # arguments below are not Tkinter.Scrollbar options # callback is approximately same as Tkinter.Scrollbar command # option but has different (more convenient) arguments allow_resize=False, callback=None, relief='sunken', show_text=False, text_color='#000000', text_func=None, units_scroll=0.1, pages_scroll=1.0, min_thickness=None, *args, **kw): assert orient in (Tkinter.HORIZONTAL, Tkinter.VERTICAL) if (show_text): assert text_func is not None self.relief = relief self.orient = orient self.callback = callback self.borderwidth = borderwidth self.repeatdelay = repeatdelay self.repeatinterval = repeatinterval self.show_text = show_text self.text_func = text_func self.units_scroll = units_scroll self.pages_scroll = pages_scroll self.min_thickness = min_thickness self.mode = 0 self.lo = 0.0 self.hi = 1.0 self.first_pass = True self.haveShift = False Frame.__init__(self, parent, *args, **kw) if (background is None): bg = parent.cget('bg') else: bg = background if (troughcolor is None): bg_trough = scaleColor(self, bg, 0.9) else: bg_trough = troughcolor # below are for shadows if relief == 'sunken': color1 = scaleColor(self, bg_trough, 0.7) color2 = scaleColor(self, bg_trough, 1.2) color3 = scaleColor(self, bg, 1.2) color4 = scaleColor(self, bg, 0.7) elif relief == 'raised': color1 = scaleColor(self, bg_trough, 1.2) color2 = scaleColor(self, bg_trough, 0.7) color3 = scaleColor(self, bg, 0.7) color4 = scaleColor(self, bg, 1.2) else: color1 = color2 = scaleColor(self, bg_trough, 0.7) color3 = color4 = scaleColor(self, bg, 1.2) self.brColor = color4 self.tlColor = color3 defaultSize = 10 # gets overriden by other widgets in container # but need to do something otherwise canvas asks for too much space kw2 = {} if (orient == Tkinter.HORIZONTAL): kw2['width'] = defaultSize kw2['height'] = width else: kw2['width'] = width kw2['height'] = defaultSize self.canvas = c = Canvas(self, bg=bg, **kw2) # grid does not seem to work because once canvas size specified # in any way it never seems to be resized c.pack(side=Tkinter.TOP, expand=Tkinter.YES, fill=Tkinter.BOTH) self.tlOuter = c.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill=color1, outline='') self.brOuter = c.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill=color2, outline='') self.bgOuter = c.create_rectangle(0, 0, 0, 0, fill=bg_trough, outline='') # self.arrowXTl,Br are for shadows of the arrows # self.arrowXFill is for triangle infill # arrow and rectangle boundaries which are colored the # same as (and so in some sense are part of) the trough # the main part of the arrow does not need its own polygon # because it is the same color as the main rectangle self.arrow1Tl = c.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill=color3, outline='') self.arrow1Br = c.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill=color4, outline='') self.arrow1Fill = c.create_polygon(0, 0, 0, 0, 0, 0, fill=bg, outline='') self.arrow2Tl = c.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill=color3, outline='') self.arrow2Br = c.create_polygon(0, 0, 0, 0, 0, 0, 0, 0, fill=color4, outline='') self.arrow2Fill = c.create_polygon(0, 0, 0, 0, 0, 0, fill=bg, outline='') # slider is the bit you grab in the middle # created with two triangles for the shadowsed border # with rectangle panel in middle self.tlSlider = c.create_polygon(0, 0, 0, 0, 0, 0, fill=color3, outline='') self.brSlider = c.create_polygon(0, 0, 0, 0, 0, 0, fill=color4, outline='') self.bgSlider = c.create_rectangle(0, 0, 0, 0, fill=bg, outline='') if (show_text): self.text0 = c.create_text(0, 0, fill=text_color) self.text1 = c.create_text(0, 0, fill=text_color) if (orient == Tkinter.HORIZONTAL): c.itemconfig(self.text0, anchor=Tkinter.W) c.itemconfig(self.text1, anchor=Tkinter.E) else: c.itemconfig(self.text0, anchor=Tkinter.S) c.itemconfig(self.text1, anchor=Tkinter.N) c.bind('<Configure>', self.configure) c.bind('<Button-1>', self.buttonPressMove) c.bind('<B1-Motion>', self.buttonMotionMove) c.bind('<ButtonRelease-1>', self.buttonReleaseMove) if (allow_resize): c.bind('<Button-2>', self.buttonPressResize) c.bind('<B2-Motion>', self.resize)
def __init__(self, parent, callback, speed=1.5, delay=50, fill='grey73', outline='grey90', hilight='grey90', width=144, height=24, docKey=None, tipText=None, *args, **kw): self.callback = callback self.speed = speed self.delay = delay self.fill = fill self.outline = outline self.hilight = hilight Frame.__init__(self, parent=parent, docKey=docKey, tipText=tipText, createToolTip=True, *args, **kw) # if canvas width/height fixed then resizing has no effect, it seems #self.grid_rowconfigure(0, weight=1) #self.grid_columnconfigure(0, weight=1) font = '-schumacher-clean-bold-r-normal--14-140-75-75-c-70-iso646.1991-irv' self.canvas = c = Canvas(self, width=width, height=height, relief='flat', borderwidth=0) c.bind('<Configure>', self.resize) c.bind('<ButtonPress>', self.press) c.bind('<Motion>', self.motion) c.bind('<Enter>', self.mouseEnter) c.bind('<Leave>', self.mouseLeave) c.bind('<ButtonRelease>', self.release) self.bg = c.create_rectangle(1, 1, 1, 1, fill='red', outline='grey50') self.boxes0 = [] self.boxes1 = [] self.boxes2 = [] self.strikes = [] self.dashes = [] for n in range(24): box1 = c.create_rectangle(0, 0, 0, 0, fill=outline, outline=outline) box2 = c.create_rectangle(0, 0, 0, 0, fill=outline, outline=outline) box0 = c.create_rectangle(0, 0, 0, 0, fill=outline, outline=outline) self.boxes0.append(box0) self.boxes1.append(box1) self.boxes2.append(box2) for n in range(8): dash = c.create_line(0, 0, 0, 0, fill='black') self.dashes.append(dash) for n in range(4): strike = c.create_line(0, 0, 0, 0, fill='black') self.strikes.append(strike) c.grid(row=0, column=0, sticky=Tkinter.NSEW) self.continue_callback = False self.multiplier = 1.0
def __init__(self, parent, iconSize='medium', multiSelect=False, font='Helvetica 8', doubleCallback=None, *args, **kw): Frame.__init__(self, parent, *args, **kw) self.multiSelect = multiSelect self.icons = {} self.openDict = {} self.scrollbarWidth = 15 self.canvasList = [] self.canvasDict = {} self.canvasLines = [] self._wait = False self.vOffset = 0 self.nodes = [] # Just a list of nodes self.nodeDict = {} # To fetch nodes via objects self.font = font self.doubleCallback = doubleCallback #bg = self.cget('background') iconItems = [{ 'kind': 'command', 'label': 'Small', 'command': self.smallIcons }, { 'kind': 'command', 'label': 'Medium', 'command': self.medIcons }, { 'kind': 'command', 'label': 'Large', 'command': self.largeIcons }] self.menu = Menu(self, tearoff=False) menu_items = [ { 'kind': 'cascade', 'label': 'Icon size', 'submenu': iconItems }, ] self.menu.setMenuItems(menu_items) self.rowHeight = None self.visibleRows = 80 self.setIconSize(iconSize, redraw=False) self.canvas = Canvas(self, relief='flat', borderwidth=0, background=BG_COLOR, xscrollcommand=self._setHScrollbar) self.canvas.pack() self.xScrollbar = Scrollbar(self, orient='horizontal', width=self.scrollbarWidth, borderwidth=1, callback=self._moveHScrollbar, background=BG_COLOR) self.yScrollbar = Scrollbar(self, orient='vertical', width=self.scrollbarWidth, borderwidth=1, callback=self._setVScrollbar, background=BG_COLOR) self.canvas.bind('<Button-1>', self._mouseClick) self.canvas.bind('<Double-1>', self._mouseDoubleClick) if isWindowsOS: self.canvas.bind('<MouseWheel>', self._windowsOsScroll) else: self.canvas.bind('<Button-4>', self._mouseUp) self.canvas.bind('<Button-5>', self._mouseDown) self.canvas.bind('<p>', self._printCanvas) self.canvas.bind('<KeyPress-Prior>', self._pageUp) self.canvas.bind('<KeyPress-Next>', self._pageDown) self.canvas.bind('<KeyPress-Up>', self._keyUp) self.canvas.bind('<KeyPress-Down>', self._keyDown) self.canvas.bind('<KeyPress-Home>', self._keyHome) self.canvas.bind('<KeyPress-End>', self._keyEnd) self.canvas.bind('<Enter>', self._enter) self.canvas.bind('<ButtonPress-3>', self._popupMenu) self.bind('<Configure>', self._changeSizeAfter)