def create_feedback_ui(self): feedback_frame = ttk.Frame(self) feedback_frame.grid(row=2, column=1, stick='W', padx=20) ttk.Label(feedback_frame, text='Input').grid(row=1, column=1) scale_input = ttk.Scale(feedback_frame, from_=-1, to=1) scale_input.grid(row=2, column=1, padx=5) ttk.Label(feedback_frame, text='Output').grid(row=1, column=2) ttk.Scale(feedback_frame, from_=-1, to=1).grid(row=2, column=2, padx=5) return
def __init__(self, path, master=None): ttk.Frame.__init__(self, master) self.cv_user = CvUser(path) self.__init_tk_vars() self.master.title(path) self.saving_filename = None scaleInitArgs = { 'from_': self.cv_user.arg_min_value, 'to': self.cv_user.arg_max_value, 'orient': ttk.Tkinter.VERTICAL } scale1 = ttk.Scale(self, variable=self.canny1, command=self.__updating_parameters_cb, **scaleInitArgs) scale2 = ttk.Scale(self, variable=self.canny2, command=self.__updating_parameters_cb, **scaleInitArgs) self.scale1 = scale1 self.scale2 = scale2 view_port = ViewPort( self, self.cv_user.apply_parameters(self.canny1.get(), self.canny2.get())) self.view_port = view_port self.canvas = view_port.canvas self.__bottom_frame = ttk.Frame(self) lab = ttk.Label(self.__bottom_frame, text="Everything is OK", justify=tk.LEFT) self.label = lab self.__rb_frame = ttk.Frame(self.__bottom_frame) modes = (("Normal", 0), ("Stretched", 1), ("Proportional", 2)) l = list() for text, v in modes: b = ttk.Radiobutton(self.__rb_frame, text=text, variable=self.view_port.zoom_mode_var, value=v, command=self.__update_rb_ui) l.append(b) self.__rb_list = l self.__arrange_widgets() self.__bind_events() # self.__update_statusLab() self.focus_set()
def SetupLabelCombo(self, parent, textname, rownum, colnum, minto, maxto, callback, cameraVal, label=''): l = Label(parent, text=textname) l.grid(row=rownum, column=colnum * 3, sticky='E', pady=2) #,padx=2) label = Label(parent, width=4, anchor=E) #,relief=SUNKEN, background='#f0f0ff') label.grid(row=rownum, column=colnum * 3 + 1) #label.config(font=('Helvetica',12)) # create the scale WITHOUT a callback. Then set the scale. scale = ttk.Scale(parent, from_=minto, to=maxto, orient='horizontal') scale.grid(row=rownum, column=colnum * 3 + 2, sticky='W', padx=5, pady=3) val = cameraVal scale.set(val) # this would attempt to call any callback scale.config(command=callback) # now supply the callback return label, scale, val
def __init__(self, master, r, name): self.master = master ttk.LabelFrame.__init__(self, self.master, text=name, labelanchor=N) self.scaleVal = DoubleVar() self.scaleText = StringVar() self.r = StringVar() self.rVal = IntVar() self.rVal.set(r) self.r.set(str(self.rVal.get())) self.scaleText.set("0") self.slide = ttk.Scale(self, from_=self.rVal.get(), to=0, orient=VERTICAL, variable=self.scaleVal, command=self.set) self.slide.grid(row=0, column=0) self.e = ttk.Entry(self, textvariable=self.scaleText, width=4) self.e.grid(row=1, column=0) self.e.bind("<Return>", self.setScale) self.setScale("a") self.c = ttk.Entry(self, textvariable=self.r, width=4) self.c.grid(row=2) self.c.bind("<Return>", self.setRange)
def BuildPage(self): self.iconMonitor = ImageTk.PhotoImage( \ PIL.Image.open("Assets/computer-monitor.png").resize((64,64),Image.ANTIALIAS)) Label(self, image=self.iconMonitor).grid(row=0, column=0, sticky='W') f = MyLabelFrame(self, 'Interface themes', 0, 1) f.columnconfigure(1, weight=1) Label(f, text='Set theme').grid(row=0, column=0, sticky='W', pady=(5, 5)) self.themes = Combobox(f, height=10, state='readonly') self.themes.grid(row=0, column=1, sticky='W', padx=(10, 0)) self.themes['values'] = Style().theme_names() self.themes.set(Style().theme_use()) self.themes.bind('<<ComboboxSelected>>', self.ThemesSelected) ToolTip(self.themes, 6100) f = MyLabelFrame(self, 'Tooltips', 1, 0, span=2) self.ShowTooltips = MyBooleanVar(ToolTip.ShowToolTips) self.ShowTipsButton = ttk.Checkbutton( f, text='Show those annoying tooltips', variable=self.ShowTooltips, command=self.ShowTooltipsChecked) #,padding=(5,5,5,5)) self.ShowTipsButton.grid(row=1, column=0, columnspan=2, sticky='W') ToolTip(self.ShowTipsButton, 6110) self.ShowTipNumber = MyBooleanVar(ToolTip.ShowTipNumber) self.ShowTipNumButton = ttk.Checkbutton( f, text='Show tip number in tip (debug)', variable=self.ShowTipNumber, command=self.ShowTooltipNumChecked, padding=(25, 5, 5, 5)) self.ShowTipNumButton.grid(row=2, column=0, columnspan=2, sticky='W') ToolTip(self.ShowTipNumButton, 6111) ttk.Label(f, text='Delay before tip', padding=(25, 0, 0, 0)).grid(row=3, column=0, sticky='W') scale = ttk.Scale(f, value=ToolTip.ShowTipDelay, from_=0.1, to=5.0, orient='horizontal', command=self.TipDelayChanged) scale.grid(row=3, column=1, sticky='W') ToolTip(scale, 6112) self.DelayText = MyStringVar("") l = Label(f, textvariable=self.DelayText, foreground='#0000FF') l.grid(row=3, column=2, sticky='W') ToolTip(l, 6113) self.TipDelayChanged(ToolTip.ShowTipDelay) # Force display update
def __init__(self, parent, **kw): if 'resolution' in kw: self.resolution = kw['resolution'] del kw['resolution'] else: self.resolution = 1 if 'from_' in kw: kw['from_'] = kw['from_'] / self.resolution if 'to' in kw: kw['to'] = kw['to'] / self.resolution if 'variable' in kw: self.variable = kw['variable'] del kw['variable'] else: self.variable = None value = None if 'value' in kw: value = kw['value'] del kw['value'] elif self.variable: value = self.variable.get() self.value = value self.command = command = None if 'command' in kw: command = kw['command'] kw['command'] = self._scale_command if 'label' in kw: self.label_text = kw['label'] width = len(self.label_text) + 4 # width = None del kw['label'] else: self.label_text = None width = 3 # create widgets side = 'left' # 'top' self.frame = ttk.Frame(parent) self.label = ttk.Label(self.frame, anchor='w', width=width, padding=(5, 0)) self.label.pack(side=side, expand=False, fill='x') self.scale = ttk.Scale(self.frame, **kw) self.scale.pack(side=side, expand=True, fill='both', pady=4) if self.variable: self.variable.trace('w', self._trace_var) if value is not None: self._set_text(self._round(value)) if self.variable: self.variable.set(value) self.command = command
def setGUI(self, options): ttk.Label(self, text=options.get('label'), width=20, anchor=tk.NW).pack(side=tk.LEFT) if options.get('id'): self.id = options.get('id').lower() self.default = options.get('default', '') self.setValue(self.default) valRange = map(int, options.get('range').split(',')) scale = ttk.Scale(self, variable=self.value, #showvalue=0, from_=valRange[0], to=valRange[-1]) #orient=tk.HORIZONTAL scale.pack(side=tk.RIGHT, fill=tk.X, expand=1) if len(valRange) == 3: scale.configure(resolution=valRange[1]) ttk.Entry(self, textvariable=self.value).pack(side=tk.RIGHT, fill=tk.X)
def makeAudioFrame(parent): audioFrame = LabelFrame(parent, text="Audio", pady=5, padx=5, bg="white", bd=1, relief=SUNKEN) whiteLabel(audioFrame, "Mic").grid(column=1, row=1, sticky=W, padx=5) whiteLabel(audioFrame, "Speaker").grid(column=1, row=2, sticky=W, padx=5) ttk.Scale(audioFrame, from_=0, to=100, orient=HORIZONTAL, variable=micVol, command=lambda x: cb(micVol)).grid(column=2, row=1, sticky=W) ttk.Scale(audioFrame, from_=0, to=100, orient=HORIZONTAL, variable=spVol, command=lambda x: cb(spVol)).grid(column=2, row=2, sticky=W) return audioFrame
def _scale(self, from_, to, resolution, variable, position, command = None, kwargs = {}): if command is None: command = lambda s: variable.set(round(float(s), 3)) scale = ttk.Scale(self.frame1.sliders, from_ = from_, to = to, variable = variable, orient = "horizontal", length = 20, command = command, takefocus = False, **kwargs) if position == 1: scale.place(relwidth = 0.35, relx = 0, x = 0, y = 25, anchor = "nw") elif position == 2: scale.place(relwidth = 0.35, relx = 0, x = 0, y = 70, anchor = "nw") elif position == 3: scale.place(relwidth = 0.35, relx = 0.5, x = 0, y = 25, anchor = "nw") elif position == 4: scale.place(relwidth = 0.35, relx = 0.5, x = 0, y = 70, anchor = "nw") return scale
def create_control_panel(self): frame = Tkinter.LabelFrame(self.root) frame.pack(expand='yes', fill='x', side='top') add_fileicon = Tkinter.PhotoImage(file="../Icons/add_file.gif") add_directoryicon = Tkinter.PhotoImage( file="../Icons/add_directory.gif") exiticon = Tkinter.PhotoImage(file="../Icons/exit.gif") playicon = Tkinter.PhotoImage(file="../Icons/play.gif") pauseicon = Tkinter.PhotoImage(file="../Icons/pause.gif") stopicon = Tkinter.PhotoImage(file="../Icons/stop.gif") rewindicon = Tkinter.PhotoImage(file="../Icons/rewind.gif") fast_forwardicon = Tkinter.PhotoImage(file="../Icons/fast_forward.gif") previous_trackicon = Tkinter.PhotoImage( file="../Icons/previous_track.gif") next_trackicon = Tkinter.PhotoImage(file="../Icons/next_track.gif") self.muteicon = Tkinter.PhotoImage(file="../Icons/mute.gif") self.unmuteicon = Tkinter.PhotoImage(file="../Icons/unmute.gif") delete_selectedicon = Tkinter.PhotoImage( file="../Icons/delete_selected.gif") list_file = [ (playicon, 'self.play'), (pauseicon, 'self.pause'), (stopicon, 'self.stop'), (previous_trackicon, 'self.previous'), (rewindicon, 'self.rewind'), (fast_forwardicon, 'self.fast'), (next_trackicon, 'self.Next'), ] for i, j in list_file: storeobj = ttk.Button(frame, image=i, command=eval(j)) storeobj.pack(side='left') storeobj.image = i self.volume_label = Tkinter.Button(frame, image=self.unmuteicon) self.volume_label.image = self.unmuteicon volume = ttk.Scale(frame, from_=Volume_lowest_value, to=Volume_highest_value, variable=self.var, command=self.update_volume) volume.pack( side='right', padx=10, ) self.volume_label.pack(side='right') return
def create_button_frame(self): buttonframe = Frame(self.root) previcon = PhotoImage(file='../icons/previous.gif') prevbtn=Button(buttonframe, image=previcon, borderwidth=0, padx=0, command=self.prev_track) prevbtn.image = previcon prevbtn.grid(row=3, column=1, sticky='w') rewindicon = PhotoImage(file='../icons/rewind.gif') rewindbtn=Button(buttonframe, image=rewindicon, borderwidth=0, padx=0, command=self.player.rewind) rewindbtn.image = rewindicon rewindbtn.grid(row=3, column=2, sticky='w') self.playicon = PhotoImage(file='../icons/play.gif') self.stopicon = PhotoImage(file='../icons/stop.gif') self.playbtn=Button(buttonframe, text ='play', image=self.playicon, borderwidth=0, padx=0, command=self.toggle_play_pause) self.playbtn.image = self.playicon self.playbtn.grid(row=3, column=3) fast_fwdicon = PhotoImage(file='../icons/fast_fwd.gif') fast_fwdbtn=Button(buttonframe, image=fast_fwdicon, borderwidth=0, padx=0, command=self.player.fast_fwd) fast_fwdbtn.image = fast_fwdicon fast_fwdbtn.grid(row=3, column=4) nexticon = PhotoImage(file='../icons/next.gif') nextbtn=Button(buttonframe, image=nexticon,borderwidth=0,padx=0, command=self.next_track) nextbtn.image = nexticon nextbtn.grid(row=3, column=5) self.muteicon = PhotoImage(file='../icons/mute.gif') self.unmuteicon = PhotoImage(file='../icons/unmute.gif') self.mutebtn=Button(buttonframe, image=self.unmuteicon, text='unmute', borderwidth=0,padx=0, command=self.toggle_mute) self.mutebtn.image = self.unmuteicon self.mutebtn.grid(row=3, column=6) self.volscale = ttk.Scale(buttonframe, from_=0.0, to =1.0 , command=self.vol_update) self.volscale.set(0.6) self.volscale.grid(row=3, column=7 , padx=5) buttonframe.grid(row=3, columnspan=5, sticky='w', pady=4, padx=5)
def create_button_frame(self): buttonframe = Frame(self.root) #****************** Previous button ******************************** previcon = PhotoImage(file='icons/previous.gif') prevbtn=Button(buttonframe, image=previcon, borderwidth=0, padx=0, command=self.prev_track) prevbtn.image = previcon prevbtn.grid(row=3, column=1, sticky='w') self.balloon.bind(prevbtn, 'Previous Song') #******************** Rewind button ******************************** rewindicon = PhotoImage(file='icons/rewind.gif') rewindbtn=Button(buttonframe, image=rewindicon, borderwidth=0, padx=0, command=self.player.rewind) rewindbtn.image = rewindicon rewindbtn.grid(row=3, column=2, sticky='w') self.balloon.bind(rewindbtn, 'Go Back') #****************** Play/Pause button ****************************** self.playicon = PhotoImage(file='icons/play.gif') self.stopicon = PhotoImage(file='icons/stop.gif') self.playbtn=Button(buttonframe, text ='play', image=self.playicon, borderwidth=0, padx=0, command=self.toggle_play_pause) self.playbtn.image = self.playicon self.playbtn.grid(row=3, column=3) self.balloon.bind(self.playbtn, 'Play Song') #****************** fast forward button ***************************** fast_fwdicon = PhotoImage(file='icons/fast_fwd.gif') fast_fwdbtn=Button(buttonframe, image=fast_fwdicon, borderwidth=0, padx=0, command=self.player.fast_fwd) fast_fwdbtn.image = fast_fwdicon fast_fwdbtn.grid(row=3, column=4) self.balloon.bind(fast_fwdbtn, 'Fast Forward') #****************** Next button ************************************* nexticon = PhotoImage(file='icons/next.gif') nextbtn=Button(buttonframe, image=nexticon,borderwidth=0,padx=0, command=self.next_track) nextbtn.image = nexticon nextbtn.grid(row=3, column=5) self.balloon.bind(nextbtn, 'Next Song') #****************** Mute/Unmute button ******************************* self.muteicon = PhotoImage(file='icons/mute.gif') self.unmuteicon = PhotoImage(file='icons/unmute.gif') self.mutebtn=Button(buttonframe, image=self.unmuteicon, text='unmute', borderwidth=0,padx=0, command=self.toggle_mute) self.mutebtn.image = self.unmuteicon self.mutebtn.grid(row=3, column=6) self.balloon.bind(self.mutebtn, 'Mute/Unmute') #****************** Volume Scale button ******************************* self.volscale = ttk.Scale(buttonframe, from_=0.0, to =1.0 , command=self.vol_update) self.volscale.set(0.6) self.volscale.grid(row=3, column=7 , padx=5) buttonframe.grid(row=3, columnspan=5, sticky='w', pady=4, padx=5)#BUTTON FRAME POSITION
def Scale(*args, **kwargs): if ttk is None: val = -1 if 'padx' in kwargs: val = kwargs['value'] kwargs.pop('value', None) s = TK.Scale(*args, **kwargs) if val > 0: s.set(val) return s else: style = 0 kwargs.pop('showvalue', None) # transmit in style? if 'borderwidth' in kwargs: style = 1 kwargs.pop('borderwidth') s = ttk.Scale(*args, **kwargs) #if style == 1: s.configure(style="K1.TScale") return s
def __init__(self, master=None, scalewidth=50, entrywidth=5, from_=0, to=50, orient=tk.HORIZONTAL, compound=tk.RIGHT, entryscalepad=0, **kwargs): """ :param master: master widget :param scalewidth: width of the Scale in pixels :param entrywidth: width of the Entry in characters :param from_: start value of the scale :param to: end value of the scale :param orient: scale orientation. Supports tk.HORIZONTAL and VERTICAL :param compound: side the Entry must be on. Supports tk.LEFT, RIGHT, TOP and BOTTOM :param entryscalepad: space between the entry and the scale :param kwargs: keyword arguments passed on to Frame initializer """ ttk.Frame.__init__(self, master, **kwargs) if compound is not tk.RIGHT and compound is not tk.LEFT and compound is not tk.TOP and \ compound is not tk.BOTTOM: raise ValueError( "Invalid value for compound passed {0}".format(compound)) self.__compound = compound if not isinstance(entryscalepad, int): raise TypeError("entryscalepad not of int type") self.__entryscalepad = entryscalepad self._variable = self.LimitedIntVar(from_, to) self._scale = ttk.Scale(self, from_=from_, to=to, length=scalewidth, orient=orient, command=self._on_scale, variable=self._variable) # Note that the textvariable keyword argument is not used to pass the LimitedIntVar self._entry = ttk.Entry(self, width=entrywidth) self._entry.insert(0, str(from_)) self._entry.bind("<KeyRelease>", self._on_entry) self._grid_widgets()
def init_config_panel(self, frame): self.config_panel = ttk.Frame(master=frame) # self.statusText = ttk.Label(master=self.config_panel, text="Idle") # self.statusText.grid(rowspan=2)#, columnspan=3, sticky='w') # ttk.Frame(master=self.config_panel, width=50).grid(column=3, rowspan=2) self.zoom_sliders = [] labels = ["Horizontal scale", "Vertical scale"] for i in range(2): ttk.Label(master=self.config_panel, text=labels[i], anchor='w').grid(row=i, column=4, sticky='e') self.zoom_sliders.append( ttk.Scale(master=self.config_panel, orient=HORIZONTAL)) self.zoom_sliders[i].grid(row=i, column=5, padx=10) self.zoom_sliders[0].config(from_=0, to=0.975) self.zoom_sliders[0].set(0.2) # TODO: Use constants for default yoffset and yrange values self.zoom_sliders[1].config(from_=12000, to=1000) self.zoom_sliders[1].set(4000) self.config_panel.pack(side='right')
def __init__(self, root, title): Frame.__init__(self, root) root.title(title) root.config(padx=15, pady=15) # Load the tooltips. If None is specified, then the file 'Tooltips.txt' # must be in the same directory as this file. Or, pass a /path/filename ToolTip.LoadToolTips(None) # Any widget can be assigned a Tooltip. f = ttk.LabelFrame(root, text="Tooltip test widgets", padding=(5, 5, 5, 5)) f.grid(row=0, column=0, sticky='NSEW', padx=(0, 10)) for i in range(5): b = ttk.Button(f, text='Press Me: Tip %d' % (100 + i), command=self.PressMe) b.grid(row=i, column=0, pady=(0, 5), sticky='W') ToolTip(b, 100 + i) # Tips numbered 100 to 104 f = ttk.LabelFrame(root, text="Tooltip test widgets", padding=(5, 5, 5, 5)) f.grid(row=0, column=1, sticky='NSEW') for i in range(5): b = ttk.Checkbutton(f, text='Check button: Tip %d' % (200 + i), command=self.PressMe) b.grid(row=i, column=0, pady=(0, 5), sticky='W') ToolTip(b, 200 + i) # Tips numbered 200 to 204 f = ttk.LabelFrame(root, text="Control the tooltips", padding=(5, 5, 5, 5)) f.grid(row=1, column=0, rowspan=2, sticky='NSEW') b = BooleanVar() # This is a static variable, so you must reference it by module name b.set(ToolTip.ShowToolTips) # The defaut value is True c = ttk.Checkbutton(f, text='Enable tooltips', variable=b, command=self.HideTooltipsPressed) c.grid(row=0, column=0, pady=(0, 5), sticky='W') ToolTip(c, 9999) # If no matching tip number is found, then the # tip message states that b = BooleanVar() # This is a static variable, so you must reference it by module name b.set(ToolTip.ShowTipNumber) # The defaut value is False c = ttk.Checkbutton(f, text='Show tip number in tooltip', variable=b, command=self.ShowTooltipNumberPressed) c.grid(row=1, column=0, columnspan=2, pady=(0, 5), sticky='W') ToolTip(c, 2000) # You can just pass a text string to the ToolTip l = ttk.Label(f, text='Tooltip show delay:') l.grid(row=2, column=0, sticky='W') ToolTip(l,"Tooltip text for the label 'Tooltip show delay' passed directly" \ " in the ToolTip constructor.") # To have the tooltip call a function in your code when it needs # a new tooltip, create the ToolTip and pass a function using # ToolTip(widget,msgFunc=self.CallbackFunctionName) # We'll apply this type of ToolTip to the Slider. s = ttk.Scale(f, from_=0, to=5.0, command=self.TooltipDelaySliderChanged, orient='horizontal', length=75) s.grid(row=2, column=1, sticky='W') # This is a static variable, so you must reference it by module name s.set(ToolTip.ShowTipDelay) # Set to the default value of 1.0 sec ToolTip(s, msgFunc=self.SampleTooltipCallback)
def __init__(self, ih, canvas, root): tk.Toplevel.__init__(self) self.wm_title("Alpha/Beta detection") self.resizable(0, 0) self.protocol("WM_DELETE_WINDOW", self.cancel) self.ih = ih self.canvas = canvas self.root = root self.blur = dalgos.BLUR self.blur_label = ttk.Label(self) blur_frame = ttk.Frame(self) self.blur_slider = ttk.Scale(blur_frame, orient="horizontal", to=100, command=self.update_blur) blur_minus = ttk.Button(blur_frame, text="-", width=1, command=self.blur_down) blur_plus = ttk.Button(blur_frame, text="+", width=1, command=self.blur_up) self.blur_label.pack(side="top", expand="y") self.blur_slider.pack(side="left") blur_minus.pack(side="left") blur_plus.pack(side="left") blur_frame.pack(side="top", expand="y") self.set_blur(self.blur, False) self.threshold = dalgos.THRESHOLD self.threshold_label = ttk.Label(self) threshold_frame = ttk.Frame(self) self.threshold_slider = ttk.Scale(threshold_frame, orient="horizontal", to=100, command=self.update_threshold) threshold_minus = ttk.Button(threshold_frame, text="-", width=1, command=self.threshold_down) threshold_plus = ttk.Button(threshold_frame, text="+", width=1, command=self.threshold_up) self.threshold_label.pack(side="top", expand="y") self.threshold_slider.pack(side="left") threshold_minus.pack(side="left") threshold_plus.pack(side="left") threshold_frame.pack(side="top", expand="y") self.set_threshold(self.threshold, False) self.iter = dalgos.ITER self.iter_label = ttk.Label(self) iter_frame = ttk.Frame(self) self.iter_slider = ttk.Scale(iter_frame, orient="horizontal", to=100, command=self.update_iter) iter_minus = ttk.Button(iter_frame, text="-", width=1, command=self.iter_down) iter_plus = ttk.Button(iter_frame, text="+", width=1, command=self.iter_up) self.iter_label.pack(side="top", expand="y") self.iter_slider.pack(side="left") iter_minus.pack(side="left") iter_plus.pack(side="left") iter_frame.pack(side="top", expand="y") self.set_iter(self.iter, False) self.area = dalgos.AREA self.area_label = ttk.Label(self) area_frame = ttk.Frame(self) self.area_slider = ttk.Scale(area_frame, orient="horizontal", to=100, command=self.update_area) area_minus = ttk.Button(area_frame, text="-", width=1, command=self.area_down) area_plus = ttk.Button(area_frame, text="+", width=1, command=self.area_up) self.area_label.pack(side="top", expand="y") self.area_slider.pack(side="left") area_minus.pack(side="left") area_plus.pack(side="left") area_frame.pack(side="top", expand="y") self.set_area(self.area, False) command_frame = ttk.Frame(self) command_frame.pack(side="top", fill="y", expand="true") ok_button = ttk.Button(self, text="OK", command=self.ok) ok_button.pack(side="left") cancel_button = ttk.Button(self, text="Cancel", command=self.cancel) cancel_button.pack(side="right") self.update()
def BuildPage(self): f = ttk.Frame(self) f.grid(row=0, column=0, sticky='NSEW') f.columnconfigure(1, weight=1) #------------------- Metering Mode -------------------- l = Label(f, text='Metering mode:') l.grid(row=0, column=0, sticky='W', pady=5) self.MeteringModeCombo = Combobox(f, state='readonly', width=20) self.MeteringModeCombo.grid(row=0, column=1, columnspan=3, sticky='W') l = list(self.camera.METER_MODES.keys()) l.sort() self.MeteringModeCombo['values'] = l self.MeteringModeCombo.current(0) self.MeteringModeCombo.bind('<<ComboboxSelected>>', self.MeteringModeChanged) ToolTip(self.MeteringModeCombo, 200) #------------------- Exposure Mode -------------------- self.ExposureModeText = None f = ttk.LabelFrame(self, text='Exposure mode (Equivalent film ISO)', padding=(5, 5, 5, 5)) f.grid(row=1, column=0, sticky='NSW', pady=5) # was 4, columnspan=3, #f.columnconfigure(1,weight=1) self.ExposureModeVar = MyStringVar('auto') self.AutoExposureRadio = MyRadio(f, 'Full auto (Default)', 'auto', self.ExposureModeVar, self.ExposureModeButton, 0, 0, 'W', tip=205) MyRadio(f, 'Preset exposures:', 'set', self.ExposureModeVar, self.ExposureModeButton, 1, 0, 'W', tip=206) MyRadio(f, 'Manually set ISO:', 'iso', self.ExposureModeVar, self.ExposureModeButton, 2, 0, 'W', tip=207) MyRadio(f, 'Off (Gains set at current value)', 'off', self.ExposureModeVar, self.ExposureModeButton, 3, 0, 'W', span=2, tip=208) #was 2 self.ExpModeCombo = Combobox(f, state='readonly', width=10) ToolTip(self.ExpModeCombo, 209) self.ExpModeCombo.grid(row=1, column=1, sticky='W') #sticky='EW') self.ExpModeCombo.bind('<<ComboboxSelected>>', self.ExpModeChanged) exp = list(self.camera.EXPOSURE_MODES.keys()) exp.remove('off') # these two are handled by radio buttons exp.remove('auto') exp.sort() #cmp=lambda x,y: cmp(x.lower(),y.lower())) self.ExpModeCombo['values'] = exp self.ExpModeCombo.current(1) self.IsoCombo = Combobox(f, state='readonly', width=10) ToolTip(self.IsoCombo, 210) self.IsoCombo.grid(row=2, column=1, sticky='W') #sticky='EW') self.IsoCombo.bind('<<ComboboxSelected>>', self.IsoChanged) self.IsoCombo['values'] = [100, 200, 320, 400, 500, 640, 800] self.IsoCombo.current(3) Separator(f, orient=HORIZONTAL).grid(pady=5, row=4, column=0, columnspan=2, sticky='EW') # was 3 f1 = ttk.Frame(f) f1.grid(row=5, column=0, sticky='NS', columnspan=2) # was 2 l = Label(f1, text='Analog gain:').grid(row=0, column=0, sticky='W') self.AnalogGain = ttk.Label(f1, style='DataLabel.TLabel') self.AnalogGain.grid(row=0, column=1, sticky=W, pady=2, padx=5) ToolTip(self.AnalogGain, 211) l = Label(f1, text='Digital gain:').grid(row=0, column=2, sticky='W') self.DigitalGain = ttk.Label(f1, style='DataLabel.TLabel') self.DigitalGain.grid(row=0, column=3, sticky=W, pady=2, padx=5) ToolTip(self.DigitalGain, 212) l = Label(f1, text='Actual ISO:').grid(row=1, column=0, sticky='W') self.EffIso = ttk.Label(f1, style='DataLabel.TLabel') self.EffIso.grid(row=1, column=1, sticky=W, pady=2, padx=5) ToolTip(self.EffIso, 213) l = Label(f1, text='Apparent ISO:').grid(row=1, column=2, sticky='W') self.MeasIso = ttk.Label(f1, style='DataLabel.TLabel') self.MeasIso.grid(row=1, column=3, sticky=W, pady=2, padx=5) ToolTip(self.MeasIso, 214) # -------------- Right frame --------------- f = ttk.LabelFrame(self, text='Exposure Compensation / DRC', padding=(5, 5, 5, 5), width=150) f.grid(row=1, column=2, sticky='NS', pady=5) # was 4, columnspan=3, b = MyBooleanVar(True) self.AutoExposureRadio = MyRadio(f, 'None (Default)', True, b, self.ExposureCompButton, 0, 0, 'W', span=2, tip=231) MyRadio(f, 'Amount:', False, b, self.ExposureCompButton, 1, 0, 'W', tip=232) self.fstop = ttk.Label(f, width=16, padding=(5, 5, 5, 5), style='DataLabel.TLabel') self.fstop.grid(row=2, column=1, sticky='W') self.ExpCompSlider = ttk.Scale(f, from_=-25, to=25, length=100, command=self.ExpComboSliderChanged, orient='horizontal') self.ExpCompSlider.grid(row=1, column=1, sticky='EW', pady=5) self.ExpCompSlider.set(0) ToolTip(self.ExpCompSlider, 230) Separator(f, orient=HORIZONTAL).grid(pady=5, row=3, column=0, columnspan=2, sticky='EW') # was 3 l = Label(f,text='Dynamic Range Compression') \ .grid(row=4,column=0,sticky='W',columnspan=2) b = MyBooleanVar(False) self.DisableDRCRadio = MyRadio(f, 'Disabled (Default)', False, b, self.DrcChecked, 5, 0, 'W', pad=(0, 5, 10, 5), tip=233, span=2) MyRadio(f, 'Enabled', True, b, self.DrcChecked, 6, 0, 'W', pad=(0, 5, 10, 5), tip=234) self.DrcCombo = Combobox(f, state='readonly', width=5) self.DrcCombo.grid(row=6, column=1, sticky='EW') ToolTip(self.DrcCombo, 235) vals = self.camera.DRC_STRENGTHS vals = list(vals.keys()) vals.remove('off') # Handled by radio button self.DrcCombo['values'] = vals self.DrcCombo.current(0) self.DrcCombo.bind('<<ComboboxSelected>>', self.DrcStrengthChanged) #------------------- Auto White Balance -------------------- f = ttk.LabelFrame(self, text='Auto white balance settings', padding=(5, 5, 5, 5)) f.grid(row=2, column=0, columnspan=5, sticky='NEWS', pady=5) #f.columnconfigure(2,weight=1) #f.columnconfigure(4,weight=1) self.AWBText = None self.AutoAWB = MyStringVar('auto') self.AWBRadio = MyRadio(f, 'Auto', 'auto', self.AutoAWB, self.AutoAWBChecked, 0, 0, 'NW', tip=250) MyRadio(f, 'Select:', 'sel', self.AutoAWB, self.AutoAWBChecked, 1, 0, 'NW', tip=251) MyRadio(f, 'Off', 'off', self.AutoAWB, self.AutoAWBChecked, 2, 0, 'NW', tip=252) Label(f, text='Default').grid(row=0, column=1, sticky='E') Label(f, text='Mode:').grid(row=1, column=1, sticky='E', pady=5) self.awb = Combobox(f, state='readonly', width=12) ToolTip(self.awb, 253) self.awb.grid(row=1, column=2, columnspan=1, sticky='W') self.awb.bind('<<ComboboxSelected>>', self.AWBModeChanged) modes = list(self.camera.AWB_MODES.keys()) modes.sort() #cmp=lambda x,y: cmp(x.lower(),y.lower())) modes.remove('off') # these two are handled by the radiobuttons modes.remove('auto') self.awb['values'] = modes self.awb.current(0) okCmd = (self.register(self.ValidateGains), '%P') Label(f, text='Red gain:').grid(row=2, column=1, sticky=E) self.RedGain = StringVar() self.RedEntry = Entry(f, textvariable=self.RedGain, width=10, validate='all', validatecommand=okCmd) self.RedEntry.grid(row=2, column=2, sticky='W') ToolTip(self.RedEntry, 254) Label(f, text='Blue gain:').grid(row=2, column=3, sticky=W) self.BlueGain = StringVar() self.BlueEntry = Entry(f, textvariable=self.BlueGain, width=10, validate='all', validatecommand=okCmd) self.BlueEntry.grid(row=2, column=4, sticky='W') ToolTip(self.BlueEntry, 255) #------------------- Shutter Speed -------------------- self.ShutterSpeedText = None self.Multiplier = 1 f = ttk.LabelFrame(self, text='Shutter speed', padding=(5, 5, 5, 5)) f.grid(row=3, column=0, columnspan=4, sticky='NEWS', pady=5) #f.columnconfigure(2,weight=1) self.ShutterSpeedAuto = MyBooleanVar(True) self.AutoShutterRadio = MyRadio(f, 'Auto (Default)', True, self.ShutterSpeedAuto, self.ShutterSpeedButton, 0, 0, 'W', span=2, tip=300) l = Label(f, text='Current Exposure:') l.grid(row=0, column=1, sticky=W, pady=5) self.ExposureSpeed = ttk.Label(f, style='DataLabel.TLabel') self.ExposureSpeed.grid(row=0, column=2, sticky=W) ToolTip(self.ExposureSpeed, 301) MyRadio(f, 'Set shutter speed:', False, self.ShutterSpeedAuto, self.ShutterSpeedButton, 1, 0, 'W', tip=302) okCmd = (self.register(self.ValidateShutterSpeed), '%P') self.ShutterSpeed = StringVar() self.ShutterSpeedEntry = Entry(f, textvariable=self.ShutterSpeed, width=7, validate='all', validatecommand=okCmd) self.ShutterSpeedEntry.grid(row=1, column=1, sticky='EW') ToolTip(self.ShutterSpeedEntry, 303) self.ShutterSpeedCombo = Combobox(f, state='readonly', width=6) self.ShutterSpeedCombo.grid(row=1, column=2, columnspan=1, sticky='W') self.ShutterSpeedCombo['values'] = ['usec', 'msec', 'sec'] self.ShutterSpeedCombo.current(0) self.ShutterSpeedCombo.bind('<<ComboboxSelected>>', self.ShutterSpeedComboChanged) ToolTip(self.ShutterSpeedCombo, 304) self.SlowestShutterSpeed = ttk.Label(f, style='RedMessage.TLabel') self.SlowestShutterSpeed.grid(row=2, column=0, columnspan=4, sticky='W') #------------------- Frame Rate -------------------- self.FPSText = None f = MyLabelFrame(self, 'Frame rate', 4, 0, span=4) #f.columnconfigure(2,weight=1) l = Label(f, text='Current frame rate:').grid(row=0, column=0, sticky='W') self.FrameRate = ttk.Label(f, style='DataLabel.TLabel') self.FrameRate.grid(row=0, column=1, columnspan=3, sticky='W') ToolTip(self.FrameRate, 310) self.FixedFrameRateBool = MyBooleanVar(True) self.ffr = MyRadio(f, 'Fixed frame rate:', True, self.FixedFrameRateBool, self.FixedFrameRateChecked, 1, 0, 'W', tip=311) okCmd = (self.register(self.ValidateFixedRange), '%P') self.FixedFramerateText = MyStringVar("30.0") self.FixedFramerateEntry = Entry(f, width=6, validate='all', validatecommand=okCmd, textvariable=self.FixedFramerateText) self.FixedFramerateEntry.grid(row=1, column=1, sticky='W') ToolTip(self.FixedFramerateEntry, 312) l = Label(f, text='FPS').grid(row=1, column=2, sticky='W') Label(f, text='Delta:').grid(row=1, column=3, sticky='E', padx=(5, 0)) okCmd = (self.register(self.ValidateFramerateDelta), '%P') self.FramerateDeltaText = MyStringVar("0.0") self.FramerateDelta = Entry(f, width=6, validate='all', validatecommand=okCmd, textvariable=self.FramerateDeltaText) self.FramerateDelta.grid(row=1, column=4, sticky='W') ToolTip(self.FramerateDelta, 315) Label(f, text='FPS').grid(row=1, column=5, sticky='W') MyRadio(f, 'Frame rate range:', False, self.FixedFrameRateBool, self.FixedFrameRateChecked, 2, 0, 'W', tip=313) #Label(f,text='Frame rate range:').grid(row=2,column=0,sticky='W') ok1Cmd = (self.register(self.ValidateFramerateRangeFrom), '%P') self.FramerateRangeFromText = MyStringVar("1/6") self.FramerateFrom = Entry(f, width=6, validate='all', textvariable=self.FramerateRangeFromText) self.FramerateFrom.grid(row=2, column=1, sticky='W') ToolTip(self.FramerateFrom, 314) Label(f, text='FPS').grid(row=2, column=2, sticky='W') Label(f, text='To:').grid(row=2, column=3, sticky='E') self.FramerateRangeToText = MyStringVar("30.0") ok2Cmd = (self.register(self.ValidateFramerateRangeTo), '%P') self.FramerateTo = Entry(f, width=6, validate='all', validatecommand=ok2Cmd, textvariable=self.FramerateRangeToText) self.FramerateTo.grid(row=2, column=4, sticky='W') ToolTip(self.FramerateTo, 316) l = Label(f, text='FPS').grid(row=2, column=5, sticky='W') self.FramerateFrom.config(validatecommand=ok1Cmd) self.AutoExposureRadio.invoke() self.DrcChecked(False) self.CheckGains() self.ExposureModeButton('auto') self.AutoAWBChecked('auto') self.ShowAWBGains() self.AutoShutterRadio.invoke() self.ExpModeCombo.focus_set() self.ffr.invoke() self.UpdateFrameRate()
def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = 'wheat' # X11 color: #f5deb3 _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#b2c9f4' # Closest X11 color: 'SlateGray2' _ana1color = '#eaf4b2' # Closest X11 color: '{pale goldenrod}' _ana2color = '#f4bcb2' # Closest X11 color: 'RosyBrown2' font10 = "-family {DejaVu Sans Mono} -size 14 -weight normal " \ "-slant roman -underline 0 -overstrike 0" font11 = "TkDefaultFont" font9 = "-family {DejaVu Sans} -size 14 -weight normal -slant " \ "roman -underline 0 -overstrike 0" self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.',background=_bgcolor) self.style.configure('.',foreground=_fgcolor) self.style.configure('.',font=font9) self.style.map('.',background= [('selected', _compcolor), ('active',_ana2color)]) top.geometry("600x881+650+150") top.title("New Toplevel 1") top.configure(background="wheat") top.configure(highlightbackground="wheat") top.configure(highlightcolor="black") self.TButton1 = ttk.Button(top) self.TButton1.place(relx=0.02, rely=0.02, height=32, width=92) self.TButton1.configure(takefocus="") self.TButton1.configure(text='''Tbutton''') self.style.map('TCheckbutton',background= [('selected', _bgcolor), ('active',"_ana2color")]) self.TCheckbutton1 = ttk.Checkbutton(top) self.TCheckbutton1.place(relx=0.03, rely=0.08, relwidth=0.12 , relheight=0.0, height=25) self.TCheckbutton1.configure(variable=themed_support.tch36) self.TCheckbutton1.configure(takefocus="") self.TCheckbutton1.configure(text='''Tcheck''') self.TCombobox1 = ttk.Combobox(top) self.TCombobox1.place(relx=0.03, rely=0.14, relheight=0.02, relwidth=0.3) self.TCombobox1.configure(textvariable=themed_support.combobox) self.TCombobox1.configure(takefocus="") self.TEntry1 = ttk.Entry(top) self.TEntry1.place(relx=0.05, rely=0.19, relheight=0.02, relwidth=0.27) self.TEntry1.configure(takefocus="") self.TEntry1.configure(cursor="xterm") self.TFrame1 = ttk.Frame(top) self.TFrame1.place(relx=0.05, rely=0.24, relheight=0.09, relwidth=0.21) self.TFrame1.configure(relief=GROOVE) self.TFrame1.configure(borderwidth="2") self.TFrame1.configure(relief=GROOVE) self.TFrame1.configure(width=125) self.TLabelframe1 = ttk.Labelframe(top) self.TLabelframe1.place(relx=0.05, rely=0.39, relheight=0.09 , relwidth=0.25) self.TLabelframe1.configure(text='''Tlabelframe''') self.TLabelframe1.configure(width=150) self.TProgressbar1 = ttk.Progressbar(top) self.TProgressbar1.place(relx=0.45, rely=0.64, relwidth=0.17 , relheight=0.0, height=19) self.style.map('TRadiobutton',background= [('selected', _bgcolor), ('active',"_ana2color")]) self.TRadiobutton1 = ttk.Radiobutton(top) self.TRadiobutton1.place(relx=0.73, rely=0.64, relwidth=0.16 , relheight=0.0, height=23) self.TRadiobutton1.configure(takefocus="") self.TRadiobutton1.configure(text='''TRadio''') self.TScale1 = ttk.Scale(top) self.TScale1.place(relx=0.85, rely=0.41, relwidth=0.0, relheight=0.11 , width=17) self.TScale1.configure(orient="vertical") self.TScale1.configure(takefocus="") self.TScale2 = ttk.Scale(top) self.TScale2.place(relx=0.45, rely=0.68, relwidth=0.17, relheight=0.0 , height=17) self.TScale2.configure(takefocus="") self.Scrolledlistbox1 = ScrolledListBox(top) self.Scrolledlistbox1.place(relx=0.05, rely=0.76, relheight=0.07 , relwidth=0.19) self.Scrolledlistbox1.configure(background="white") self.Scrolledlistbox1.configure(disabledforeground="#b8a786") self.Scrolledlistbox1.configure(font=font11) self.Scrolledlistbox1.configure(highlightbackground="wheat") self.Scrolledlistbox1.configure(highlightcolor="wheat") self.Scrolledlistbox1.configure(selectbackground="#c4c4c4") self.Scrolledlistbox1.configure(width=10) self.Scrolledtext1 = ScrolledText(top) self.Scrolledtext1.place(relx=0.37, rely=0.76, relheight=0.09 , relwidth=0.21) self.Scrolledtext1.configure(background="white") self.Scrolledtext1.configure(font=font10) self.Scrolledtext1.configure(highlightbackground="wheat") self.Scrolledtext1.configure(insertborderwidth="3") self.Scrolledtext1.configure(selectbackground="#c4c4c4") self.Scrolledtext1.configure(width=10) self.Scrolledtext1.configure(wrap=NONE) self.style.configure('Treeview.Heading', font=font9) self.Scrolledtreeview1 = ScrolledTreeView(top) self.Scrolledtreeview1.place(relx=0.13, rely=0.86, relheight=0.12 , relwidth=0.7) self.Scrolledtreeview1.configure(columns="Col1") self.Scrolledtreeview1.heading("#0",text="Tree") self.Scrolledtreeview1.heading("#0",anchor="center") self.Scrolledtreeview1.column("#0",width="209") self.Scrolledtreeview1.column("#0",minwidth="20") self.Scrolledtreeview1.column("#0",stretch="1") self.Scrolledtreeview1.column("#0",anchor="w") self.Scrolledtreeview1.heading("Col1",text="Col1") self.Scrolledtreeview1.heading("Col1",anchor="center") self.Scrolledtreeview1.column("Col1",width="209") self.Scrolledtreeview1.column("Col1",minwidth="20") self.Scrolledtreeview1.column("Col1",stretch="1") self.Scrolledtreeview1.column("Col1",anchor="w") self.TSizegrip1 = ttk.Sizegrip(top) self.TSizegrip1.place(anchor=SE, relx=1.0, rely=1.0) self.TLabel1 = ttk.Label(top) self.TLabel1.place(relx=0.05, rely=0.34, height=17, width=37) self.TLabel1.configure(background="wheat") self.TLabel1.configure(foreground="#000000") self.TLabel1.configure(relief=FLAT) self.TLabel1.configure(text='''Tlabel''') self.style.configure('TNotebook.Tab', background=_bgcolor) self.style.configure('TNotebook.Tab', foreground=_fgcolor) self.style.map('TNotebook.Tab', background= [('selected', _compcolor), ('active',_ana2color)]) self.TNotebook1 = ttk.Notebook(top) self.TNotebook1.place(relx=0.43, rely=0.05, relheight=0.26, relwidth=0.5) self.TNotebook1.configure(width=300) self.TNotebook1.configure(takefocus="") self.TNotebook1_t1 = ttk.Frame(self.TNotebook1) self.TNotebook1.add(self.TNotebook1_t1, padding=3) self.TNotebook1.tab(0, text="Page 1",underline="-1",) self.TNotebook1_t2 = ttk.Frame(self.TNotebook1) self.TNotebook1.add(self.TNotebook1_t2, padding=3) self.TNotebook1.tab(1, text="Page 2",underline="-1",) self.TPanedwindow2 = ttk.Panedwindow(top, orient="vertical") self.TPanedwindow2.place(relx=0.03, rely=0.49, relheight=0.23 , relwidth=0.33) self.TPanedwindow2.configure(width=200) self.TPanedwindow2_p1 = ttk.Labelframe(height=75, text='Pane 1') self.TPanedwindow2.add(self.TPanedwindow2_p1) self.TPanedwindow2_p2 = ttk.Labelframe(text='Pane 2') self.TPanedwindow2.add(self.TPanedwindow2_p2) self.__funcid0 = self.TPanedwindow2.bind('<Map>', self.__adjust_sash0) self.TPanedwindow1 = ttk.Panedwindow(top, orient="horizontal") self.TPanedwindow1.place(relx=0.42, rely=0.34, relheight=0.23 , relwidth=0.33) self.TPanedwindow1.configure(width=200) self.TPanedwindow1_p1 = ttk.Labelframe(width=75, text='Pane 1') self.TPanedwindow1.add(self.TPanedwindow1_p1) self.TPanedwindow1_p2 = ttk.Labelframe(text='Pane 2') self.TPanedwindow1.add(self.TPanedwindow1_p2) self.__funcid1 = self.TPanedwindow1.bind('<Map>', self.__adjust_sash1)
def __init__(self, root, camera, title): # Creates a Frame for the Main Window Frame.__init__(self, root) self.grid(padx=5,pady=5) self.root = root self.ControlMapping = ControlMapping() # Starts Camera Preview self.camera = camera self.camera.start_preview(fullscreen=False,window=(0,0,10,10)) self.title = title self.root.title(title) master = root master.rowconfigure(0,weight=1) master.columnconfigure(1,weight=1) master.config(padx=5,pady=5) ToolTip.LoadToolTips() '''-------------- Icons for Menu and Buttons -------------------''' self.iconClose = GetPhotoImage("Assets/window-close.png") #self.iconClose = ImageTk.PhotoImage(PIL.Image.open("Assets/window-close.png")) self.iconPrefs = GetPhotoImage('Assets/prefs1_16x16.png') self.iconWeb = GetPhotoImage('Assets/web_16x16.png') image = PIL.Image.open('Assets/camera-icon.png') self.iconCameraBig = GetPhotoImage(image.resize((22,22))) self.iconCamera = GetPhotoImage(image.resize((16,16))) image = PIL.Image.open('Assets/video-icon-b.png') self.iconVideoBig = GetPhotoImage(image.resize((22,22))) self.iconVideo = GetPhotoImage(image.resize((16,16))) '''-------------- Notebook with all control pages -------------''' frame1 = ttk.Frame(master,padding=(5,5,5,5)) frame1.grid(row=0,column=0,sticky="NSEW") frame1.rowconfigure(2,weight=1) frame1.columnconfigure(0,weight=1) self.AlwaysPreview = False n = Notebook(frame1,padding=(5,5,5,5)) n.grid(row=1,column=0,rowspan=2,sticky=(N,E,W,S)) n.columnconfigure(0,weight=1) n.enable_traversal() # Calls Notebook Pages from external classes # PiCamera Classes self.BasicControlsFrame = BasicControls(n,camera) self.ExposureFrame = Exposure(n,camera) self.FinerControlFrame = FinerControl(n,camera) # MicroscoPy Classes self.TimelapseFrame = Timelapse(n,camera) # Unfinished self.MotorControlsFrame = MotorControls(n,camera) # Unfinished self.LivestreamFrame = Livestream(n,camera) # Unfinished self.PositonalTrackingFrame = PositionalTracking(n,camera) # Unfinished n.add(self.BasicControlsFrame , text='Basic', underline=0) n.add(self.ExposureFrame, text='Exposure', underline=0) n.add(self.FinerControlFrame, text='Advanced', underline=0) n.add(self.TimelapseFrame, text='Time lapse', underline=0) n.add(self.MotorControlsFrame, text='Motor Positioning', underline=0) n.add(self.LivestreamFrame, text='Livestream', underline=0) n.add(self.PositonalTrackingFrame, text='Object Tracking', underline=0) self.FinerControlFrame.PassControlFrame(self.BasicControlsFrame) self.pw = ttk.PanedWindow(master,orient=VERTICAL,style='TPanedwindow', takefocus=True) self.pw.grid(row=0,column=1,sticky="NSEW") self.pw.rowconfigure(0,weight=1) self.pw.columnconfigure(0,weight=1) self.TopFrame = ttk.Frame(self.pw,padding=(5,5,5,5)) self.TopFrame.grid(row=0,column=0,sticky="NEWS") self.TopFrame.rowconfigure(0,weight=1) self.TopFrame.columnconfigure(1,weight=1) self.ImageCanvas = Canvas(self.TopFrame,width=256,height=256, background=self.ControlMapping.FocusColor,cursor='diamond_cross') self.ImageCanvas.grid(row=0,column=0,columnspan=2,sticky="NEWS") self.ImageCanvas.itemconfigure('nopreview',state='hidden') self.ImageCanvas.bind("<Motion>", self.CanvasMouseMove) self.ImageCanvas.bind("<ButtonPress>", self.CanvasMouseMove) self.ImageCanvas.bind("<Enter>", self.CanvasEnterLeave) self.ImageCanvas.bind("<Leave>", self.CanvasEnterLeave) ButtonFrame = ttk.Frame(self.TopFrame,padding=(5,5,5,5),relief=SUNKEN) ButtonFrame.grid(row=1,column=0,columnspan=2,sticky="NEWS") self.PreviewOn = MyBooleanVar(True) self.enablePrev = ttk.Checkbutton(ButtonFrame,text='Preview',variable=self.PreviewOn, command=self.SetPreviewOn) self.enablePrev.grid(row=0,column=0,padx=5,sticky='W') ToolTip(self.enablePrev, msg=1) l2 = Label(ButtonFrame,text="Alpha:") l2.grid(column=1,row=0,sticky='W') self.alpha = ttk.Scale(ButtonFrame,from_=0,to=255, command=self.AlphaChanged,orient='horizontal',length=75) self.alpha.grid(row=0,column=2,sticky='E') self.alpha.set(255) ToolTip(self.alpha, msg=2) self.VFlipState = False image = PIL.Image.open('Assets/flip.png') image1 = image.rotate(90) image1 = image1.resize((16,16)) self.flipVgif = ImageTk.PhotoImage(image1) self.Vflip = ttk.Button(ButtonFrame,image=self.flipVgif,width=10, command=self.ToggleVFlip,padding=(2,2,2,2)) self.Vflip.grid(row=0,column=3,padx=5) ToolTip(self.Vflip, msg=3) self.HFlipState = False self.flipHgif = ImageTk.PhotoImage(image.resize((16,16))) self.Hflip = ttk.Button(ButtonFrame,image=self.flipHgif,width=10, command=self.ToggleHFlip,padding=(2,2,2,2)) self.Hflip.grid(row=0,column=4) ToolTip(self.Hflip, msg=4) image = PIL.Image.open('Assets/rotate.png') self.RotateImg = ImageTk.PhotoImage(image.resize((16,16))) self.Rotate = ttk.Button(ButtonFrame,image=self.RotateImg,width=10, command=self.RotateCamera,padding=(2,2,2,2)) self.Rotate.grid(row=0,column=5) ToolTip(self.Rotate, msg=14) self.ShowOnScreen = MyBooleanVar(True) self.ShowOnMonitorButton = ttk.Checkbutton(ButtonFrame, \ text='Overlay',variable=self.ShowOnScreen, \ command=self.SetPreviewLocation) self.ShowOnMonitorButton.grid(row=0,column=6,padx=5,sticky='W') ToolTip(self.ShowOnMonitorButton, msg=5) l5 = Label(ButtonFrame,text="Size:") l5.grid(column=7,row=0,sticky='W') self.WindowSize = ttk.Scale(ButtonFrame,from_=100,to=800, command=self.WindowSizeChanged,orient='horizontal',length=75) self.WindowSize.grid(row=0,column=8,sticky='E') self.WindowSize.set(255) ToolTip(self.WindowSize, msg=6) #------------------ Photo / Video Section ---------------------- self.pictureStream = io.BytesIO() BottomFrame = ttk.Frame(self.pw,padding=(5,5,5,5)) BottomFrame.grid(row=1,column=0,sticky="NEWS") BottomFrame.rowconfigure(0,weight=1) BottomFrame.columnconfigure(0,weight=1) self.photoPanedWindow = ttk.PanedWindow(BottomFrame,orient=HORIZONTAL, style='Pan.TPanedwindow') self.photoPanedWindow.grid(row=0,column=0,sticky="NSEW") self.photoPanedWindow.rowconfigure(0,weight=1) self.photoPanedWindow.columnconfigure(0,weight=1) self.photoPanedWindow.columnconfigure(1,weight=1) self.LeftFrame = ttk.Frame(self.photoPanedWindow,padding=(5,5,5,5)) self.LeftFrame.grid(row=0,column=0,sticky="NEWS") self.LeftFrame.rowconfigure(0,weight=1) self.LeftFrame.columnconfigure(0,weight=1) sb = Scrollbar(self.LeftFrame,orient='vertical') sb.grid(row=0,column=1,sticky='NS') ToolTip(sb, msg=7) sb1 = Scrollbar(self.LeftFrame,orient='horizontal') sb1.grid(row=1,column=0,sticky='EW') ToolTip(sb, msg=8) text = Text(self.LeftFrame,width=37,wrap='none', yscrollcommand=sb.set,xscrollcommand=sb1.set) text.bind('<Configure>',self.TextboxResize) text.grid(row=0,column=0,sticky='NSEW') sb.config(command=text.yview) sb1.config(command=text.xview) text.bind("<Key>",lambda e : "break") # ignore all keypress self.CameraUtils = CameraUtils(self.camera,self.BasicControlsFrame) self.CameraUtils.SetupCameraSettingsTextbox(text) RightFrame = ttk.Frame(self.photoPanedWindow,padding=(5,5,5,5)) RightFrame.grid(row=0,column=1,sticky="NEWS") RightFrame.rowconfigure(0,weight=1) RightFrame.columnconfigure(0,weight=1) self.CurrentImage = None self.photoCanvas = Canvas(RightFrame,width=50,height=50, background=self.ControlMapping.FocusColor,cursor='diamond_cross') self.photoCanvas.grid(row=0,column=0,sticky="NEWS") self.photoCanvas.create_line(0,0,320,0, fill='red',tags=('cursors','objs','cursorx')) self.photoCanvas.create_line(0,0,0,240, fill='red',tags=('cursors','objs','cursory')) self.photoCanvas.create_line(0,0,320,0, fill='lightgray',activefill='blue',tags=('cross','cross1')) self.photoCanvas.create_line(0,0,0,240, fill='lightgray',activefill='blue',tags=('cross','cross2')) self.photoCanvas.create_text(0,0, tags=('capture'),text='', fill='lightgray',activefill='blue',anchor='center', font=('Helveticar',18,"bold italic")) self.photoCanvas.itemconfigure('capture',state='hidden') self.photoCanvas.create_text(0,0, fill='red',tags=('text','objs'),anchor='nw') self.photoCanvas.bind('<Configure>', self.PhotoCanvasResize) self.photoCanvas.bind("<ButtonPress-1>", self.photoCanvasScrollStart) self.photoCanvas.bind("<B1-Motion>", self.photoCanvasScrollMove) self.photoCanvas.bind("<Motion>", self.photoCanvasMove) self.photoCanvas.bind("<ButtonRelease-1>", self.photoCanvasButtonUp) self.photoCanvas.bind("<Enter>", self.photoCanvasEnterLeave) self.photoCanvas.bind("<Leave>", self.photoCanvasEnterLeave) self.InPhotoZoom = False # hack - # self.PhotoState = 'none', 'picture', 'zoom', 'video' ??? vsbar = Scrollbar(RightFrame,orient=VERTICAL) vsbar.grid(row=0,column=1,sticky='NS') vsbar.config(command=self.photoCanvas.yview) self.photoCanvas.config(yscrollcommand=vsbar.set) hsbar = Scrollbar(RightFrame,orient=HORIZONTAL) hsbar.grid(row=1,column=0,sticky='EW') hsbar.config(command=self.photoCanvas.xview) self.photoCanvas.config(xscrollcommand=hsbar.set) self.photoCanvas.bind("<5>",self.WheelScrollPhotoCanvas) self.photoCanvas.bind("<4>",self.WheelScrollPhotoCanvas) self.photoZoomScale = 1.0 self.photoPanedWindow.add(self.LeftFrame) self.photoPanedWindow.add(RightFrame) self.photoPanedWindow.forget(self.LeftFrame) ButtonFrame = ttk.Frame(BottomFrame,padding=(5,5,5,5)) ButtonFrame.grid(row=1,column=0,columnspan=3,sticky="NEWS") b = ttk.Button(ButtonFrame,text='Picture',underline=0,image=self.iconCameraBig, compound='left',command=lambda e=None:self.TakePicture(e),width=7) b.grid(row=0,column=0,sticky='W',padx=5) ToolTip(b, msg=9) self.InCaptureVideo = False # hack ---- self.TakeVideo = ttk.Button(ButtonFrame,text='Video',underline=0, image=self.iconVideoBig,compound='left', command=lambda e=None:self.ToggleVideo(e),width=7) self.TakeVideo.grid(row=0,column=1,sticky='W') ToolTip(self.TakeVideo, msg=10) self.clearImage = ImageTk.PhotoImage(file='Assets/cancel_22x22.png') b = ttk.Button(ButtonFrame,command=lambda e=None:self.ClearPicture(e), image=self.clearImage,padding=(0,1,0,1)) b.grid(row=0,column=2,sticky='W',padx=5) ToolTip(b, msg=11) image = PIL.Image.open('Assets/flip.png').resize((22,22)) self.FlipHorzImage = ImageTk.PhotoImage(image) b = ttk.Button(ButtonFrame,command=lambda e=None:self.FlipPictureH(e), image=self.FlipHorzImage,padding=(0,1,0,1)) b.grid(row=0,column=3,sticky='W') b.config(state='disabled') ToolTip(b, msg=12) self.FlipVertImage = ImageTk.PhotoImage(image.rotate(90)) b = ttk.Button(ButtonFrame,command=lambda e=None:self.FlipPictureV(e), image=self.FlipVertImage,padding=(0,1,0,1)) b.grid(row=0,column=4,sticky='W',padx=5) b.config(state='disabled') ToolTip(b, msg=13) self.pw.add(self.TopFrame) self.pw.add(BottomFrame) #-------------------------- Status Bar ------------------------- self.StatusBarFrame = ttk.Frame(master) self.StatusBarFrame.grid(row=1,column=0,columnspan=2,sticky='NSEW') self.StatusBarFrame.columnconfigure(5,weight=1) self.XYText = StringVar() l = ttk.Label(self.StatusBarFrame,anchor=CENTER,font=('Arial',9), textvariable=self.XYText,style='StatusBar.TLabel', width=13) l.grid(row=0,column=0,sticky='W') ToolTip(l,40) self.ExposureModeText = StringVar() l = ttk.Label(self.StatusBarFrame,anchor=CENTER,textvariable=self.ExposureModeText, style='StatusBar.TLabel',width=18,font=('Arial',9)) l.grid(row=0,column=1,sticky='W') ToolTip(l,41) self.AWBText = StringVar() l = ttk.Label(self.StatusBarFrame,anchor=CENTER,textvariable=self.AWBText, style='StatusBar.TLabel',width=18,font=('Arial',9)) l.grid(row=0,column=2,sticky='W') ToolTip(l,42) self.ShutterSpeedText = StringVar() l = ttk.Label(self.StatusBarFrame,anchor=CENTER,textvariable=self.ShutterSpeedText, style='StatusBar.TLabel',width=15,font=('Arial',9)) l.grid(row=0,column=3,sticky='W') ToolTip(l,43) self.FPSText = StringVar() l = ttk.Label(self.StatusBarFrame,anchor=CENTER,textvariable=self.FPSText, style='StatusBar.TLabel',width=10,font=('Arial',9)) l.grid(row=0,column=4,sticky='W') ToolTip(l,44) self.StatusText = StringVar() l = ttk.Label(self.StatusBarFrame,anchor=CENTER,textvariable=self.StatusText, style='StatusBar.TLabel',width=10,font=('Arial',9)) l.grid(row=0,column=5,sticky='EW') ToolTip(l,45) self.ExposureFrame.SetVariables(self.ExposureModeText, self.AWBText, self.ShutterSpeedText, self.FPSText) #--------------------------- Menu ------------------------------ menubar = Menu(root, foreground='black',background='#F0F0F0',activebackground='#86ABD9', activeforeground='white') filemenu = Menu(menubar,tearoff=0,foreground='black',background='#F0F0F0', activebackground='#86ABD9',activeforeground='white') #filemenu.add_command(label="Save Camera setups...",underline=0, #command=lambda e=None:self.SaveCameraSetups(e)) #filemenu.add_separator() filemenu.add_command(label="Preferences...",underline=0, image=self.iconPrefs, compound='left', command=lambda e=None:self.SystemPreferences(e)) filemenu.add_separator() filemenu.add_command(label="Quit",underline=0,image=self.iconClose, compound='left',accelerator='Ctrl+Q', command=lambda e=None:self.quitProgram(e)) self.DefineAccelerators('c','q',lambda e=None:self.quitProgram(e)) menubar.add("cascade",label='File',underline=0,menu=filemenu) viewmenu = Menu(menubar,tearoff=0,foreground='black',background='#F0F0F0', activebackground='#86ABD9',activeforeground='white') self.viewImageCursor = MyBooleanVar(False) viewmenu.add_checkbutton(label="Image cursors",underline=7, accelerator='Ctrl+Shift+C', onvalue=True,offvalue=False,variable=self.viewImageCursor, command=lambda e='Menu':self.ViewImageCursor(e)) self.DefineAccelerators('cs','c',self.ViewImageCursor) self.viewImageAttributesPane = BooleanVar() self.viewImageAttributesPane.set(False) viewmenu.add_checkbutton(label="Image Attribute pane",underline=6, accelerator='Ctrl+Shift+A', onvalue=True,offvalue=False,variable=self.viewImageAttributesPane, command=lambda e='Menu':self.ViewImageAttributesPane(e)) self.DefineAccelerators('cs','a',self.ViewImageAttributesPane) self.viewPreviewPane = BooleanVar() self.viewPreviewPane.set(True) viewmenu.add_checkbutton(label="Preview pane",underline=0, accelerator='Ctrl+Shift+P', onvalue=True,offvalue=False,variable=self.viewPreviewPane, command=lambda e='Menu':self.ViewPreviewPane(e)) self.DefineAccelerators('cs','p',self.ViewPreviewPane) self.ViewStatusBarBoolean = MyBooleanVar(True) viewmenu.add_checkbutton(label="Status bar",underline=0, onvalue=True,offvalue=False,variable=self.ViewStatusBarBoolean, command=lambda e='Menu':self.ViewStatusBar(e)) #viewmenu.add_command(label="Properties...",underline=0,accelerator='Ctrl+Alt+P', #image=self.iconPrefs,compound='left', #command=lambda e=None:self.ViewProperties(e)) #self.DefineAccelerators('ca','p',lambda e=None:self.ViewProperties(e)) menubar.add("cascade",label='View',underline=0,menu=viewmenu) photomenu = Menu(menubar,tearoff=0,foreground='black',background='#F0F0F0', activebackground='#86ABD9',activeforeground='white') photomenu.add_command(label="Take picture",underline=5, image=self.iconCamera,compound='left', command=lambda e=None:self.TakePicture(e),accelerator='Ctrl+P') self.DefineAccelerators('c','p',lambda e=None:self.TakePicture(e)) photomenu.add_command(label="Save Image...",underline=0,compound='left', command=lambda e=None:self.SavePictureorVideo(e),accelerator='Ctrl+S') self.DefineAccelerators('c','s',lambda e=None:self.SavePictureorVideo(e)) photomenu.add_command(label="Clear picture",underline=0, image=self.iconClose,compound='left', command=lambda e=None:self.ClearPicture(e),accelerator='Ctrl+C') self.DefineAccelerators('c','c',lambda e=None:self.ClearPicture(e)) photomenu.add_command(label="Reset Camera setups",underline=0, compound='left', command=lambda e=None:self.ResetCameraSetups(e),accelerator='Ctrl+R') self.DefineAccelerators('c','r',lambda e=None:self.ResetCameraSetups(e)) photomenu.add_separator() photomenu.add_command(label="Annotation/Overlay",underline=0, compound='left', command=lambda e=None:self.AnnotationOverlay(e))#,accelerator='Ctrl+A') #self.DefineAccelerators('c','a',lambda e=None:self.AnnotationOverlay(e)) menubar.add("cascade",label='Photo',underline=0,menu=photomenu) videomenu = Menu(menubar,tearoff=0,foreground='black',background='#F0F0F0', activebackground='#86ABD9',activeforeground='white') videomenu.add_command(label="Toggle video",underline=7, image=self.iconVideo,compound='left', command=lambda e=None:self.ToggleVideo(e),accelerator='Ctrl+V') self.DefineAccelerators('c','v',lambda e=None:self.ToggleVideo(e)) menubar.add("cascade",label='Video',underline=0,menu=videomenu) helpmenu = Menu(menubar,tearoff=0,foreground='black',background='#F0F0F0', activebackground='#86ABD9',activeforeground='white') helpmenu.add_command(label="Keyboard shortcuts...",underline=0, command=lambda e=None:self.KeyboardShortcuts(e)) helpmenu.add_command(label="Picamera Documentation...",underline=9, command=lambda e=None:self.PiCameraDocs(e),image=self.iconWeb,compound='left') helpmenu.add_command(label="Picamera Recipies...",underline=9, command=lambda e=None:self.PiCameraRecipies(e),image=self.iconWeb,compound='left') helpmenu.add_separator() helpmenu.add_command(label="About...",underline=0,command=lambda e=None:self.HelpAbout(e)) menubar.add("cascade",label='Help',underline=0,menu=helpmenu) root.config(menu=menubar) # infohost.nmt.edu/tcc/help/pubs/tkinter/web/menu.html # colors : wiki.tcl.tk/37701 self.CanvasPopup = Menu(root, title='Popup',tearoff=0, background='snow', foreground = 'black', activeforeground='white', activebackground='cornflowerblue',relief=FLAT) self.CanvasPopup.add_command(label='---Picture Menu---',command=None) self.CanvasPopup.add_separator() self.CanvasPopup.add_command(label='Save picture', command=lambda e=None:self.SavePictureorVideo(e)) self.CanvasPopup.add_command(label='Clear picture', command=lambda e=None:self.ClearPicture(e)) self.CanvasPopup.add_separator() self.CanvasPopup.add_command(label='Reset preview zoom', command=self.BasicControlsFrame.ZoomReset) # Selections are also bound to right mouse!! That sucks. self.photoCanvas.bind("<Button-3>", self.DoPictureWindowPopup) #--------------------------- End Menu -------------------------- # Catch all focus events to the Top Window. Use to control # whether the camera preview_window overlay is visible or not. # I'm sure this will fail with Topmost windows... :( self.root.bind('<FocusOut>',self.LoseFocus) self.root.bind('<FocusIn>',self.GotFocus) # We want to catch window movements to show/hide preview window root.bind( '<Configure>', self.OnFormEvent ) root.protocol("WM_DELETE_WINDOW", lambda e=None:self.quitProgram(e)) self.UpdateAnnotationText()
if rc1Val > 2000: rc1Val = 2000 elif rc1Val < 1000: rc1Val = 1000 #~ print "servo 1 ", rc1Val v.channels.overrides["1"] = rc1Val def setWheelAngleonRelease(instanceVar): setSteering(wheelAngleVal.get()) wheelAngleVal = DoubleVar() wheelAngleScale = ttk.Scale(topInfo, orient=HORIZONTAL, from_=8.0, to=0.0, variable=wheelAngleVal, style="Speed.Horizontal.TScale") wheelAngleScale.bind("<ButtonRelease-1>", setWheelAngleonRelease) wheelAngleScale.grid(column=0, row=0, sticky=(N, E, S, W)) topInfo.columnconfigure(0, weight=1) topInfo.rowconfigure(0, weight=1) ###SpeedSelFrame#### def setTargetSpeed(scaleVal): #Updates target speed as slider is moved targetSpeed.set((str(round(float(scaleVal), 1)), "MPH")) def setSpeed(requestSpeed):
def create_widgets(self): # Create some room around all the internal frames self.window['padx'] = 5 self.window['pady'] = 5 # - - - - - - - - - - - - - - - - - - - - - # The Commands frame # cmd_frame = ttk.LabelFrame(self.window, text="Commands", padx=5, pady=5, relief=tk.RIDGE) cmd_frame = ttk.LabelFrame(self.window, text="Commands", relief=tk.RIDGE) cmd_frame.grid(row=1, column=1, sticky=tk.E + tk.W + tk.N + tk.S) button_label = ttk.Label(cmd_frame, text="tk.Button") button_label.grid(row=1, column=1, sticky=tk.W, pady=3) button_label = ttk.Label(cmd_frame, text="ttk.Button") button_label.grid(row=2, column=1, sticky=tk.W, pady=3) menu_label = ttk.Label(cmd_frame, text="Menu (see examples above)") menu_label.grid(row=3, column=1, columnspan=2, sticky=tk.W, pady=3) my_button = tk.Button(cmd_frame, text="do something") my_button.grid(row=1, column=2) my_button = ttk.Button(cmd_frame, text="do something") my_button.grid(row=2, column=2) # - - - - - - - - - - - - - - - - - - - - - # The Data entry frame entry_frame = ttk.LabelFrame(self.window, text="Data Entry", relief=tk.RIDGE) entry_frame.grid(row=2, column=1, sticky=tk.E + tk.W + tk.N + tk.S) entry_label = ttk.Label(entry_frame, text="ttk.Entry") entry_label.grid(row=1, column=1, sticky=tk.W + tk.N) text_label = ttk.Label(entry_frame, text="tk.Text") text_label.grid(row=2, column=1, sticky=tk.W + tk.N) scale_label = ttk.Label(entry_frame, text="tk.Scale") scale_label.grid(row=4, column=1, sticky=tk.W) scale_label2 = ttk.Label(entry_frame, text="ttk.Scale") scale_label2.grid(row=5, column=1, sticky=tk.W) my_entry = ttk.Entry(entry_frame, width=40) my_entry.grid(row=1, column=2, sticky=tk.W, pady=3) my_entry.insert(tk.END, "Test") my_text = tk.Text(entry_frame, height=5, width=30) my_text.grid(row=2, column=2) my_text.insert(tk.END, "An example of multi-line\ninput") my_spinbox = tk.Spinbox(entry_frame, from_=0, to=10, width=5, justify=tk.RIGHT) my_spinbox.grid(row=3, column=2, sticky=tk.W, pady=3) my_scale = tk.Scale(entry_frame, from_=0, to=100, orient=tk.HORIZONTAL, width=8, length=200) my_scale.grid(row=4, column=2, sticky=tk.W) my_scale = ttk.Scale(entry_frame, from_=0, to=100, orient=tk.HORIZONTAL, length=200) my_scale.grid(row=5, column=2, sticky=tk.W) # - - - - - - - - - - - - - - - - - - - - - # The Choices frame switch_frame = ttk.LabelFrame(self.window, text="Choices", relief=tk.RIDGE, padding=6) switch_frame.grid(row=2, column=2, padx=6, sticky=tk.E + tk.W + tk.N + tk.S) checkbox_label = ttk.Label(switch_frame, text="ttk.Checkbutton") checkbox_label.grid(row=1, rowspan=3, column=1, sticky=tk.W + tk.N) entry_label = ttk.Label(switch_frame, text="ttk.Radiobutton") entry_label.grid(row=4, rowspan=3, column=1, sticky=tk.W + tk.N) checkbutton1 = ttk.Checkbutton(switch_frame, text="On-off switch 1") checkbutton1.grid(row=1, column=2) checkbutton2 = ttk.Checkbutton(switch_frame, text="On-off switch 2") checkbutton2.grid(row=2, column=2) checkbutton3 = ttk.Checkbutton(switch_frame, text="On-off switch 3") checkbutton3.grid(row=3, column=2) self.radio_variable = tk.StringVar() self.radio_variable.set("0") radiobutton1 = ttk.Radiobutton(switch_frame, text="Choice One of three", variable=self.radio_variable, value="0") radiobutton2 = ttk.Radiobutton(switch_frame, text="Choice Two of three", variable=self.radio_variable, value="1") radiobutton3 = ttk.Radiobutton(switch_frame, text="Choice Three of three", variable=self.radio_variable, value="2") radiobutton1.grid(row=4, column=2, sticky=tk.W) radiobutton2.grid(row=5, column=2, sticky=tk.W) radiobutton3.grid(row=6, column=2, sticky=tk.W) # - - - - - - - - - - - - - - - - - - - - - # The Choosing from lists frame fromlist_frame = ttk.LabelFrame(self.window, text="Choosing from a list", relief=tk.RIDGE) fromlist_frame.grid(row=1, column=2, sticky=tk.E + tk.W + tk.N + tk.S, padx=6) listbox_label = tk.Label(fromlist_frame, text="tk.Listbox") listbox_label.grid(row=1, column=1, sticky=tk.W + tk.N) combobox_label = tk.Label(fromlist_frame, text="ttk.Combobox") combobox_label.grid(row=2, column=1, sticky=tk.W + tk.N) my_listbox = tk.Listbox(fromlist_frame, height=4) for item in ["one", "two", "three", "four"]: my_listbox.insert(tk.END, "Choice " + item) my_listbox.grid(row=1, column=2) self.combobox_value = tk.StringVar() my_combobox = ttk.Combobox(fromlist_frame, height=4, textvariable=self.combobox_value) my_combobox.grid(row=2, column=2) my_combobox['values'] = ("Choice one", "Choice two", "Choice three", "Choice four") my_combobox.current(0) # - - - - - - - - - - - - - - - - - - - - - # Menus menubar = tk.Menu(self.window) filemenu = tk.Menu(menubar, tearoff=0) #filemenu.add_command(label="Open", command=filedialog.askopenfilename) #filemenu.add_command(label="Save", command=filedialog.asksaveasfilename) filemenu.add_separator() filemenu.add_command(label="Exit", command=self.window.quit) menubar.add_cascade(label="File", menu=filemenu) self.window.config(menu=menubar) # - - - - - - - - - - - - - - - - - - - - - # Quit button in the lower right corner quit_button = ttk.Button(self.window, text="Quit", command=self.window.destroy) quit_button.grid(row=1, column=3)
def BuildPage ( self ): frame = MyLabelFrame(self, "JPEG Parameters", 0, 0) Label(frame,text="Quality:").grid(row=0,column=0,sticky='W'); self.Quality = ttk.Scale(frame,from_=1,to=100,orient='horizontal') self.Quality.grid(row=0,column=1,sticky='W',pady=5) self.Quality.set(JPEG.Quality) ToolTip(self.Quality,2000) self.QualityAmt = IntVar() self.QualityAmt.set(JPEG.Quality) l = ttk.Label(frame,textvariable=self.QualityAmt,style='DataLabel.TLabel') l.grid(row=0,column=2,sticky='W') ToolTip(l,2001) # NOW enable callback - else we get an error on self.QualityAmt self.Quality.config(command=self.QualityChanged) Label(frame,text="Restart:").grid(row=1,column=0,sticky='W'); l = Label(frame,text="Unclear what to do here!") l.grid(row=1,column=1,columnspan=2,sticky='W'); ToolTip(l,2010) f = ttk.Frame(frame) f.grid(row=2,column=0,columnspan=3,sticky='EW') Label(f,text="Thumbnail:").grid(row=0,column=0,sticky='W'); self.ThumbnailNone = MyBooleanVar(JPEG.Thumbnail == None) r = MyRadio(f,"None",True,self.ThumbnailNone,self.ThumbnailChanged, 0,1,'W',tip=2015) MyRadio(f,"Set size/quality",False,self.ThumbnailNone,self.ThumbnailChanged, 0,2,'W',tip=2020) self.ThumbnailEditFrame = ttk.Frame(f,padding=(15,0,0,0)) self.ThumbnailEditFrame.grid(row=1,column=0,columnspan=3,sticky='EW') Label(self.ThumbnailEditFrame,text="Width:").grid(row=0,column=0,sticky='E'); self.WidthCombo = Combobox(self.ThumbnailEditFrame,state='readonly',width=3) self.WidthCombo.bind('<<ComboboxSelected>>',self.SomethingChanged) self.WidthCombo.grid(row=0,column=1,sticky='W') self.WidthComboList = [16,32,48,64,80,96,112,128] self.WidthCombo['values'] = self.WidthComboList if JPEG.Thumbnail is None: self.WidthCombo.current(0) else: self.WidthCombo.current(int(JPEG.Thumbnail[0]/16) - 1) ToolTip(self.WidthCombo,2021) ttk.Label(self.ThumbnailEditFrame,text="Height:",padding=(5,0,0,0)).grid(row=0,column=2,sticky='E'); self.HeightCombo = Combobox(self.ThumbnailEditFrame,state='readonly',width=3) self.HeightCombo.bind('<<ComboboxSelected>>',self.SomethingChanged) self.HeightCombo.grid(row=0,column=3,sticky='W') self.HeightCombo['values'] = self.WidthComboList if JPEG.Thumbnail is None: self.HeightCombo.current(0) else: self.HeightCombo.current(int(JPEG.Thumbnail[1]/16) - 1) ToolTip(self.HeightCombo,2022) ttk.Label(self.ThumbnailEditFrame,text="Quality:",padding=(5,0,0,0)).grid(row=0,column=4,sticky='E'); self.QualityCombo = ttk.Combobox(self.ThumbnailEditFrame,state='readonly',width=3) self.QualityCombo.bind('<<ComboboxSelected>>',self.SomethingChanged) self.QualityCombo.grid(row=0,column=5,sticky='W') self.QualityComboList = [30,40,50,60,70,80,90] self.QualityCombo['values'] = self.QualityComboList if JPEG.Thumbnail is None: self.QualityCombo.current(0) else: self.QualityCombo.current(int((JPEG.Thumbnail[2]-30) / 10)) ToolTip(self.QualityCombo,2023) Label(f,text="Bayer:").grid(row=2,column=0,sticky='W'); self.Bayer = MyBooleanVar(JPEG.Bayer) MyRadio(f,"Off (default)",False,self.Bayer,self.SomethingChanged, 2,1,'W',tip=2030) MyRadio(f,"On",True,self.Bayer,self.SomethingChanged,2,2,'W', tip=2031) frame = MyLabelFrame(self, "EXIF Metadata", 1, 0) self.AddExifBoolean = MyBooleanVar(JPEG.IncludeEXIF) self.AddExifButton = ttk.Checkbutton(frame, text='Add EXIF metadata when saving photo', variable=self.AddExifBoolean, command=lambda e=None:self.SomethingChanged(e)) self.AddExifButton.grid(row=0,column=0,columnspan=2,sticky='W',padx=5) ToolTip(self.AddExifButton,msg=2100) Label(frame,text="Add a user comment to the EXIF metadata") \ .grid(row=1,column=0,sticky='W') self.AddCommentStr = MyStringVar(JPEG.UserComment) okCmd = (self.register(self.SomethingChanged),'%P') e = Entry(frame,textvariable=self.AddCommentStr,validate='key', validatecommand=okCmd) e.grid(row=2,column=0,columnspan=2,sticky='EW') ToolTip(e,msg=2110) self.ThumbnailChanged(None)
def setUp(self): support.root_deiconify() self.scale = ttk.Scale() self.scale.pack() self.scale.update()
def __init__(self, root): root.title("Regularization for Machine Learning") root.resizable(width=False, height=False) Main = ttk.Frame(root, padding=(3, 3, 12, 12)) #,width=600, height=600) f1 = ttk.Labelframe(Main, text='Input', borderwidth=1, relief="sunken", width=300, height=300, padding=(10, 10, 12, 12)) # f2 = ttk.Frame(Main, borderwidth=1, relief="sunken", width=300, height=400, padding=(10, 10, 12, 12)) self.f3 = ttk.Frame(Main, borderwidth=5, relief="sunken", width=300, height=400, padding=(1, 1, 1, 1)) f4 = ttk.Frame(Main, borderwidth=1, relief="sunken", width=300, height=300, padding=(3, 3, 3, 3)) f11 = ttk.Labelframe(f1, text='Task', borderwidth=1, relief="sunken", width=300, height=100, padding=(3, 3, 12, 12)) # f12 = ttk.Labelframe(f1, text='Dataset', borderwidth=1, relief="sunken", width=300, height=200, padding=(3, 3, 20, 20)) # f21 = ttk.Labelframe(f2, text='Filter', borderwidth=1, relief="sunken", width=300, height=50, padding=(3, 3, 12, 12)) f22 = ttk.Labelframe(f2, text='Kernal', borderwidth=1, relief="sunken", width=300, height=100, padding=(3, 3, 12, 12)) f23 = ttk.Labelframe(f2, text='Learning', borderwidth=1, relief="sunken", width=300, height=200, padding=(3, 3, 12, 12)) f41 = ttk.Labelframe(f4, text='Result', borderwidth=1, relief="sunken", width=400, height=70, padding=(3, 3, 1, 1)) self.f42 = ttk.Labelframe(f4, borderwidth=5, relief="sunken", width=400, height=220, padding=(0, 0, 0, 0)) Main.grid(column=0, row=0, sticky=(N, S, E, W)) f1.grid(column=0, row=0, columnspan=1, rowspan=1, sticky=(N, S, E, W)) f2.grid(column=1, row=0, columnspan=3, rowspan=2, sticky=(N, S, E, W)) self.f3.grid(column=0, row=1, columnspan=1, rowspan=2, sticky=(N, S, E, W)) f4.grid(column=1, row=2, columnspan=3, rowspan=1, sticky=(N, S, E, W)) f11.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f12.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f21.grid(column=0, row=0, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f22.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f23.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f41.grid(row=0, sticky=(N, S, E, W), pady=5) self.f42.grid(row=1, sticky=(N, S)) ###-------------------------------- F1------------------------------------ label1f1 = ttk.Label(f1, text='Input ') label2f1 = ttk.Label(f11, text='Task') label3f1 = ttk.Label(f12, text='Dataset') tFont = tkFont.Font(f12, family='Times', weight='bold') #, size=12 label4f1 = ttk.Label( f12, text='# Training Samples') #,style ="B.TLabel")#,font =tFont) label5f1 = ttk.Label(f12, text='# Test Samples') label6f1 = ttk.Label(f12, text='Wrong labels ratio[0-1]') labelfont = ('timesroman', 15, 'bold') self.task = IntVar() self.task.set(1) self.Clf = ttk.Radiobutton(f11, text='Claasification', variable=self.task, value=1, command=self.TaskSelF) self.Reg = ttk.Radiobutton(f11, text='Regression ', variable=self.task, value=0, command=self.TaskSelF, state='disabled') self.dt = StringVar() self.eData = ttk.Radiobutton(f12, text='Existing Dataset', variable=self.dt, value=1, command=self.seDataFun) self.sData = ttk.Radiobutton( f12, text='Simulation ', variable=self.dt, value=0, command=self.seDataFun) #, state='disabled') self.Browse = ttk.Button(f12, text="Browse", command=self.BrowseDataFun) #self.eDataO = StringVar() self.eDataG = ttk.Entry(f12, width=8) self.sDataG = ttk.Combobox(f12) #, textvariable = self.sDataO) self.sDataG['values'] = ('Moons', 'Gaussians', 'Linear', 'Sinusoidal', 'Spiral') #,'Toy') #MOONS, GAUSSIANS, LINEAR, SINUSOIDAL, SPIRAL self.sDataG.current(0) self.nTr = StringVar() self.nTs = StringVar() self.nE = StringVar() self.nTrain = ttk.Entry(f12, textvariable=self.nTr, width=7) self.nTest = ttk.Entry(f12, textvariable=self.nTs, width=7) self.nWL = ttk.Entry(f12, textvariable=self.nE, width=7) self.nTrain.insert(0, '100') self.nTest.insert(0, '100') self.nWL.insert(0, '0.0') self.LoadData = ttk.Button(f12, text="LoadData", command=self.LoadDataFun) ## --------------F1----------Grid-------------------------------- #F11 self.Clf.grid(column=0, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W)) self.Reg.grid(column=3, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W)) #F12 self.eData.grid(column=0, row=1, columnspan=2, rowspan=1, sticky=(N, S, E, W)) self.eDataG.grid(column=2, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) self.Browse.grid(column=3, row=1, columnspan=2, rowspan=1, sticky=(S, W), padx=10) self.sData.grid(column=0, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W)) self.sDataG.grid(column=2, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label4f1.grid(column=2, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label5f1.grid(column=2, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label6f1.grid(column=2, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W)) self.nTrain.grid(column=3, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) self.nTest.grid(column=3, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) self.nWL.grid(column=3, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) self.LoadData.grid(column=0, row=6, columnspan=1, rowspan=1, sticky=(N, S, E, W)) ###-------------------------------- F2------------------------------------ #Filter------ label1f2 = ttk.Label(f21, text='Filter') # DropDown self.ftrO = ttk.Combobox(f21, width=30) self.ftrO['values'] = ('Regularized Least Squares', 'nu-method', 'Truncated SVD', 'Spectral cut-off', 'Iterative Landweber') self.ftrO.current(0) self.ftrO.bind("<<ComboboxSelected>>", self.filtrUpdate) #Kernal------ label2f2 = ttk.Label(f22, text='Kernal') # DropDown self.krnlO = ttk.Combobox(f22) self.krnlO['values'] = ('Linear', 'Polynomial', 'Gaussian') self.krnlO.current(0) self.krnlO.bind("<<ComboboxSelected>>", self.kpRangeUpdate) #self.kparVar = StringVar() self.kParaO = ttk.Scale(f22, orient=HORIZONTAL, length=200) #, from_=0.0, to=100.0) self.kParaO['command'] = self.kParaSelFun self.kParaO['from_'] = 1.0 self.kParaO['to'] = 30.0 self.label3f2 = ttk.Label(f22, text='kpar : 0.0') self.aSigVar = IntVar() self.aSigmaO = ttk.Checkbutton(f22, text='AutoSigma', variable=self.aSigVar, command=self.aSigmaSelFun) ukpar = DoubleVar() self.ukparO = ttk.Entry(f22, width=8) #textvariable=ukpar, self.ukparO.insert(0, 0.0) label3f2 = ttk.Label(f23, text='Learning') self.tVar = IntVar() self.cKvcO = ttk.Checkbutton(f23, text='use KCV', variable=self.tVar, onvalue=1, offvalue=0, command=self.cKCVSelfun) self.fixedVO = ttk.Checkbutton(f23, text='Fixed Value', variable=self.tVar, onvalue=0, offvalue=1, command=self.cKCVSelfun) label31f2 = ttk.Label(f23, text='Split') label32f2 = ttk.Label(f23, text='# split') label33f2 = ttk.Label(f23, text='t min') label34f2 = ttk.Label(f23, text='t max') label35f2 = ttk.Label(f23, text='# of values') # DropDown1 #splitype = StringVar() self.splitO = ttk.Combobox(f23) #, textvariable = splitype) self.splitO['values'] = ('Sequential', 'Random') self.splitO.current(0) # DropDown2 self.vScaleO = ttk.Combobox(f23) self.vScaleO['values'] = ('Linear Space', 'Log Space') self.vScaleO.current(0) self.nSO = ttk.Entry(f23, width=4) self.tMnO = ttk.Entry(f23, width=4) self.tMxO = ttk.Entry(f23, width=4) self.nSvO = ttk.Entry(f23, width=4) self.fixVO = ttk.Entry(f23, width=4) self.nSO.insert(0, 5) self.tMnO.insert(0, 0.0) self.tMxO.insert(0, 1.0) self.nSvO.insert(0, 10) self.fixVO.insert(0, 1.3) ## --------------F2----------Grid-------------------------------- ##F21 self.ftrO.grid(column=0, row=0, columnspan=2, rowspan=1, sticky=(N, S, E, W), padx=10) ## F22 #Kernal------ # DropDown self.krnlO.grid(column=1, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.kParaO.grid(column=1, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.label3f2.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=5, pady=5) self.aSigmaO.grid(column=0, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W)) self.ukparO.grid(column=2, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) ## F23 self.cKvcO.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label31f2.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label32f2.grid(column=0, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label33f2.grid(column=0, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label34f2.grid(column=0, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label35f2.grid(column=0, row=6, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) # DropDown2 self.vScaleO.grid(column=0, row=7, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=20) self.fixedVO.grid(column=0, row=8, columnspan=1, rowspan=1, sticky=(N, S, E, W)) # DropDown1 self.splitO.grid(column=1, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W), pady=4) #Entry-- self.nSO.grid(column=2, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.tMnO.grid(column=2, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.tMxO.grid(column=2, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.nSvO.grid(column=2, row=6, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.fixVO.grid(column=1, row=8, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) ###-------------------------------- F3------------------------------------ ## Plot ###-------------------------------- F4------------------------------------ #F4 self.label1f41 = ttk.Label(f41, text='Training Error - ') self.label2f41 = ttk.Label(f41, text='Testing Error - ') self.label3f41 = ttk.Label(f41, text='Selected t - ') self.sep1f41 = ttk.Separator(f41, orient="vertical") ##--------------- F4---------Grid--------------------------- self.label1f41.grid(column=0, row=0, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.label2f41.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.sep1f41.grid(column=1, row=0, columnspan=1, rowspan=3, sticky='NS', padx=10, pady=0) self.label3f41.grid(column=2, row=0, columnspan=1, rowspan=2, sticky=(N, S, E, W), padx=10, pady=5) #######----------MAIN Frame---------------------------------------------------------- Plot = ttk.Button(Main, text="Plot Test/Train", command=self.PlotTrTsTT) RUN = ttk.Button(Main, text="RUN", command=self.runLEARN) CLOSE = ttk.Button(Main, text="Close", command=self.Qt) Reset = ttk.Button(Main, text="Reset", command=self.ResetSetting) Plot.grid(column=0, row=3) RUN.grid(column=1, row=3) Reset.grid(column=2, row=3) CLOSE.grid(column=3, row=3) #---------Default--Initial Setting variable/Items------------------- self.plotTrain = True self.trained = False self.Clf.invoke() self.sData.invoke() self.aSigmaO.state(['selected']) self.kParaO.state(['disabled']) self.fixedVO.state(['selected']) self.fixedVO.invoke() self.ftrO.current(0)
def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#d9d9d9' # X11 color: 'gray85' font12 = "-family Verdana -size 10 -weight bold -slant roman " \ "-underline 0 -overstrike 0" self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.', background=_bgcolor) self.style.configure('.', foreground=_fgcolor) self.style.configure('.', font="TkDefaultFont") self.style.map('.', background=[('selected', _compcolor), ('active', _ana2color)]) top.geometry("1200x750+347+157") top.title("Photo Enhancer") top.configure(background="#d9d9d9") #######Menu Bar######## #File self.menubar = Menu(top, bg='#ff0000', fg=_fgcolor) top.configure(menu=self.menubar) self.file = Menu(top, tearoff=0) self.menubar.add_cascade(menu=self.file, compound="left", font=( 'Purisa', 12, 'normal', 'roman', ), foreground="#000000", label="File") #Load Image from Computer self.file.add_command( activeforeground="#000000", command=lambda: functions.openClicked(root, self), font="TkMenuFont", foreground="#000000", label="Open File") #Load URL self.file.add_command( activeforeground="#000000", command=lambda: functions.importClicked(root, self), font="TkMenuFont", foreground="#000000", label="Load URL") self.file.add_separator( #background="#ffff00" ) #Save self.file.add_command( activeforeground="#000000", command=lambda: functions.saveClicked(root, self), font="TkMenuFont", foreground="#000000", label="Save") #Save As self.file.add_command( activeforeground="#000000", command=lambda: functions.saveasClicked(root, self), font="TkMenuFont", foreground="#000000", label="Save As") self.file.add_separator( #background="#ffff00" ) #Close Image self.file.add_command( activeforeground="#000000", command=lambda: functions.closeClicked(root, self), font="TkMenuFont", foreground="#000000", label="Close the Image") self.file.add_separator( #background="#ffff00" ) #Quit the Application self.file.add_command( activeforeground="#000000", #background="#ffff00", command=lambda: functions.quitClicked(root, self), compound="top", font="TkMenuFont", foreground="#000000", #image=self._img0, label="Quit") #Edit self.edit = Menu(top, tearoff=0) self.menubar.add_cascade(menu=self.edit, compound="left", font=( 'Purisa', 12, 'normal', 'roman', ), foreground="#000000", state="disabled", label="Edit") self.edit.add_command( activeforeground="#000000", command=lambda: functions.rotateClicked(root, self), font="TkMenuFont", foreground="#000000", label="Rotate") self.edit.add_command( activeforeground="#000000", command=lambda: functions.brightenClicked(root, self), font="TkMenuFont", foreground="#000000", label="Brighten") self.edit.add_command( activeforeground="#000000", command=lambda: functions.contrastClicked(root, self), font="TkMenuFont", foreground="#000000", label="Contrast") self.edit.add_command( activeforeground="#000000", command=lambda: functions.filterClicked(root, self), font="TkMenuFont", foreground="#000000", label="Filter") self.edit.add_command( activeforeground="#000000", command=lambda: functions.mirrorClicked(root, self), font="TkMenuFont", foreground="#000000", label="Mirror") self.edit.add_command( activeforeground="#000000", command=lambda: functions.cropClicked(root, self), font="TkMenuFont", foreground="#000000", label="Crop") self.edit.add_command( activeforeground="#000000", command=lambda: functions.blurClicked(root, self), font="TkMenuFont", foreground="#000000", label="Blur") self.edit.add_command( activeforeground="#000000", command=lambda: functions.sharpenClicked(root, self), font="TkMenuFont", foreground="#000000", label="Sharpen") self.help = Menu(top, tearoff=0) self.menubar.add_cascade(menu=self.help, compound="left", font=( 'Purisa', 12, 'normal', 'roman', ), foreground="#000000", label="Help") self.help.add_command( activeforeground="#000000", command=lambda: functions.helpClicked(root, self), font="TkMenuFont", foreground="#000000", label="About") #######Buttons######### self.TPanedwindow1 = ttk.Panedwindow(top, orient="horizontal") self.TPanedwindow1.place(relx=0.02, rely=0.01, relheight=0.96, relwidth=0.97) self.TPanedwindow1.configure(width=1165) self.toolPanel = ttk.Labelframe(width=200, text='') self.TPanedwindow1.add(self.toolPanel) self.displayPanel = ttk.Labelframe(text='') self.TPanedwindow1.add(self.displayPanel) self.__funcid0 = self.TPanedwindow1.bind('<Map>', self.__adjust_sash0) #Places the Editing Tools Title self.toolLabel = ttk.Label(self.toolPanel) self.toolLabel.place(relx=0.3, rely=0.07, height=29, width=96, y=-12) self.toolLabel.configure(background="#d9d9d9") self.toolLabel.configure(foreground="#000000") self.toolLabel.configure(font=font12) self.toolLabel.configure(relief=FLAT) self.toolLabel.configure(justify=CENTER) self.toolLabel.configure(text='''Editing Tools''') self.toolLabel.configure(width=96) #Places the Rotate Button self.rotateButton = ttk.Button(self.toolPanel) self.rotateButton.place(relx=0.26, rely=0.14, height=25, width=90, y=-12) self.rotateButton.configure( command=lambda: functions.rotateClicked(root, self)) self.rotateButton.configure(takefocus="") self.rotateButton.configure(text='''Rotate''') self.rotateButton.configure(state=DISABLED) #Clockwise Radio Button self.clockwiseRadiobutton = Radiobutton(self.toolPanel) self.clockwiseRadiobutton.place(relx=0.16, rely=0.18, relheight=0.03, relwidth=0.52, y=-12, h=12) self.clockwiseRadiobutton.configure(activebackground="#d9d9d9") self.clockwiseRadiobutton.configure(activeforeground="#000000") self.clockwiseRadiobutton.configure(background="#eaeaea") self.clockwiseRadiobutton.configure(foreground="#000000") self.clockwiseRadiobutton.configure(highlightbackground="#d9d9d9") self.clockwiseRadiobutton.configure(highlightcolor="black") self.clockwiseRadiobutton.configure(justify=LEFT) self.clockwiseRadiobutton.configure(text='''Clockwise''') self.clockwiseRadiobutton.configure(variable="rotate") self.clockwiseRadiobutton.configure(value="1") self.clockwiseRadiobutton.configure( command=lambda: functions.setRotateDirection(1)) #1 rotates clockwise self.clockwiseRadiobutton.configure(state=DISABLED) self.clockwiseRadiobutton.select() #Counterclockwise Radio Button self.counterwiseRadiobutton = Radiobutton(self.toolPanel) self.counterwiseRadiobutton.place(relx=0.16, rely=0.22, relheight=0.03, relwidth=0.61, y=-12, h=12) self.counterwiseRadiobutton.configure(activebackground="#d9d9d9") self.counterwiseRadiobutton.configure(activeforeground="#000000") self.counterwiseRadiobutton.configure(background="#eaeaea") self.counterwiseRadiobutton.configure(foreground="#000000") self.counterwiseRadiobutton.configure(highlightbackground="#d9d9d9") self.counterwiseRadiobutton.configure(highlightcolor="black") self.counterwiseRadiobutton.configure(justify=LEFT) self.counterwiseRadiobutton.configure(text='''Counterwise''') self.counterwiseRadiobutton.configure(variable="rotate") self.counterwiseRadiobutton.configure(value="-1") #-1 rotates counterclockwise self.counterwiseRadiobutton.configure( command=lambda: functions.setRotateDirection(-1)) self.counterwiseRadiobutton.configure(state=DISABLED) self.counterwiseRadiobutton.deselect() #Brightness Button self.brightnessButton = ttk.Button(self.toolPanel) self.brightnessButton.place(relx=0.26, rely=0.28, height=25, width=90, y=-12) self.brightnessButton.configure( command=lambda: functions.brightnessClicked(root, self)) self.brightnessButton.configure(takefocus="") self.brightnessButton.configure(text='''Brighten''') self.brightnessButton.configure(state=DISABLED) #Brightness Scale self.brightScale = ttk.Scale(self.toolPanel) self.brightScale.place(relx=0.25, rely=0.31, relwidth=0.5, relheight=0.0, height=26) self.brightScale.configure(from_="-255") self.brightScale.configure(to="255") self.brightScale.configure(value="0") #Scale ranges from -255 to 255 & it starts at 0 self.brightScale.configure( command=lambda x: functions.setBrightness(root, self)) #Contrast Button self.contrastButton = ttk.Button(self.toolPanel) self.contrastButton.place(relx=0.26, rely=0.38, height=25, width=90, y=-12) self.contrastButton.configure( command=lambda: functions.contrastClicked(root, self)) self.contrastButton.configure(takefocus="") self.contrastButton.configure(text='''Contrast''') self.contrastButton.configure(state=DISABLED) #Contrast Scale self.contrastScale = ttk.Scale(self.toolPanel) self.contrastScale.place(relx=0.25, rely=0.42, relwidth=0.5, relheight=0.0, height=26) self.contrastScale.configure(takefocus="") self.contrastScale.configure(from_="0.0") self.contrastScale.configure(to="10.0") self.contrastScale.configure(value="5.0") #scale ranges from 0 to 10 & starts at 5 self.contrastScale.configure( command=lambda x: functions.setContrast(root, self)) #Filter Button self.filterButton = ttk.Button(self.toolPanel) self.filterButton.place(relx=0.26, rely=0.50, height=25, width=90, y=-12) self.filterButton.configure(takefocus="") self.filterButton.configure(text='''Filter''') self.filterButton.configure(state=DISABLED) self.filterButton.configure( command=lambda: functions.filterClicked(root, self)) #Black and White Button self.bw = Radiobutton(self.toolPanel) self.bw.place(relx=0.26, rely=0.54, relheight=0.03, relwidth=0.36, y=-12, h=12) self.bw.configure(activebackground="#d9d9d9") self.bw.configure(activeforeground="#000000") self.bw.configure(background="#eaeaea") self.bw.configure(disabledforeground="#a3a3a3") self.bw.configure(foreground="#000000") self.bw.configure(highlightbackground="#d9d9d9") self.bw.configure(highlightcolor="black") self.bw.configure(justify=LEFT) self.bw.configure(text='''B&W''') self.bw.configure(variable="filter") self.bw.configure(value="1") self.bw.configure(width=70) self.bw.select() self.bw.configure( command=lambda: functions.setFilterOptions((1, 1, 1))) self.bw.configure(state=DISABLED) #Blue Filter self.red = Radiobutton(self.toolPanel) self.red.place(relx=0.26, rely=0.58, relheight=0.03, relwidth=0.36, y=-12, h=12) self.red.configure(activebackground="#d9d9d9") self.red.configure(activeforeground="#000000") self.red.configure(background="#eaeaea") self.red.configure(disabledforeground="#a3a3a3") self.red.configure(foreground="#000000") self.red.configure(highlightbackground="#d9d9d9") self.red.configure(highlightcolor="black") self.red.configure(justify=LEFT) self.red.configure(text='''Blue''') self.red.configure(variable="filter") self.red.configure(value="2") self.red.configure(width=70) self.red.deselect() self.red.configure( command=lambda: functions.setFilterOptions((0, 1, 1))) self.red.configure(state=DISABLED) #Green Filter self.blue = Radiobutton(self.toolPanel) self.blue.place(relx=0.26, rely=0.62, relheight=0.03, relwidth=0.38, y=-12, h=12) self.blue.configure(activebackground="#d9d9d9") self.blue.configure(activeforeground="#000000") self.blue.configure(background="#eaeaea") self.blue.configure(disabledforeground="#a3a3a3") self.blue.configure(foreground="#000000") self.blue.configure(highlightbackground="#d9d9d9") self.blue.configure(highlightcolor="black") self.blue.configure(justify=LEFT) self.blue.configure(text='''Green''') self.blue.configure(variable="filter") self.blue.configure(value="3") self.blue.configure(width=70) self.blue.deselect() self.blue.configure( command=lambda: functions.setFilterOptions((1, 1, 0))) self.blue.configure(state=DISABLED) #Red Filter self.green = Radiobutton(self.toolPanel) self.green.place(relx=0.26, rely=0.66, relheight=0.03, relwidth=0.36, y=-12, h=12) self.green.configure(activebackground="#d9d9d9") self.green.configure(activeforeground="#000000") self.green.configure(background="#eaeaea") self.green.configure(disabledforeground="#a3a3a3") self.green.configure(foreground="#000000") self.green.configure(highlightbackground="#d9d9d9") self.green.configure(highlightcolor="black") self.green.configure(justify=LEFT) self.green.configure(text='''Red''') self.green.configure(variable="filter") self.green.configure(value="4") self.green.configure(width=70) self.green.deselect() self.green.configure( command=lambda: functions.setFilterOptions((1, 0, 1))) self.green.configure(state=DISABLED) #Mirror Button self.mirrorButton = ttk.Button(self.toolPanel) self.mirrorButton.place(relx=0.26, rely=0.71, height=25, width=90, y=-12) self.mirrorButton.configure(takefocus="") self.mirrorButton.configure(text='''Mirror''') self.mirrorButton.configure( command=lambda: functions.mirrorClicked(root, self)) self.mirrorButton.configure(state=DISABLED) #Crop Button self.cropButton = ttk.Button(self.toolPanel) self.cropButton.place(relx=0.26, rely=0.77, height=25, width=90, y=-12) self.cropButton.configure(takefocus="") self.cropButton.configure(text='''Crop''') self.cropButton.configure(command=functions.cropClicked) self.cropButton.configure(state=DISABLED) #Blur Button self.blurButton = ttk.Button(self.toolPanel) self.blurButton.place(relx=0.26, rely=0.83, height=25, width=90, y=-12) self.blurButton.configure(takefocus="") self.blurButton.configure(text='''Blur''') self.blurButton.configure( command=lambda: functions.blurClicked(root, self)) self.blurButton.configure(state=DISABLED) #Sharpen Button self.sharpenButton = ttk.Button(self.toolPanel) self.sharpenButton.place(relx=0.26, rely=0.89, height=25, width=90, y=-12) self.sharpenButton.configure(takefocus="") self.sharpenButton.configure(text='''Sharpen''') self.sharpenButton.configure( command=lambda: functions.sharpenClicked(root, self)) self.sharpenButton.configure(state=DISABLED) #Draws the canvas for the image display self.imgCanvas = Canvas(self.displayPanel) self.imgCanvas.place(relx=0.0, rely=0.01, relheight=0.90, relwidth=0.99, y=-12, h=12) self.imgCanvas.configure(background="#d9d9d9") self.imgCanvas.configure(borderwidth="2") self.imgCanvas.configure(insertbackground="black") self.imgCanvas.configure(relief=RIDGE) self.imgCanvas.configure(selectbackground="#c4c4c4") self.imgCanvas.configure(selectforeground="black") self.imgCanvas.configure(width=955) root.bind( "<Button-1>", lambda event: functions.mousePressedWrapper(event, root, self)) root.bind("<B1-Motion>", lambda event: functions.mouseMovedWrapper(event, root, self)) root.bind( "<ButtonRelease-1>", lambda event: functions.mouseReleasedWrapper(event, root, self)) #Displays the image label for URL bar self.fileLabel = Label(self.displayPanel) self.fileLabel.place(relx=0.02, rely=0.95, height=27, width=60, y=-12) self.fileLabel.configure(background="#eaeaea") self.fileLabel.configure(disabledforeground="#a3a3a3") self.fileLabel.configure(foreground="#000000") self.fileLabel.configure(text='''Image:''') #White space to enter URL self.imageEntry = Entry(self.displayPanel) self.imageEntry.place(relx=0.09, rely=0.94, height=30, relwidth=0.75) self.imageEntry.configure(background="white") self.imageEntry.configure(disabledforeground="#a3a3a3") self.imageEntry.configure(font="TkFixedFont") self.imageEntry.configure(foreground="#000000") self.imageEntry.configure(insertbackground="black") READONLY = 'readonly' self.imageEntry.configure(state=READONLY) self.imageEntry.configure(width=694) #Button to load the URL self.loadButton = Button(self.displayPanel) self.loadButton.place(relx=0.85, rely=0.96, height=24, width=100, y=-12) self.loadButton.configure(activebackground="#d9d9d9") self.loadButton.configure(activeforeground="#000000") self.loadButton.configure(background="#d9d9d9") self.loadButton.configure(disabledforeground="#a3a3a3") self.loadButton.configure(foreground="#000000") self.loadButton.configure(highlightbackground="#d9d9d9") self.loadButton.configure(highlightcolor="black") self.loadButton.configure(pady="0") self.loadButton.configure(state=DISABLED) self.loadButton.configure(text='''Load Image''') self.loadButton.configure( command=lambda: functions.openURL(root, self))
def __init__(self, master=None): _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#d9d9d9' # X11 color: 'gray85' font10 = "-family {Courier New} -size 9 -weight normal -slant " \ "roman -underline 0 -overstrike 0" font12 = "-family Tahoma -size 9 -weight bold -slant roman " \ "-underline 0 -overstrike 0" self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.', background=_bgcolor) self.style.configure('.', foreground=_fgcolor) self.style.configure('.', font="TkDefaultFont") self.style.map('.', background=[('selected', _compcolor), ('active', _ana2color)]) master.configure(background="#d9d9d9") master.configure(highlightbackground="#d9d9d9") master.configure(highlightcolor="black") self.TLabelframe1 = ttk.Labelframe(master) self.TLabelframe1.place(relx=0.01, rely=0.03, relheight=0.2, relwidth=0.17) self.TLabelframe1.configure(text='''Serial connect''') self.TLabelframe1.configure(width=120) self.btn_connect = Button(self.TLabelframe1) self.btn_connect.place(relx=0.08, rely=0.21, height=22, width=65) self.btn_connect.configure(activebackground="#d9d9d9") self.btn_connect.configure(activeforeground="#000000") self.btn_connect.configure(background=_bgcolor) self.btn_connect.configure(command=rbgui1_support.do_connect_serial) self.btn_connect.configure(disabledforeground="#a3a3a3") self.btn_connect.configure(foreground="#000000") self.btn_connect.configure(highlightbackground="#d9d9d9") self.btn_connect.configure(highlightcolor="black") self.btn_connect.configure(pady="0") self.btn_connect.configure(text='''Connect''') self.txt_connect_indicator = Entry(self.TLabelframe1) self.txt_connect_indicator.place(relx=0.67, rely=0.27, relheight=0.25, relwidth=0.2) self.txt_connect_indicator.configure(background="white") self.txt_connect_indicator.configure(disabledforeground="#a3a3a3") self.txt_connect_indicator.configure(font="TkFixedFont") self.txt_connect_indicator.configure(foreground="#000000") self.txt_connect_indicator.configure(highlightbackground="#d9d9d9") self.txt_connect_indicator.configure(highlightcolor="black") self.txt_connect_indicator.configure(insertbackground="black") self.txt_connect_indicator.configure(selectbackground="#c4c4c4") self.txt_connect_indicator.configure(selectforeground="black") self.chk_Allow_motion = Checkbutton(self.TLabelframe1) self.chk_Allow_motion.place(relx=0.08, rely=0.67, relheight=0.29, relwidth=0.81) self.chk_Allow_motion.configure(activebackground="#d9d9d9") self.chk_Allow_motion.configure(activeforeground="#000000") self.chk_Allow_motion.configure(background=_bgcolor) self.chk_Allow_motion.configure( command=rbgui1_support.HandleForceToken) self.chk_Allow_motion.configure(disabledforeground="#a3a3a3") self.chk_Allow_motion.configure(foreground="#000000") self.chk_Allow_motion.configure(highlightbackground="#d9d9d9") self.chk_Allow_motion.configure(highlightcolor="black") self.chk_Allow_motion.configure(justify=LEFT) self.chk_Allow_motion.configure(text='''Allow Motion''') self.chk_Allow_motion.configure( variable=rbgui1_support.wvar.Force_Token_var) self.menubar = Menu(master, bg=_bgcolor, fg=_fgcolor) master.configure(menu=self.menubar) self.file = Menu(master, tearoff=0) self.menubar.add_cascade(menu=self.file, activebackground="#d9d9d9", activeforeground="#111111", accelerator="f", background="#d9d9d9", foreground="#000000", label="File") self.file.add_command(activebackground="#d9d9d9", activeforeground="#000000", background="#d9d9d9", foreground="#000000", label="Exit") self.settings = Menu(master, tearoff=0) self.menubar.add_cascade(menu=self.settings, activebackground="#d9d9d9", activeforeground="#111111", background="#d9d9d9", foreground="#000000", label="Settings") self.settings.add_command(activebackground="#d9d9d9", activeforeground="#000000", background="#d9d9d9", command=rbgui1_support.do_SerialPortConfig, foreground="#000000", label="Config Serial port") self.about = Menu(master, tearoff=0) self.menubar.add_cascade(menu=self.about, activebackground="#d9d9d9", activeforeground="#111111", accelerator="a", background="#d9d9d9", foreground="#000000", label="About") self.about.add_command(activebackground="#d9d9d9", activeforeground="#000000", background="#d9d9d9", command=rbgui1_support.do_about, foreground="#000000", label="Show About") self.TLabelframe2 = ttk.Labelframe(master) self.TLabelframe2.place(relx=0.01, rely=0.24, relheight=0.5, relwidth=0.36) self.TLabelframe2.configure(text='''Manual controls''') self.TLabelframe2.configure(width=250) self.ts_direction = ttk.Scale(self.TLabelframe2) self.ts_direction.place(relx=0.4, rely=0.54, relwidth=0.4, relheight=0.0, height=16) self.ts_direction.configure(command=rbgui1_support.do_new_direction) self.ts_direction.configure( variable=rbgui1_support.wvar.ts_direction_value) self.ts_direction.configure(from_="50") self.ts_direction.configure(to="-50") self.ts_direction.configure(takefocus="") self.Label1 = Label(self.TLabelframe2) self.Label1.place(relx=0.48, rely=0.43, height=19, width=48) self.Label1.configure(activebackground="#f9f9f9") self.Label1.configure(activeforeground="black") self.Label1.configure(background=_bgcolor) self.Label1.configure(disabledforeground="#a3a3a3") self.Label1.configure(foreground="#000000") self.Label1.configure(highlightbackground="#d9d9d9") self.Label1.configure(highlightcolor="black") self.Label1.configure(text='''Direction''') self.entry_setdirection = Entry(self.TLabelframe2) self.entry_setdirection.place(relx=0.6, rely=0.65, relheight=0.1, relwidth=0.26) self.entry_setdirection.configure(background="white") self.entry_setdirection.configure(disabledforeground="#a3a3a3") self.entry_setdirection.configure(font="TkFixedFont") self.entry_setdirection.configure(foreground="#000000") self.entry_setdirection.configure(highlightbackground="#d9d9d9") self.entry_setdirection.configure(highlightcolor="black") self.entry_setdirection.configure(insertbackground="black") self.entry_setdirection.configure(justify=RIGHT) self.entry_setdirection.configure(selectbackground="#c4c4c4") self.entry_setdirection.configure(selectforeground="black") self.entry_setdirection.configure( textvariable=rbgui1_support.wvar.gui_set_direction) self.entry_actdirection = Entry(self.TLabelframe2) self.entry_actdirection.place(relx=0.6, rely=0.76, relheight=0.1, relwidth=0.26) self.entry_actdirection.configure(background="white") self.entry_actdirection.configure(disabledforeground="#a3a3a3") self.entry_actdirection.configure(font="TkFixedFont") self.entry_actdirection.configure(foreground="#000000") self.entry_actdirection.configure(highlightbackground="#d9d9d9") self.entry_actdirection.configure(highlightcolor="black") self.entry_actdirection.configure(insertbackground="black") self.entry_actdirection.configure(justify=RIGHT) self.entry_actdirection.configure(selectbackground="#c4c4c4") self.entry_actdirection.configure(selectforeground="black") self.entry_actdirection.configure( textvariable=rbgui1_support.wvar.gui_act_direction) self.Label2 = Label(self.TLabelframe2) self.Label2.place(relx=0.4, rely=0.65, height=19, width=32) self.Label2.configure(activebackground="#f9f9f9") self.Label2.configure(activeforeground="black") self.Label2.configure(background=_bgcolor) self.Label2.configure(disabledforeground="#a3a3a3") self.Label2.configure(foreground="#000000") self.Label2.configure(highlightbackground="#d9d9d9") self.Label2.configure(highlightcolor="black") self.Label2.configure(text='''Set''') self.Label3 = Label(self.TLabelframe2) self.Label3.place(relx=0.4, rely=0.76, height=19, width=32) self.Label3.configure(activebackground="#f9f9f9") self.Label3.configure(activeforeground="black") self.Label3.configure(background=_bgcolor) self.Label3.configure(disabledforeground="#a3a3a3") self.Label3.configure(foreground="#000000") self.Label3.configure(highlightbackground="#d9d9d9") self.Label3.configure(highlightcolor="black") self.Label3.configure(text='''Act''') self.Label4 = Label(self.TLabelframe2) self.Label4.place(relx=0.04, rely=0.76, height=19, width=36) self.Label4.configure(activebackground="#f9f9f9") self.Label4.configure(activeforeground="black") self.Label4.configure(background=_bgcolor) self.Label4.configure(disabledforeground="#a3a3a3") self.Label4.configure(foreground="#000000") self.Label4.configure(highlightbackground="#d9d9d9") self.Label4.configure(highlightcolor="black") self.Label4.configure(text='''Speed''') self.entry_setspeed = Entry(self.TLabelframe2) self.entry_setspeed.place(relx=0.4, rely=0.05, relheight=0.1, relwidth=0.3) self.entry_setspeed.configure(background="white") self.entry_setspeed.configure(disabledforeground="#a3a3a3") self.entry_setspeed.configure(font=font10) self.entry_setspeed.configure(foreground="#000000") self.entry_setspeed.configure(highlightbackground="#d9d9d9") self.entry_setspeed.configure(highlightcolor="black") self.entry_setspeed.configure(insertbackground="black") self.entry_setspeed.configure(justify=RIGHT) self.entry_setspeed.configure(selectbackground="#c4c4c4") self.entry_setspeed.configure(selectforeground="black") self.entry_setspeed.configure( textvariable=rbgui1_support.wvar.gui_setspeed) self.Label5 = Label(self.TLabelframe2) self.Label5.place(relx=0.24, rely=0.05, height=19, width=32) self.Label5.configure(activebackground="#f9f9f9") self.Label5.configure(activeforeground="black") self.Label5.configure(background=_bgcolor) self.Label5.configure(disabledforeground="#a3a3a3") self.Label5.configure(foreground="#000000") self.Label5.configure(highlightbackground="#d9d9d9") self.Label5.configure(highlightcolor="black") self.Label5.configure(text='''Set''') self.entry_actspeed = Entry(self.TLabelframe2) self.entry_actspeed.place(relx=0.4, rely=0.16, relheight=0.1, relwidth=0.3) self.entry_actspeed.configure(background="white") self.entry_actspeed.configure(disabledforeground="#a3a3a3") self.entry_actspeed.configure(font="TkFixedFont") self.entry_actspeed.configure(foreground="#000000") self.entry_actspeed.configure(highlightbackground="#d9d9d9") self.entry_actspeed.configure(highlightcolor="black") self.entry_actspeed.configure(insertbackground="black") self.entry_actspeed.configure(justify=RIGHT) self.entry_actspeed.configure(selectbackground="#c4c4c4") self.entry_actspeed.configure(selectforeground="black") self.entry_actspeed.configure( textvariable=rbgui1_support.wvar.gui_actspeed) self.Label6 = Label(self.TLabelframe2) self.Label6.place(relx=0.22, rely=0.16, height=19, width=41) self.Label6.configure(activebackground="#f9f9f9") self.Label6.configure(activeforeground="black") self.Label6.configure(background=_bgcolor) self.Label6.configure(disabledforeground="#a3a3a3") self.Label6.configure(foreground="#000000") self.Label6.configure(highlightbackground="#d9d9d9") self.Label6.configure(highlightcolor="black") self.Label6.configure(text='''Act''') self.Label7 = Label(self.TLabelframe2) self.Label7.place(relx=0.4, rely=0.86, height=19, width=47) self.Label7.configure(activebackground="#f9f9f9") self.Label7.configure(activeforeground="black") self.Label7.configure(background=_bgcolor) self.Label7.configure(disabledforeground="#a3a3a3") self.Label7.configure(foreground="#000000") self.Label7.configure(highlightbackground="#d9d9d9") self.Label7.configure(highlightcolor="black") self.Label7.configure(text='''Rad/sec''') self.Label7.configure(width=47) self.entry_radpersec = Entry(self.TLabelframe2) self.entry_radpersec.place(relx=0.6, rely=0.86, relheight=0.1, relwidth=0.26) self.entry_radpersec.configure(background="white") self.entry_radpersec.configure(disabledforeground="#a3a3a3") self.entry_radpersec.configure(font="TkFixedFont") self.entry_radpersec.configure(foreground="#000000") self.entry_radpersec.configure(highlightbackground="#d9d9d9") self.entry_radpersec.configure(highlightcolor="black") self.entry_radpersec.configure(insertbackground="black") self.entry_radpersec.configure(justify=RIGHT) self.entry_radpersec.configure(selectbackground="#c4c4c4") self.entry_radpersec.configure(selectforeground="black") self.entry_radpersec.configure( textvariable=rbgui1_support.wvar.gui_radpersec) self.ts_speed = Scale(self.TLabelframe2) self.ts_speed.place(relx=0.04, rely=0.11, relwidth=0.0, relheight=0.57, width=40) self.ts_speed.configure(activebackground="#d9d9d9") self.ts_speed.configure(background=_bgcolor) self.ts_speed.configure(command=rbgui1_support.do_new_speed) self.ts_speed.configure(font="TkTextFont") self.ts_speed.configure(foreground="#000000") self.ts_speed.configure(from_="50.0") self.ts_speed.configure(highlightbackground="#d9d9d9") self.ts_speed.configure(highlightcolor="black") self.ts_speed.configure(to="-50.0") self.ts_speed.configure(troughcolor="#d9d9d9") self.ts_speed.configure(variable=rbgui1_support.wvar.ts_speed_value) self.ts_speed.configure(width=12) self.btn_center = Button(self.TLabelframe2) self.btn_center.place(relx=0.76, rely=0.27, height=31, width=52) self.btn_center.configure(activebackground="#d9d9d9") self.btn_center.configure(activeforeground="#000000") self.btn_center.configure(background=_bgcolor) self.btn_center.configure(command=rbgui1_support.Do_Center) self.btn_center.configure(disabledforeground="#a3a3a3") self.btn_center.configure(font=font12) self.btn_center.configure(foreground="#000000") self.btn_center.configure(highlightbackground="#d9d9d9") self.btn_center.configure(highlightcolor="black") self.btn_center.configure(pady="0") self.btn_center.configure(text='''Center''') self.btn_center.configure(width=52) self.btn_Stop = Button(self.TLabelframe2) self.btn_Stop.place(relx=0.2, rely=0.7, height=31, width=51) self.btn_Stop.configure(activebackground="#d9d9d9") self.btn_Stop.configure(activeforeground="#000000") self.btn_Stop.configure(background=_bgcolor) self.btn_Stop.configure(command=rbgui1_support.Do_Stop) self.btn_Stop.configure(disabledforeground="#a3a3a3") self.btn_Stop.configure(font=font12) self.btn_Stop.configure(foreground="#000000") self.btn_Stop.configure(highlightbackground="#d9d9d9") self.btn_Stop.configure(highlightcolor="black") self.btn_Stop.configure(pady="0") self.btn_Stop.configure(text='''Stop''') self.btn_Stop.configure(width=51) self.Label11 = Label(self.TLabelframe2) self.Label11.place(relx=0.24, rely=0.27, height=19, width=35) self.Label11.configure(background=_bgcolor) self.Label11.configure(disabledforeground="#a3a3a3") self.Label11.configure(foreground="#000000") self.Label11.configure(text='''M/Sec''') self.entry_actspeed_mpers = Entry(self.TLabelframe2) self.entry_actspeed_mpers.place(relx=0.4, rely=0.29, relheight=0.1, relwidth=0.3) self.entry_actspeed_mpers.configure(background="white") self.entry_actspeed_mpers.configure(disabledforeground="#a3a3a3") self.entry_actspeed_mpers.configure(font="TkFixedFont") self.entry_actspeed_mpers.configure(foreground="#000000") self.entry_actspeed_mpers.configure(highlightbackground="#d9d9d9") self.entry_actspeed_mpers.configure(highlightcolor="black") self.entry_actspeed_mpers.configure(insertbackground="black") self.entry_actspeed_mpers.configure(justify=RIGHT) self.entry_actspeed_mpers.configure(selectbackground="#c4c4c4") self.entry_actspeed_mpers.configure(selectforeground="black") self.entry_actspeed_mpers.configure( textvariable=rbgui1_support.wvar.gui_actspeedmpersec) self.entry_actspeed_mpers.configure(width=74) self.lf_status = ttk.Labelframe(master) self.lf_status.place(relx=0.38, rely=0.0, relheight=0.75, relwidth=0.2) self.lf_status.configure(text='''Status''') self.lf_status.configure(width=140) self.entry_status = Entry(self.lf_status) self.entry_status.place(relx=0.07, rely=0.07, relheight=0.07, relwidth=0.46) self.entry_status.configure(background="white") self.entry_status.configure(disabledforeground="#a3a3a3") self.entry_status.configure(font="TkFixedFont") self.entry_status.configure(foreground="#000000") self.entry_status.configure(highlightbackground="#d9d9d9") self.entry_status.configure(highlightcolor="black") self.entry_status.configure(insertbackground="black") self.entry_status.configure(selectbackground="#c4c4c4") self.entry_status.configure(selectforeground="black") self.entry_status.configure( textvariable=rbgui1_support.wvar.gui_statushex) self.Cs3 = Checkbutton(self.lf_status) self.Cs3.place(relx=0.0, rely=0.27, relheight=0.08, relwidth=0.54) self.Cs3.configure(activebackground="#d9d9d9") self.Cs3.configure(activeforeground="#000000") self.Cs3.configure(anchor=W) self.Cs3.configure(background=_bgcolor) self.Cs3.configure(disabledforeground="#a3a3a3") self.Cs3.configure(foreground="#000000") self.Cs3.configure(highlightbackground="#d9d9d9") self.Cs3.configure(highlightcolor="black") self.Cs3.configure(justify=LEFT) self.Cs3.configure(text='''3 Enabled''') self.Cs3.configure(variable=rbgui1_support.wvar.Cs3var) self.Cs15 = Checkbutton(self.lf_status) self.Cs15.place(relx=0.0, rely=0.89, relheight=0.08, relwidth=0.5) self.Cs15.configure(activebackground="#d9d9d9") self.Cs15.configure(activeforeground="#000000") self.Cs15.configure(anchor=W) self.Cs15.configure(background=_bgcolor) self.Cs15.configure(disabledforeground="#a3a3a3") self.Cs15.configure(foreground="#000000") self.Cs15.configure(highlightbackground="#d9d9d9") self.Cs15.configure(highlightcolor="black") self.Cs15.configure(justify=LEFT) self.Cs15.configure(text='''15 Alarm''') self.Cs15.configure(variable=rbgui1_support.wvar.Cs15var) self.Cs4 = Checkbutton(self.lf_status) self.Cs4.place(relx=0.0, rely=0.35, relheight=0.08, relwidth=0.55) self.Cs4.configure(activebackground="#d9d9d9") self.Cs4.configure(activeforeground="#000000") self.Cs4.configure(anchor=W) self.Cs4.configure(background=_bgcolor) self.Cs4.configure(disabledforeground="#a3a3a3") self.Cs4.configure(foreground="#000000") self.Cs4.configure(highlightbackground="#d9d9d9") self.Cs4.configure(highlightcolor="black") self.Cs4.configure(justify=LEFT) self.Cs4.configure(text='''4 Moveing''') self.Cs4.configure(variable=rbgui1_support.wvar.Cs4var) self.Cs5 = Checkbutton(self.lf_status) self.Cs5.place(relx=0.0, rely=0.42, relheight=0.08, relwidth=0.59) self.Cs5.configure(activebackground="#d9d9d9") self.Cs5.configure(activeforeground="#000000") self.Cs5.configure(anchor=W) self.Cs5.configure(background=_bgcolor) self.Cs5.configure(disabledforeground="#a3a3a3") self.Cs5.configure(foreground="#000000") self.Cs5.configure(highlightbackground="#d9d9d9") self.Cs5.configure(highlightcolor="black") self.Cs5.configure(justify=LEFT) self.Cs5.configure(text='''5 PC active''') self.Cs5.configure(variable=rbgui1_support.wvar.Cs5var) self.Cs7 = Checkbutton(self.lf_status) self.Cs7.place(relx=0.0, rely=0.49, relheight=0.08, relwidth=0.79) self.Cs7.configure(activebackground="#d9d9d9") self.Cs7.configure(activeforeground="#000000") self.Cs7.configure(anchor=W) self.Cs7.configure(background=_bgcolor) self.Cs7.configure(disabledforeground="#a3a3a3") self.Cs7.configure(foreground="#000000") self.Cs7.configure(highlightbackground="#d9d9d9") self.Cs7.configure(highlightcolor="black") self.Cs7.configure(justify=LEFT) self.Cs7.configure(text='''7 Joy stick active''') self.Cs7.configure(variable=rbgui1_support.wvar.Cs7var) self.Cs11 = Checkbutton(self.lf_status) self.Cs11.place(relx=0.0, rely=0.56, relheight=0.08, relwidth=0.76) self.Cs11.configure(activebackground="#d9d9d9") self.Cs11.configure(activeforeground="#000000") self.Cs11.configure(anchor=W) self.Cs11.configure(background=_bgcolor) self.Cs11.configure(disabledforeground="#a3a3a3") self.Cs11.configure(foreground="#000000") self.Cs11.configure(highlightbackground="#d9d9d9") self.Cs11.configure(highlightcolor="black") self.Cs11.configure(justify=LEFT) self.Cs11.configure(text='''11 Current error''') self.Cs11.configure(variable=rbgui1_support.wvar.Cs11var) self.Cs13 = Checkbutton(self.lf_status) self.Cs13.place(relx=0.0, rely=0.64, relheight=0.08, relwidth=0.68) self.Cs13.configure(activebackground="#d9d9d9") self.Cs13.configure(activeforeground="#000000") self.Cs13.configure(anchor=W) self.Cs13.configure(background=_bgcolor) self.Cs13.configure(disabledforeground="#a3a3a3") self.Cs13.configure(foreground="#000000") self.Cs13.configure(highlightbackground="#d9d9d9") self.Cs13.configure(highlightcolor="black") self.Cs13.configure(justify=LEFT) self.Cs13.configure(text='''13 Vin too low''') self.Cs13.configure(variable=rbgui1_support.wvar.Cs13var) self.Cs14 = Checkbutton(self.lf_status) self.Cs14.place(relx=0.0, rely=0.71, relheight=0.08, relwidth=0.74) self.Cs14.configure(activebackground="#d9d9d9") self.Cs14.configure(activeforeground="#000000") self.Cs14.configure(anchor=W) self.Cs14.configure(background=_bgcolor) self.Cs14.configure(disabledforeground="#a3a3a3") self.Cs14.configure(foreground="#000000") self.Cs14.configure(highlightbackground="#d9d9d9") self.Cs14.configure(highlightcolor="black") self.Cs14.configure(justify=LEFT) self.Cs14.configure(text='''14 3.3V too low''') self.Cs14.configure(variable=rbgui1_support.wvar.Cs14var) self.Cs0 = Checkbutton(self.lf_status) self.Cs0.place(relx=0.0, rely=0.2, relheight=0.08, relwidth=0.61) self.Cs0.configure(activebackground="#d9d9d9") self.Cs0.configure(activeforeground="#000000") self.Cs0.configure(anchor=W) self.Cs0.configure(background=_bgcolor) self.Cs0.configure(disabledforeground="#a3a3a3") self.Cs0.configure(foreground="#000000") self.Cs0.configure(highlightbackground="#d9d9d9") self.Cs0.configure(highlightcolor="black") self.Cs0.configure(justify=LEFT) self.Cs0.configure(text='''0 Watchdog''') self.Cs0.configure(variable=rbgui1_support.wvar.Cs0var) self.lf_voltages = LabelFrame(master) self.lf_voltages.place(relx=0.6, rely=0.0, relheight=0.75, relwidth=0.38) self.lf_voltages.configure(relief=GROOVE) self.lf_voltages.configure(foreground="black") self.lf_voltages.configure(text='''Voltage/Currents''') self.lf_voltages.configure(background=_bgcolor) self.lf_voltages.configure(highlightbackground="#d9d9d9") self.lf_voltages.configure(highlightcolor="black") self.lf_voltages.configure(width=270) self.lb_adc = Listbox(self.lf_voltages) self.lb_adc.place(relx=0.04, rely=0.07, relheight=0.78, relwidth=0.94) self.lb_adc.configure(background="white") self.lb_adc.configure(disabledforeground="#a3a3a3") self.lb_adc.configure(font="TkFixedFont") self.lb_adc.configure(foreground="#000000") self.lb_adc.configure(highlightbackground="#d9d9d9") self.lb_adc.configure(highlightcolor="black") self.lb_adc.configure(selectbackground="#c4c4c4") self.lb_adc.configure(selectforeground="black") self.btn_resetminmax = Button(self.lf_voltages) self.btn_resetminmax.place(relx=0.07, rely=0.87, height=21, width=121) self.btn_resetminmax.configure(activebackground="#d9d9d9") self.btn_resetminmax.configure(activeforeground="#000000") self.btn_resetminmax.configure(background=_bgcolor) self.btn_resetminmax.configure(command=rbgui1_support.do_resetminmax) self.btn_resetminmax.configure(disabledforeground="#a3a3a3") self.btn_resetminmax.configure(foreground="#000000") self.btn_resetminmax.configure(highlightbackground="#d9d9d9") self.btn_resetminmax.configure(highlightcolor="black") self.btn_resetminmax.configure(pady="0") self.btn_resetminmax.configure(text='''Reset Min Max''') self.Labelframe2 = LabelFrame(master) self.Labelframe2.place(relx=0.2, rely=0.03, relheight=0.2, relwidth=0.17) self.Labelframe2.configure(relief=GROOVE) self.Labelframe2.configure(foreground="black") self.Labelframe2.configure(text='''Enable/Reset''') self.Labelframe2.configure(background=_bgcolor) self.Labelframe2.configure(highlightbackground="#d9d9d9") self.Labelframe2.configure(highlightcolor="black") self.Labelframe2.configure(width=120) self.btn_enable = Button(self.Labelframe2) self.btn_enable.place(relx=0.08, rely=0.53, height=22, width=55) self.btn_enable.configure(activebackground="#d9d9d9") self.btn_enable.configure(activeforeground="#000000") self.btn_enable.configure(background=_bgcolor) self.btn_enable.configure(command=rbgui1_support.do_enable) self.btn_enable.configure(disabledforeground="#a3a3a3") self.btn_enable.configure(foreground="#000000") self.btn_enable.configure(highlightbackground="#d9d9d9") self.btn_enable.configure(highlightcolor="black") self.btn_enable.configure(pady="0") self.btn_enable.configure(state=DISABLED) self.btn_enable.configure(text='''Enable''') self.btn_reset = Button(self.Labelframe2) self.btn_reset.place(relx=0.08, rely=0.2, height=22, width=55) self.btn_reset.configure(activebackground="#d9d9d9") self.btn_reset.configure(activeforeground="#000000") self.btn_reset.configure(background=_bgcolor) self.btn_reset.configure(command=rbgui1_support.do_reset) self.btn_reset.configure(disabledforeground="#a3a3a3") self.btn_reset.configure(foreground="#000000") self.btn_reset.configure(highlightbackground="#d9d9d9") self.btn_reset.configure(highlightcolor="black") self.btn_reset.configure(pady="0") self.btn_reset.configure(text='''Reset''') self.entry_reset = Entry(self.Labelframe2) self.entry_reset.place(relx=0.67, rely=0.2, relheight=0.25, relwidth=0.2) self.entry_reset.configure(background="white") self.entry_reset.configure(disabledforeground="#a3a3a3") self.entry_reset.configure(font="TkFixedFont") self.entry_reset.configure(foreground="#000000") self.entry_reset.configure(highlightbackground="#d9d9d9") self.entry_reset.configure(highlightcolor="black") self.entry_reset.configure(insertbackground="black") self.entry_reset.configure(selectbackground="#c4c4c4") self.entry_reset.configure(selectforeground="black") self.entry_enable = Entry(self.Labelframe2) self.entry_enable.place(relx=0.67, rely=0.53, relheight=0.25, relwidth=0.2) self.entry_enable.configure(background="white") self.entry_enable.configure(disabledforeground="#a3a3a3") self.entry_enable.configure(font="TkFixedFont") self.entry_enable.configure(foreground="#000000") self.entry_enable.configure(highlightbackground="#d9d9d9") self.entry_enable.configure(highlightcolor="black") self.entry_enable.configure(insertbackground="black") self.entry_enable.configure(selectbackground="#c4c4c4") self.entry_enable.configure(selectforeground="black") self.Labelframe1 = LabelFrame(master) self.Labelframe1.place(relx=0.01, rely=0.76, relheight=0.2, relwidth=0.97) self.Labelframe1.configure(relief=GROOVE) self.Labelframe1.configure(foreground="black") self.Labelframe1.configure(text='''Info''') self.Labelframe1.configure(background=_bgcolor) self.Labelframe1.configure(highlightbackground="#d9d9d9") self.Labelframe1.configure(highlightcolor="black") self.Labelframe1.configure(width=680) self.entry_version = Entry(self.Labelframe1) self.entry_version.place(relx=0.01, rely=0.47, relheight=0.35, relwidth=0.31) self.entry_version.configure(background="white") self.entry_version.configure(disabledforeground="#a3a3a3") self.entry_version.configure(font="TkFixedFont") self.entry_version.configure(foreground="#000000") self.entry_version.configure(highlightbackground="#d9d9d9") self.entry_version.configure(highlightcolor="black") self.entry_version.configure(insertbackground="black") self.entry_version.configure(selectbackground="#c4c4c4") self.entry_version.configure(selectforeground="black") self.entry_version.configure( textvariable=rbgui1_support.wvar.gui_version) self.entry_counters = Entry(self.Labelframe1) self.entry_counters.place(relx=0.34, rely=0.47, relheight=0.35, relwidth=0.33) self.entry_counters.configure(background="white") self.entry_counters.configure(disabledforeground="#a3a3a3") self.entry_counters.configure(font="TkFixedFont") self.entry_counters.configure(foreground="#000000") self.entry_counters.configure(highlightbackground="#d9d9d9") self.entry_counters.configure(highlightcolor="black") self.entry_counters.configure(insertbackground="black") self.entry_counters.configure(justify=RIGHT) self.entry_counters.configure(selectbackground="#c4c4c4") self.entry_counters.configure(selectforeground="black") self.entry_counters.configure( textvariable=rbgui1_support.wvar.gui_counters) self.Entry11 = Entry(self.Labelframe1) self.Entry11.place(relx=0.68, rely=0.47, relheight=0.35, relwidth=0.27) self.Entry11.configure(background="white") self.Entry11.configure(disabledforeground="#a3a3a3") self.Entry11.configure(font="TkFixedFont") self.Entry11.configure(foreground="#000000") self.Entry11.configure(highlightbackground="#d9d9d9") self.Entry11.configure(highlightcolor="black") self.Entry11.configure(insertbackground="black") self.Entry11.configure(selectbackground="#c4c4c4") self.Entry11.configure(selectforeground="black") self.Entry11.configure(textvariable=rbgui1_support.wvar.gui_timers) self.Label8 = Label(self.Labelframe1) self.Label8.place(relx=0.06, rely=0.13, height=19, width=61) self.Label8.configure(activebackground="#f9f9f9") self.Label8.configure(activeforeground="black") self.Label8.configure(background=_bgcolor) self.Label8.configure(disabledforeground="#a3a3a3") self.Label8.configure(foreground="#000000") self.Label8.configure(highlightbackground="#d9d9d9") self.Label8.configure(highlightcolor="black") self.Label8.configure(text='''Version''') self.Label9 = Label(self.Labelframe1) self.Label9.place(relx=0.34, rely=0.13, height=19, width=108) self.Label9.configure(activebackground="#f9f9f9") self.Label9.configure(activeforeground="black") self.Label9.configure(background=_bgcolor) self.Label9.configure(disabledforeground="#a3a3a3") self.Label9.configure(foreground="#000000") self.Label9.configure(highlightbackground="#d9d9d9") self.Label9.configure(highlightcolor="black") self.Label9.configure(text='''Process counters''') self.Label10 = Label(self.Labelframe1) self.Label10.place(relx=0.68, rely=0.13, height=19, width=101) self.Label10.configure(activebackground="#f9f9f9") self.Label10.configure(activeforeground="black") self.Label10.configure(background=_bgcolor) self.Label10.configure(disabledforeground="#a3a3a3") self.Label10.configure(foreground="#000000") self.Label10.configure(highlightbackground="#d9d9d9") self.Label10.configure(highlightcolor="black") self.Label10.configure(text='''Process times''')
def setUp(self): self.scale = ttk.Scale() self.scale.pack() self.scale.update()
def create_button_frame(self): buttonframe = Frame(self.root) previcon = PhotoImage(file='icons/previous.gif') prevbtn = Button(buttonframe, image=previcon, borderwidth=0, padx=0, command=self.prev_track) prevbtn.image = previcon prevbtn.grid(row=0, column=0) self.balloon.bind(prevbtn, 'Previous Song') rewindicon = PhotoImage(file='icons/rewind.gif') rewindbtn = Button(buttonframe, image=rewindicon, borderwidth=0, padx=0, command=self.player.rewind) rewindbtn.image = rewindicon rewindbtn.grid(row=0, column=1) self.balloon.bind(rewindbtn, 'Go Back') self.playicon = PhotoImage(file='icons/play.gif') self.stopicon = PhotoImage(file='icons/stop.gif') self.playbtn = Button(buttonframe, text='play', image=self.playicon, borderwidth=0, padx=0, command=self.toggle_play_pause) self.playbtn.image = self.playicon self.playbtn.grid(row=0, column=2) self.balloon.bind(self.playbtn, 'Play Song') fast_fwdicon = PhotoImage(file='icons/fast_fwd.gif') fast_fwdbtn = Button(buttonframe, image=fast_fwdicon, borderwidth=0, padx=0, command=self.player.fast_fwd) fast_fwdbtn.image = fast_fwdicon fast_fwdbtn.grid(row=0, column=3) self.balloon.bind(fast_fwdbtn, 'Fast Forward') nexticon = PhotoImage(file='icons/next.gif') nextbtn = Button(buttonframe, image=nexticon, borderwidth=0, padx=0, command=self.next_track) nextbtn.image = nexticon nextbtn.grid(row=0, column=4) self.balloon.bind(nextbtn, 'Next Song') self.muteicon = PhotoImage(file='icons/mute.gif') self.unmuteicon = PhotoImage(file='icons/unmute.gif') self.mutebtn = Button(buttonframe, text='unmute', image=self.unmuteicon, borderwidth=0, padx=0, command=self.toggle_mute) self.mutebtn.image = self.unmuteicon self.mutebtn.grid(row=0, column=5) self.balloon.bind(self.mutebtn, 'Mute/Unmute') self.volscale = ttk.Scale(buttonframe, from_=0.0, to=1.0, value=0.6, command=self.vol_update) self.volscale.grid(row=0, column=6, padx=5) buttonframe.grid(row=1, padx=4, pady=5, sticky=W)
def BuildPage(self): #### TODO: Add Rotation. Cleanup and organize controls # Add handling of Image Effect Params #----------- Select port for image captures ------------ f1 = MyLabelFrame(self, 'Select port for image captures', 0, 0, span=2) self.UseVidPort = MyBooleanVar(False) self.UseRadio = MyRadio(f1, 'Use Still Port', False, self.UseVidPort, self.UseVideoPort, 0, 0, 'W', tip=100) MyRadio(f1, 'Use Video Port', True, self.UseVidPort, self.UseVideoPort, 0, 1, 'W', tip=101) f2 = ttk.Frame(f1) # Sub frame f2.grid(row=1, column=0, columnspan=4, sticky='NSEW') self.VideoDenoise = MyBooleanVar(True) b = ttk.Checkbutton(f2, text='Video denoise', variable=self.VideoDenoise, command=self.VideoDenoiseChecked) b.grid(row=1, column=0, sticky='NW', padx=5) ToolTip(b, msg=103) self.VideoStab = MyBooleanVar(False) b = ttk.Checkbutton(f2, text='Video stabilization', variable=self.VideoStab, command=self.VideoStabChecked) b.grid(row=1, column=1, sticky='NW') ToolTip(b, msg=105) self.ImageDenoise = MyBooleanVar(True) b = ttk.Checkbutton(f2, text='Image denoise', variable=self.ImageDenoise, command=self.ImageDenoiseChecked) b.grid(row=1, column=2, sticky='NW', padx=10) ToolTip(b, msg=104) #--------------- Picture/Video Capture Size --------------- f = MyLabelFrame(self, 'Picture/Video capture size in pixels', 1, 0) #f.columnconfigure(0,weight=1) f1 = ttk.Frame(f) # Sub frames to frame f f1.grid(row=1, column=0, sticky='NSEW') f1.columnconfigure(1, weight=1) self.UseFixedResolutions = BooleanVar() self.UseFixedResolutions.set(True) self.UseFixedResRadio = ttk.Radiobutton( f1, text='Use fixed:', variable=self.UseFixedResolutions, value=True, command=self.UseFixedResRadios, padding=(5, 5, 5, 5)) ToolTip(self.UseFixedResRadio, 120) self.UseFixedResRadio.grid(row=0, column=0, sticky='NW') self.FixedResolutionsCombo = Combobox(f1, state='readonly', width=25) self.FixedResolutionsCombo.bind('<<ComboboxSelected>>', self.FixedResolutionChanged) self.FixedResolutionsCombo.grid(row=0, column=1, columnspan=3, sticky='W') ToolTip(self.FixedResolutionsCombo, 121) #------------ Capture Width and Height ---------------- # OrderedDict is used to ensure the keys stay in the same order as # entered. I want the combobox to display in this order #### TODO: Must check resolution and framerate and disable the Video # button if we exceed limits of the modes # Framerate 1-30 fps up to 1920x1080 16:9 aspect ratio # Framerate 1-15 fps up to 2592 x 1944 4:3 aspect ratio # Framerate 0.1666 to 1 fps up to 2592 x 1944 4:3 aspect ratio # Framerate 1-42 fps up t0 1296 x 972 4:3 aspect ratio # Framerate 1-49 fps up to 1296 x 730 16:9 aspect ratio # Framerate 42.1 - 60 fps to 640 x 480 4:3 aspect ratio # Framerate 60.1 - 90 fps to 640 x 480 4:3 aspect ratio self.StandardResolutions = OrderedDict([ \ ('CGA', (320,200)), ('QVGA', (320,240)), ('VGA', (640,480)), ('PAL', (768,576)), ('480p', (720,480)), ('576p', (720,576)), ('WVGA', (800,480)), ('SVGA', (800,600)), ('FWVGA', (854,480)), ('WSVGA', (1024,600)), ('XGA', (1024,768)), ('HD 720', (1280,720)), ('WXGA_1', (1280,768)), ('WXGA_2', (1280,800)), ('SXGA', (1280,1024)), ('SXGA+', (1400,1050)), ('UXGA', (1600,1200)), ('WSXGA+', (1680,1050)), ('HD 1080', (1920,1080)), ('WUXGA', (1920,1200)), ('2K', (2048,1080)), ('QXGA', (2048, 1536)), ('WQXGA', (2560,1600)), ('MAX Resolution', (2592,1944)), ]) vals = [] for key in self.StandardResolutions.keys(): vals.append('%s: (%dx%d)' % ( key, # Tabs not working?!! self.StandardResolutions[key][0], self.StandardResolutions[key][1])) self.FixedResolutionsCombo['values'] = vals self.FixedResolutionsCombo.current(10) f2 = ttk.Frame(f) # subframe to frame f f2.grid(row=2, column=0, sticky='NSEW') f2.columnconfigure(2, weight=1) f2.columnconfigure(4, weight=1) b2 = ttk.Radiobutton(f2, text='Roll your own:', variable=self.UseFixedResolutions, value=False, command=self.UseFixedResRadios, padding=(5, 5, 5, 5)) b2.grid(row=1, column=0, sticky='NW') ToolTip(b2, 122) Label(f2, text="Width:", anchor=E).grid(column=1, row=1, sticky='E', ipadx=3, ipady=3) Widths = [] for i in range(1, 82): Widths.append(32 * i) # Widths can be in 32 byte increments self.cb = MyComboBox(f2, Widths, current=10, callback=self.ResolutionChanged, width=5, row=1, col=2, sticky='W', state='disabled', tip=123) Label(f2, text="Height:", anchor=E).grid(column=3, row=1, sticky='W', ipadx=5, ipady=3) Heights = [] for i in range(1, 123): Heights.append(16 * i) # heights in 16 byte increments self.cb1 = MyComboBox(f2, Heights, current=10, callback=self.ResolutionChanged, width=5, row=1, col=4, sticky='W', state='disabled', tip=124) ttk.Label(f2, text='Actual:').grid(row=2, column=1, sticky='E') self.WidthLabel = ttk.Label(f2, style='DataLabel.TLabel') self.WidthLabel.grid(row=2, column=2, sticky='W') ToolTip(self.WidthLabel, 125) ttk.Label(f2, text='Actual:').grid(row=2, column=3, sticky='E') self.HeightLabel = ttk.Label(f2, style='DataLabel.TLabel') self.HeightLabel.grid(row=2, column=4, sticky='W') ToolTip(self.HeightLabel, 126) Separator(f, orient=HORIZONTAL).grid(pady=5, row=3, column=0, columnspan=4, sticky='EW') #--------------- Zoom Region Before ---------------- f4 = MyLabelFrame( f, 'Zoom region of interest before taking ' + 'picture/video', 4, 0) #f4.columnconfigure(1,weight=1) #f4.columnconfigure(3,weight=1) Label(f4, text='X:').grid(row=0, column=0, sticky='E') self.Xzoom = ttk.Scale(f4, from_=0.0, to=0.94, orient='horizontal') self.Xzoom.grid(row=0, column=1, sticky='W', padx=5, pady=3) self.Xzoom.set(0.0) ToolTip(self.Xzoom, 130) Label(f4, text='Y:').grid(row=0, column=2, sticky='E') self.Yzoom = ttk.Scale(f4, from_=0.0, to=0.94, orient='horizontal') self.Yzoom.grid(row=0, column=3, sticky='W', padx=5, pady=3) self.Yzoom.set(0.0) ToolTip(self.Yzoom, 131) Label(f4, text='Width:').grid(row=1, column=0, sticky='E') self.Widthzoom = ttk.Scale(f4, from_=0.05, to=1.0, orient='horizontal') self.Widthzoom.grid(row=1, column=1, sticky='W', padx=5, pady=3) self.Widthzoom.set(1.0) ToolTip(self.Widthzoom, 132) Label(f4, text='Height:').grid(row=1, column=2, sticky='E') self.Heightzoom = ttk.Scale(f4, from_=0.05, to=1.0, orient='horizontal') self.Heightzoom.grid(row=1, column=3, sticky='W', padx=5, pady=3) self.Heightzoom.set(1.0) ToolTip(self.Heightzoom, 133) # WLW THIS IS A PROBLEM image = PIL.Image.open('Assets/reset.png') #.resize((16,16)) self.resetImage = GetPhotoImage(image.resize((16, 16))) self.ResetZoomButton = ttk.Button(f4, image=self.resetImage, command=self.ZoomReset) self.ResetZoomButton.grid(row=0, column=4, rowspan=2, sticky='W') ToolTip(self.ResetZoomButton, 134) self.Xzoom.config(command=lambda newval, widget=self.Xzoom: self.Zoom( newval, widget)) self.Yzoom.config(command=lambda newval, widget=self.Yzoom: self.Zoom( newval, widget)) self.Widthzoom.config(command=lambda newval, widget=self.Widthzoom: self.Zoom(newval, widget)) self.Heightzoom.config(command=lambda newval, widget=self.Heightzoom: self.Zoom(newval, widget)) Separator(f, orient=HORIZONTAL).grid(pady=5, row=5, column=0, columnspan=3, sticky='EW') #--------------- Resize Image After ---------------- f4 = MyLabelFrame(f, 'Resize image after taking picture/video', 6, 0) #f4.columnconfigure(3,weight=1) #f4.columnconfigure(5,weight=1) b = MyBooleanVar(False) self.ResizeAfterNone = MyRadio(f4, 'None (Default)', False, b, self.AllowImageResizeAfter, 0, 0, 'W', pad=(0, 5, 0, 5), tip=140) MyRadio(f4, 'Resize', True, b, self.AllowImageResizeAfter, 0, 1, 'W', pad=(5, 5, 0, 5), tip=141) Label(f4, text="Width:", anchor=E).grid(column=2, row=0, sticky='E', ipadx=3, ipady=3) self.resizeWidthAfterCombo = MyComboBox( f4, Widths, current=10, callback=self.ResizeAfterChanged, width=5, row=0, col=3, sticky='W', state='disabled', tip=142) Label(f4, text="Height:", anchor=E).grid(column=4, row=0, sticky='W', ipadx=5, ipady=3) self.resizeHeightAfterCombo = MyComboBox( f4, Heights, current=10, callback=self.ResizeAfterChanged, width=5, row=0, col=5, sticky='W', state='disabled', tip=143) self.resizeAfter = None #--------------- Quick Adjustments ---------------- f = MyLabelFrame(self, 'Quick adjustments', 2, 0) #f.columnconfigure(2,weight=1) #-Brightness self.brightLabel, self.brightness, val = \ self.SetupLabelCombo(f,'Brightness:',0,0,0, 100, self.CameraBrightnessChanged, self.camera.brightness ) self.CameraBrightnessChanged(val) ToolTip(self.brightness, msg=150) #-Contrast self.contrastLabel, self.contrast, val = \ self.SetupLabelCombo(f,'Contrast:',0,3,-100, 100, self.ContrastChanged, self.camera.contrast ) self.ContrastChanged(val) ToolTip(self.contrast, msg=151) #-Saturation self.saturationLabel, self.saturation, val = \ self.SetupLabelCombo(f,'Saturation:',1,0,-100, 100, self.SaturationChanged, self.camera.saturation, label='Sat' ) self.SaturationChanged(val) ToolTip(self.saturation, msg=152) #-Sharpness self.sharpnessLabel, self.sharpness, val = \ self.SetupLabelCombo(f,'Sharpness:',1,3,-100, 100, self.SharpnessChanged, self.camera.sharpness ) self.SharpnessChanged(val) ToolTip(self.sharpness, msg=153) #-Reset #self.ResetGeneralButton = Button(f,image=self.resetImage,width=5, #command=self.ResetGeneralSliders) #self.ResetGeneralButton.grid(row=4,column=2,sticky='W',padx=5) #ToolTip(self.ResetGeneralButton,msg=154) #--------------- Image Effects ---------------- f = MyLabelFrame(self, 'Preprogrammed image effects', 3, 0) #f.columnconfigure(2,weight=1) v = MyBooleanVar(False) self.NoEffectsRadio = MyRadio(f, 'None (Default)', False, v, self.EffectsChecked, 0, 0, 'W', tip=160) MyRadio(f, 'Select effect:', True, v, self.EffectsChecked, 0, 1, 'W', tip=161) self.effects = Combobox(f, height=15, width=10, state='readonly') #,width=15) self.effects.grid(row=0, column=2, sticky='W') effects = list(self.camera.IMAGE_EFFECTS.keys()) # python 3 workaround effects.remove('none') effects.sort( ) #cmp=lambda x,y: cmp(x.lower(),y.lower())) # not python 3 self.effects['values'] = effects self.effects.current(0) self.effects.bind('<<ComboboxSelected>>', self.EffectsChanged) ToolTip(self.effects, msg=162) self.ModParams = ttk.Button(f, text='Params...', command=self.ModifyEffectsParamsPressed, underline=0, padding=(5, 3, 5, 3), width=8) self.ModParams.grid(row=0, column=3, sticky=EW, padx=5) ToolTip(self.ModParams, msg=163) self.EffectsChecked(False) ''' Add additional controls if JPG is selected Certain file formats accept additional options which can be specified as keyword arguments. Currently, only the 'jpeg' encoder accepts additional options, which are: quality - Defines the quality of the JPEG encoder as an integer ranging from 1 to 100. Defaults to 85. Please note that JPEG quality is not a percentage and definitions of quality vary widely. restart - Defines the restart interval for the JPEG encoder as a number of JPEG MCUs. The actual restart interval used will be a multiple of the number of MCUs per row in the resulting image. thumbnail - Defines the size and quality of the thumbnail to embed in the Exif metadata. Specifying None disables thumbnail generation. Otherwise, specify a tuple of (width, height, quality). Defaults to (64, 48, 35). bayer - If True, the raw bayer data from the camera’s sensor is included in the Exif metadata. ''' #--------------- Flash Mode --------------- f = MyLabelFrame(self, 'LED and Flash mode', 4, 0, span=4) #f.columnconfigure(3,weight=1) self.LedOn = MyBooleanVar(True) self.LedButton = ttk.Checkbutton(f, text='Led On (via GPIO pins)', variable=self.LedOn, command=self.LedOnChecked) self.LedButton.grid(row=0, column=0, sticky='NW', pady=5, columnspan=2) ToolTip(self.LedButton, msg=102) Label(f, text='Flash Mode:').grid(row=1, column=0, sticky='W') b = MyStringVar('off') self.FlashModeOffRadio = MyRadio(f, 'Off (Default)', 'off', b, self.FlashModeButton, 1, 1, 'W', tip=180) MyRadio(f, 'Auto', 'auto', b, self.FlashModeButton, 1, 2, 'W', tip=181) MyRadio(f, 'Select:', 'set', b, self.FlashModeButton, 1, 3, 'W', tip=182) # Use invoke() on radio button to force a command self.FlashModeCombo = Combobox(f, state='readonly', width=10) self.FlashModeCombo.grid(row=1, column=4, sticky='W') self.FlashModeCombo.bind('<<ComboboxSelected>>', self.FlashModeChanged) modes = list(self.camera.FLASH_MODES.keys()) modes.remove('off') # these two are handled by radio buttons modes.remove('auto') modes.sort() #cmp=lambda x,y: cmp(x.lower(),y.lower())) self.FlashModeCombo['values'] = modes self.FlashModeCombo.current(0) self.FlashModeCombo.config(state='disabled') ToolTip(self.FlashModeCombo, 183) self.FixedResolutionChanged(None) #----- Autofocus--- f = MyLabelFrame(self, 'Autofocus', 5, 0, span=4) v = MyBooleanVar(False) self.NoFocusRadio = MyRadio(f, 'None (Default)', False, v, self.FocusChecked, 0, 0, 'W', tip=135) MyRadio(f, 'Autofocus', 'auto', v, self.FocusChecked, 0, 1, 'W', tip=135) MyRadio(f, 'Manual Focus', 'manual', v, self.FocusChecked, 0, 2, 'W', tip=136) self.FocusParamText = MyStringVar("500") okCmdFocus = (self.register(self.ValidateFixedFocusRange), '%P') self.FocusParam = Entry(f, width=6, validate='all', validatecommand=okCmdFocus, textvariable=self.FocusParamText, state='disabled') self.FocusParam.grid(row=1, column=6, rowspan=1, sticky='W') ToolTip(self.FocusParam, 136)