def __init__(self, parent, *args, **kwargs): Tkinter.Frame.__init__(self, parent, *args, **kwargs) self.title = Tkinter.Label(master=self, text="muse231") self.title.pack(side=Tkinter.TOP) #self.img=Tkinter.PhotoImage(file="pictures/muse231.gif") #Tkinter.Label(master=self, image=self.img).pack(side=Tkinter.LEFT) self.valframe = Tkinter.Frame(master=self, relief=Tkinter.RAISED, borderwidth=1) self.valframe.pack(side=Tkinter.TOP) Tkinter.Label(master=self.valframe, text="Measurement Data").pack(side=Tkinter.TOP) self.sht_t = Tkinter.DoubleVar(value=25.0) ValField(master=self.valframe, name="SHT T", unit="degC", val=self.sht_t).pack(side=Tkinter.BOTTOM) self.sht_rh = Tkinter.DoubleVar(value=0.5) ValField(master=self.valframe, name="SHT RH", unit="vH", val=self.sht_rh).pack(side=Tkinter.BOTTOM) self.vmcu = Tkinter.DoubleVar(value=2.85) ValField(master=self.valframe, name="VMCU", unit="mV", val=self.vmcu).pack(side=Tkinter.BOTTOM) self.cfgframe = Tkinter.Frame(master=self, relief=Tkinter.RAISED, borderwidth=1) self.cfgframe.pack(side=Tkinter.TOP) Tkinter.Label(master=self.cfgframe, text="Configuration").pack(side=Tkinter.TOP) self.cfg_accenable = Tkinter.BooleanVar() Tkinter.Checkbutton(master=self.cfgframe, text="ACC enable", variable=self.cfg_accenable).pack(side=Tkinter.TOP) self.cfg_shtenable = Tkinter.BooleanVar() Tkinter.Checkbutton(master=self.cfgframe, text="SHT21 enable", variable=self.cfg_shtenable).pack(side=Tkinter.TOP) self.cfg_blink = Tkinter.BooleanVar() Tkinter.Checkbutton(master=self.cfgframe, text="Blink on sample", variable=self.cfg_blink).pack(side=Tkinter.TOP) rates = [0.1, 1.0, 8.0, 60.0] self.cfg_samplerate = Tkinter.DoubleVar() Tkinter.Label(master=self.cfgframe, text='Sample Rate [Hz]').pack(side=Tkinter.TOP) cb = Tix.ComboBox(master=self.cfgframe, variable=self.cfg_samplerate) cb.pack(side=Tkinter.TOP) bal = Tix.Balloon(self.cfgframe) bal.bind_widget(cb, balloonmsg="Sample rate of measurement") [cb.insert(Tix.END, '%.2f' % (1 / i)) for i in rates]
def main(): global demo, root progname = sys.argv[0] dirname = os.path.dirname(progname) if dirname and dirname != os.curdir: demo.dir = dirname index = -1 for i in range(len(sys.path)): p = sys.path[i] if p in ("", os.curdir): index = i if index >= 0: sys.path[index] = dirname else: sys.path.insert(0, dirname) else: demo.dir = os.getcwd() sys.path.insert(0, demo.dir+'/samples') root.withdraw() root = Tix.Toplevel() root.title('Tix Widget Demonstration') root.geometry('780x570+50+50') demo.balloon = Tix.Balloon(root) frame1 = MkMainMenu(root) frame2 = MkMainNotebook(root) frame3 = MkMainStatus(root) frame1.pack(side=Tix.TOP, fill=Tix.X) frame3.pack(side=Tix.BOTTOM, fill=Tix.X) frame2.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=4, pady=4) demo.balloon['statusbar'] = demo.statusbar root.mainloop()
def __init__(self, w): self.root = w self.exit = -1 z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1) status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1) # Create two mysterious widgets that need balloon help button1 = Tix.Button(w, text='Something Unexpected', command=self.quitcmd) button2 = Tix.Button(w, text='Something Else Unexpected') button2['command'] = lambda w=button2: w.destroy() button1.pack(side=Tix.TOP, expand=1) button2.pack(side=Tix.TOP, expand=1) # Create the balloon widget and associate it with the widgets that we want # to provide tips for: b = Tix.Balloon(w, statusbar=status) b.bind_widget(button1, balloonmsg='Close Window', statusmsg='Press this button to close this window') b.bind_widget(button2, balloonmsg='Self-destruct button', statusmsg='Press this button and it will destroy itself')
def __create_widgets(self): self.__scrolltext_source = Tix.ScrolledText( self, scrollbar="both", width=300, height=300, ) self.__text_source = self.__scrolltext_source.subwidget("text") self.__text_source.config( state='disabled', spacing1=2, ) self.__scrolltext_source.grid(sticky="nesw") self.__text_source.tag_config( "a", background="#4169E1", borderwidth=3, relief="raised", rmargin=10, ) # 下面是两种气球方案,一个是Tix.Balloon,一个是自定义 self.__balloon = Tix.Balloon( self.__text_source, state='balloon', ) self.__text_source.bind('<Motion>', self.__show_balloon)
def build(self): root = self.root z = root.winfo_toplevel() z.wm_title('Tix Widget Demonstration') z.geometry('790x590+10+10') test.balloon = Tix.Balloon(root) frame1 = self.MkMainMenu() frame2 = self.MainNotebook() frame3 = self.MkMainStatus() frame1.pack(side=TOP, fill=X) #frame3.pack(side=BOTTOM, fill=X) frame2.pack(side=TOP, expand=1, fill=BOTH, padx=4, pady=4) test.balloon['statusbar'] = test.statusbar z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
def __init__(self, master, tag, varname="", direction="left", **args): Tix.Canvas.__init__( self, master, name=tag, borderwidth=0, width=30, height=20, cursor="dot", ) self.title = varname self.__ballon = Tix.Balloon(self, state="balloon", initwait=10) self.__ballon.label.destroy() self.__ballon.bind_widget(self, msg=varname) self.change_arrow(direction)
def RunSample(w): status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1) status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1) # Create two mysterious widgets that need balloon help button1 = Tix.Button(w, text='Something Unexpected', command=lambda w=w: w.destroy()) button2 = Tix.Button(w, text='Something Else Unexpected') button2['command'] = lambda w=button2: w.destroy() button1.pack(side=Tix.TOP, expand=1) button2.pack(side=Tix.TOP, expand=1) # Create the balloon widget and associate it with the widgets that we want # to provide tips for: b = Tix.Balloon(w, statusbar=status) b.bind_widget(button1, balloonmsg='Close Window', statusmsg='Press this button to close this window') b.bind_widget(button2, balloonmsg='Self-destruct button', statusmsg='Press this button and it will destroy itself')
def __init__(self, master=None): ttk.Frame.__init__(self, master) self.pack(fill=BOTH, expand=1) self.root = master self.balloon = Tix.Balloon(self.root) self._headingsTable = ('Input URL', 'Status', 'File Name', 'Direct URL') #data = { inputUrl<list>:{password, quality, listFiles : [inputUrl<file>, status, directurl, fileName, password*, quality*]} } #Read data from file self._data = OrderedDict() self._data['Main'] = { 'status': '', 'password': '', 'quality': '', 'listFiles': [] } self._activeList = 'Main' dataStored = self._import_data() # print dataStored if (isinstance(dataStored, OrderedDict)): self._data.update(dataStored) #create element self.createWidgets() self._save_data() self._thread_get_link = None self._queue_get_link = deque() #collections.deque # add info list, table for listName in self._data.keys(): self._add_new_list(values=listName) for file in self._data[self._activeList]['listFiles']: self._add_new_row(index='end', values=file) ### content for sub in self.balloon.subwidgets_all(): sub.config(bg='lightgrey')
def __create_widgets(self): _scrolltext = Tix.ScrolledText( self, scrollbar="both", width=600, height=400, ) self.__text_stack = _scrolltext.subwidget("text") self.__text_stack.configure( wrap="none", spacing1=2, ) _scrolltext.grid(sticky="nesw") self.__balloon = Tix.Balloon( self.__text_stack, state='balloon', ) self.__text_stack.bind( '<Motion>', self.__show_variable )
def Initialise(self): global UB self.title('UltraBorg Tuning GUI') # Setup a grid of 4 sliders which command each servo output, plus 4 readings for the servo positions and distances self.grid() # The heading labels self.lblHeadingTask = Tkinter.Label(self, text='Task to perform') self.lblHeadingTask['font'] = ('Arial', 18, 'bold') self.lblHeadingTask.grid(column=0, row=0, columnspan=1, rowspan=1, sticky='NSEW') self.lblHeadingServo1 = Tkinter.Label(self, text='Servo #1') self.lblHeadingServo1['font'] = ('Arial', 18, 'bold') self.lblHeadingServo1.grid(column=1, row=0, columnspan=2, rowspan=1, sticky='NSEW') self.lblHeadingServo2 = Tkinter.Label(self, text='Servo #2') self.lblHeadingServo2['font'] = ('Arial', 18, 'bold') self.lblHeadingServo2.grid(column=3, row=0, columnspan=2, rowspan=1, sticky='NSEW') self.lblHeadingServo3 = Tkinter.Label(self, text='Servo #3') self.lblHeadingServo3['font'] = ('Arial', 18, 'bold') self.lblHeadingServo3.grid(column=5, row=0, columnspan=2, rowspan=1, sticky='NSEW') self.lblHeadingServo4 = Tkinter.Label(self, text='Servo #4') self.lblHeadingServo4['font'] = ('Arial', 18, 'bold') self.lblHeadingServo4.grid(column=7, row=0, columnspan=2, rowspan=1, sticky='NSEW') # The task descriptions self.lblTaskMaximum = Tkinter.Label(self, text='Hover over the buttons\n' + 'for more help\n\n' + 'Set the servo maximums') self.lblTaskMaximum['font'] = ('Arial', 14, '') self.lblTaskMaximum.grid(column=0, row=1, columnspan=1, rowspan=2, sticky='NEW') self.lblTaskStartup = Tkinter.Label( self, text='Set the servo startup positions') self.lblTaskStartup['font'] = ('Arial', 14, '') self.lblTaskStartup.grid(column=0, row=3, columnspan=1, rowspan=2, sticky='NSEW') self.lblTaskMinimum = Tkinter.Label(self, text='Set the servo minimums') self.lblTaskMinimum['font'] = ('Arial', 14, '') self.lblTaskMinimum.grid(column=0, row=5, columnspan=1, rowspan=2, sticky='NSEW') self.lblTaskCurrent = Tkinter.Label(self, text='Current servo position') self.lblTaskCurrent['font'] = ('Arial', 18, 'bold') self.lblTaskCurrent.grid(column=0, row=7, columnspan=1, rowspan=1, sticky='NSEW') # The servo sliders self.sld1 = Tkinter.Scale(self, from_=CAL_PWM_MAX, to=CAL_PWM_MIN, orient=Tkinter.VERTICAL, command=self.sld1_move, showvalue=0) self.sld1.set(CAL_PWM_START) self.sld1.grid(column=1, row=1, rowspan=6, columnspan=1, sticky='NSE') self.sld2 = Tkinter.Scale(self, from_=CAL_PWM_MAX, to=CAL_PWM_MIN, orient=Tkinter.VERTICAL, command=self.sld2_move, showvalue=0) self.sld2.set(CAL_PWM_START) self.sld2.grid(column=3, row=1, rowspan=6, columnspan=1, sticky='NSE') self.sld3 = Tkinter.Scale(self, from_=CAL_PWM_MAX, to=CAL_PWM_MIN, orient=Tkinter.VERTICAL, command=self.sld3_move, showvalue=0) self.sld3.set(CAL_PWM_START) self.sld3.grid(column=5, row=1, rowspan=6, columnspan=1, sticky='NSE') self.sld4 = Tkinter.Scale(self, from_=CAL_PWM_MAX, to=CAL_PWM_MIN, orient=Tkinter.VERTICAL, command=self.sld4_move, showvalue=0) self.sld4.set(CAL_PWM_START) self.sld4.grid(column=7, row=1, rowspan=6, columnspan=1, sticky='NSE') # The servo maximums self.lblServoMaximum1 = Tkinter.Label(self, text='-') self.lblServoMaximum1['font'] = ('Arial', 14, '') self.lblServoMaximum1.grid(column=2, row=1, columnspan=1, rowspan=1, sticky='SW') self.lblServoMaximum2 = Tkinter.Label(self, text='-') self.lblServoMaximum2['font'] = ('Arial', 14, '') self.lblServoMaximum2.grid(column=4, row=1, columnspan=1, rowspan=1, sticky='SW') self.lblServoMaximum3 = Tkinter.Label(self, text='-') self.lblServoMaximum3['font'] = ('Arial', 14, '') self.lblServoMaximum3.grid(column=6, row=1, columnspan=1, rowspan=1, sticky='SW') self.lblServoMaximum4 = Tkinter.Label(self, text='-') self.lblServoMaximum4['font'] = ('Arial', 14, '') self.lblServoMaximum4.grid(column=8, row=1, columnspan=1, rowspan=1, sticky='SW') # The servo maximum set buttons self.butServoMaximum1 = Tkinter.Button( self, text='Save\nmaximum', command=self.butServoMaximum1_click) self.butServoMaximum1['font'] = ('Arial', 12, '') self.butServoMaximum1.grid(column=2, row=2, columnspan=1, rowspan=1, sticky='NW') self.butServoMaximum2 = Tkinter.Button( self, text='Save\nmaximum', command=self.butServoMaximum2_click) self.butServoMaximum2['font'] = ('Arial', 12, '') self.butServoMaximum2.grid(column=4, row=2, columnspan=1, rowspan=1, sticky='NW') self.butServoMaximum3 = Tkinter.Button( self, text='Save\nmaximum', command=self.butServoMaximum3_click) self.butServoMaximum3['font'] = ('Arial', 12, '') self.butServoMaximum3.grid(column=6, row=2, columnspan=1, rowspan=1, sticky='NW') self.butServoMaximum4 = Tkinter.Button( self, text='Save\nmaximum', command=self.butServoMaximum4_click) self.butServoMaximum4['font'] = ('Arial', 12, '') self.butServoMaximum4.grid(column=8, row=2, columnspan=1, rowspan=1, sticky='NW') # The servo startups self.lblServoStartup1 = Tkinter.Label(self, text='-') self.lblServoStartup1['font'] = ('Arial', 14, '') self.lblServoStartup1.grid(column=2, row=3, columnspan=1, rowspan=1, sticky='SW') self.lblServoStartup2 = Tkinter.Label(self, text='-') self.lblServoStartup2['font'] = ('Arial', 14, '') self.lblServoStartup2.grid(column=4, row=3, columnspan=1, rowspan=1, sticky='SW') self.lblServoStartup3 = Tkinter.Label(self, text='-') self.lblServoStartup3['font'] = ('Arial', 14, '') self.lblServoStartup3.grid(column=6, row=3, columnspan=1, rowspan=1, sticky='SW') self.lblServoStartup4 = Tkinter.Label(self, text='-') self.lblServoStartup4['font'] = ('Arial', 14, '') self.lblServoStartup4.grid(column=8, row=3, columnspan=1, rowspan=1, sticky='SW') # The servo startup set buttons self.butServoStartup1 = Tkinter.Button( self, text='Save\nstartup', command=self.butServoStartup1_click) self.butServoStartup1['font'] = ('Arial', 12, '') self.butServoStartup1.grid(column=2, row=4, columnspan=1, rowspan=1, sticky='NW') self.butServoStartup2 = Tkinter.Button( self, text='Save\nstartup', command=self.butServoStartup2_click) self.butServoStartup2['font'] = ('Arial', 12, '') self.butServoStartup2.grid(column=4, row=4, columnspan=1, rowspan=1, sticky='NW') self.butServoStartup3 = Tkinter.Button( self, text='Save\nstartup', command=self.butServoStartup3_click) self.butServoStartup3['font'] = ('Arial', 12, '') self.butServoStartup3.grid(column=6, row=4, columnspan=1, rowspan=1, sticky='NW') self.butServoStartup4 = Tkinter.Button( self, text='Save\nstartup', command=self.butServoStartup4_click) self.butServoStartup4['font'] = ('Arial', 12, '') self.butServoStartup4.grid(column=8, row=4, columnspan=1, rowspan=1, sticky='NW') # The servo minimums self.lblServoMinimum1 = Tkinter.Label(self, text='-') self.lblServoMinimum1['font'] = ('Arial', 14, '') self.lblServoMinimum1.grid(column=2, row=5, columnspan=1, rowspan=1, sticky='SW') self.lblServoMinimum2 = Tkinter.Label(self, text='-') self.lblServoMinimum2['font'] = ('Arial', 14, '') self.lblServoMinimum2.grid(column=4, row=5, columnspan=1, rowspan=1, sticky='SW') self.lblServoMinimum3 = Tkinter.Label(self, text='-') self.lblServoMinimum3['font'] = ('Arial', 14, '') self.lblServoMinimum3.grid(column=6, row=5, columnspan=1, rowspan=1, sticky='SW') self.lblServoMinimum4 = Tkinter.Label(self, text='-') self.lblServoMinimum4['font'] = ('Arial', 14, '') self.lblServoMinimum4.grid(column=8, row=5, columnspan=1, rowspan=1, sticky='SW') # The servo minimum set buttons self.butServoMinimum1 = Tkinter.Button( self, text='Save\nminimum', command=self.butServoMinimum1_click) self.butServoMinimum1['font'] = ('Arial', 12, '') self.butServoMinimum1.grid(column=2, row=6, columnspan=1, rowspan=1, sticky='NW') self.butServoMinimum2 = Tkinter.Button( self, text='Save\nminimum', command=self.butServoMinimum2_click) self.butServoMinimum2['font'] = ('Arial', 12, '') self.butServoMinimum2.grid(column=4, row=6, columnspan=1, rowspan=1, sticky='NW') self.butServoMinimum3 = Tkinter.Button( self, text='Save\nminimum', command=self.butServoMinimum3_click) self.butServoMinimum3['font'] = ('Arial', 12, '') self.butServoMinimum3.grid(column=6, row=6, columnspan=1, rowspan=1, sticky='NW') self.butServoMinimum4 = Tkinter.Button( self, text='Save\nminimum', command=self.butServoMinimum4_click) self.butServoMinimum4['font'] = ('Arial', 12, '') self.butServoMinimum4.grid(column=8, row=6, columnspan=1, rowspan=1, sticky='NW') # The servo values (read from the controller) self.lblServo1 = Tkinter.Label(self, text='-') self.lblServo1['font'] = ('Arial', 18, '') self.lblServo1.grid(column=2, row=7, columnspan=1, rowspan=1, sticky='NSW') self.lblServo2 = Tkinter.Label(self, text='-') self.lblServo2['font'] = ('Arial', 18, '') self.lblServo2.grid(column=4, row=7, columnspan=1, rowspan=1, sticky='NSW') self.lblServo3 = Tkinter.Label(self, text='-') self.lblServo3['font'] = ('Arial', 18, '') self.lblServo3.grid(column=6, row=7, columnspan=1, rowspan=1, sticky='NSW') self.lblServo4 = Tkinter.Label(self, text='-') self.lblServo4['font'] = ('Arial', 18, '') self.lblServo4.grid(column=8, row=7, columnspan=1, rowspan=1, sticky='NSW') # The major operations self.butReset = Tkinter.Button( self, text='Reset and save all to default values', command=self.butReset_click) self.butReset['font'] = ("Arial", 20, "bold") self.butReset.grid(column=0, row=8, rowspan=1, columnspan=9, sticky='NSEW') # Balloon help pop-up self.tipStatus = Tix.Balloon(self) self.servoSliderHelp = ( 'Use this slider to move servo #%d.\n' + 'Hover over each button for more help.\n' + 'The current position of servo #%d is shown at the bottom.') self.servoMaxHelp = ( 'Set the maximum for servo #%d.\n' + 'Slowly move the servo #%d slider up until the servo stops moving,\n' + 'then move the slider back down slightly to where it moves again.\n' + 'This will become +100%%.') self.servoStartupHelp = ( 'Set the startup position for servo #%d.\n' + 'When UltraBorg powers up, servo #%d will move to this position.\n' + 'This position must be between the set maximum and minimum.\n' + 'If unset then 0%% is used instead.') self.servoMinHelp = ( 'Set the minimum for servo #%d.\n' + 'Slowly move the servo #%d slider down until the servo stops moving,\n' + 'then move the slider back up slightly to where it moves again.\n' + 'This will become -100%%.') self.tipStatus.bind_widget(self.sld1, balloonmsg=self.servoSliderHelp % (1, 1)) self.tipStatus.bind_widget(self.butServoMaximum1, balloonmsg=self.servoMaxHelp % (1, 1)) self.tipStatus.bind_widget(self.butServoStartup1, balloonmsg=self.servoStartupHelp % (1, 1)) self.tipStatus.bind_widget(self.butServoMinimum1, balloonmsg=self.servoMinHelp % (1, 1)) self.tipStatus.bind_widget(self.sld2, balloonmsg=self.servoSliderHelp % (2, 2)) self.tipStatus.bind_widget(self.butServoMaximum2, balloonmsg=self.servoMaxHelp % (2, 2)) self.tipStatus.bind_widget(self.butServoStartup2, balloonmsg=self.servoStartupHelp % (2, 2)) self.tipStatus.bind_widget(self.butServoMinimum2, balloonmsg=self.servoMinHelp % (2, 2)) self.tipStatus.bind_widget(self.sld3, balloonmsg=self.servoSliderHelp % (3, 3)) self.tipStatus.bind_widget(self.butServoMaximum3, balloonmsg=self.servoMaxHelp % (3, 3)) self.tipStatus.bind_widget(self.butServoStartup3, balloonmsg=self.servoStartupHelp % (3, 3)) self.tipStatus.bind_widget(self.butServoMinimum3, balloonmsg=self.servoMinHelp % (3, 3)) self.tipStatus.bind_widget(self.sld4, balloonmsg=self.servoSliderHelp % (4, 4)) self.tipStatus.bind_widget(self.butServoMaximum4, balloonmsg=self.servoMaxHelp % (4, 4)) self.tipStatus.bind_widget(self.butServoStartup4, balloonmsg=self.servoStartupHelp % (4, 4)) self.tipStatus.bind_widget(self.butServoMinimum4, balloonmsg=self.servoMinHelp % (4, 4)) # The grid sizing self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=1) self.grid_columnconfigure(2, weight=2) self.grid_columnconfigure(3, weight=1) self.grid_columnconfigure(4, weight=2) self.grid_columnconfigure(5, weight=1) self.grid_columnconfigure(6, weight=2) self.grid_columnconfigure(7, weight=1) self.grid_columnconfigure(8, weight=2) self.grid_rowconfigure(0, weight=1) self.grid_rowconfigure(1, weight=1) self.grid_rowconfigure(2, weight=1) self.grid_rowconfigure(3, weight=1) self.grid_rowconfigure(4, weight=1) self.grid_rowconfigure(5, weight=1) self.grid_rowconfigure(6, weight=1) self.grid_rowconfigure(7, weight=1) self.grid_rowconfigure(8, weight=1) # Set the size of the dialog self.resizable(True, True) self.geometry('1000x700') # Read the current settings for each servo self.ReadAllCalibration() # Start polling for readings self.poll()
def Initialise(self): global RB self.title('RockyBorg Tuning GUI') # Setup a grid of 4 sliders which command each servo output, plus 4 readings for the servo positions and distances self.grid() # The heading labels self.lblHeadingTask = Tkinter.Label(self, text='Task to perform') self.lblHeadingTask['font'] = ('Arial', 18, 'bold') self.lblHeadingTask.grid(column=0, row=0, columnspan=1, rowspan=1, sticky='NSEW') self.lblHeadingServo = Tkinter.Label(self, text='Servo') self.lblHeadingServo['font'] = ('Arial', 18, 'bold') self.lblHeadingServo.grid(column=1, row=0, columnspan=2, rowspan=1, sticky='NSEW') # The task descriptions self.lblTaskMaximum = Tkinter.Label( self, text='Hover over the buttons\n' + 'for more help\n\n' + 'Set the servo maximum\n(turning right)') self.lblTaskMaximum['font'] = ('Arial', 14, '') self.lblTaskMaximum.grid(column=0, row=1, columnspan=1, rowspan=2, sticky='NEW') self.lblTaskStartup = Tkinter.Label( self, text='Set the servo startup position\n(central)') self.lblTaskStartup['font'] = ('Arial', 14, '') self.lblTaskStartup.grid(column=0, row=3, columnspan=1, rowspan=2, sticky='NSEW') self.lblTaskMinimum = Tkinter.Label( self, text='Set the servo minimum\n(turning left)') self.lblTaskMinimum['font'] = ('Arial', 14, '') self.lblTaskMinimum.grid(column=0, row=5, columnspan=1, rowspan=2, sticky='NSEW') self.lblTaskCurrent = Tkinter.Label(self, text='Current servo position') self.lblTaskCurrent['font'] = ('Arial', 18, 'bold') self.lblTaskCurrent.grid(column=0, row=7, columnspan=1, rowspan=1, sticky='NSEW') # The servo slider self.sld = Tkinter.Scale(self, from_=CAL_PWM_MAX, to=CAL_PWM_MIN, orient=Tkinter.VERTICAL, command=self.sld_move, showvalue=0) self.sld.set(CAL_PWM_START) self.sld.grid(column=1, row=1, rowspan=6, columnspan=1, sticky='NSE') # The servo maximum self.lblServoMaximum = Tkinter.Label(self, text='-') self.lblServoMaximum['font'] = ('Arial', 14, '') self.lblServoMaximum.grid(column=2, row=1, columnspan=1, rowspan=1, sticky='SW') self.butServoMaximum = Tkinter.Button( self, text='Save\nmaximum', command=self.butServoMaximum_click) self.butServoMaximum['font'] = ('Arial', 12, '') self.butServoMaximum.grid(column=2, row=2, columnspan=1, rowspan=1, sticky='NW') # The servo startup self.lblServoStartup = Tkinter.Label(self, text='-') self.lblServoStartup['font'] = ('Arial', 14, '') self.lblServoStartup.grid(column=2, row=3, columnspan=1, rowspan=1, sticky='SW') self.butServoStartup = Tkinter.Button( self, text='Save\nstartup', command=self.butServoStartup_click) self.butServoStartup['font'] = ('Arial', 12, '') self.butServoStartup.grid(column=2, row=4, columnspan=1, rowspan=1, sticky='NW') # The servo minimum self.lblServoMinimum = Tkinter.Label(self, text='-') self.lblServoMinimum['font'] = ('Arial', 14, '') self.lblServoMinimum.grid(column=2, row=5, columnspan=1, rowspan=1, sticky='SW') self.butServoMinimum = Tkinter.Button( self, text='Save\nminimum', command=self.butServoMinimum_click) self.butServoMinimum['font'] = ('Arial', 12, '') self.butServoMinimum.grid(column=2, row=6, columnspan=1, rowspan=1, sticky='NW') # The servo value (read from the controller) self.lblServo = Tkinter.Label(self, text='-') self.lblServo['font'] = ('Arial', 18, '') self.lblServo.grid(column=2, row=7, columnspan=1, rowspan=1, sticky='NSW') # The major operations self.butReset = Tkinter.Button( self, text='Reset and save all to default values', command=self.butReset_click) self.butReset['font'] = ("Arial", 20, "bold") self.butReset.grid(column=0, row=8, rowspan=1, columnspan=3, sticky='NSEW') # Balloon help pop-up self.tipStatus = Tix.Balloon(self) self.servoSliderHelp = ( 'Use this slider to move the servo.\n' + 'Hover over each button for more help.\n' + 'The current position of the servo is shown at the bottom.') self.servoMaxHelp = ( 'Set the maximum for the servo.\n' + 'Slowly move the servo slider up until the servo stops moving,\n' + 'then move the slider back down slightly to where it moves again.\n' + 'This will become +100%.') self.servoStartupHelp = ( 'Set the startup position for the servo.\n' + 'When RockyBorg powers up, the servo will move to this position.\n' + 'This position must be between the set maximum and minimum.\n' + 'If unset then 0% is used instead.') self.servoMinHelp = ( 'Set the minimum for the servo.\n' + 'Slowly move the servo slider down until the servo stops moving,\n' + 'then move the slider back up slightly to where it moves again.\n' + 'This will become -100%.') self.tipStatus.bind_widget(self.sld, balloonmsg=self.servoSliderHelp) self.tipStatus.bind_widget(self.butServoMaximum, balloonmsg=self.servoMaxHelp) self.tipStatus.bind_widget(self.butServoStartup, balloonmsg=self.servoStartupHelp) self.tipStatus.bind_widget(self.butServoMinimum, balloonmsg=self.servoMinHelp) # The grid sizing self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=1) self.grid_columnconfigure(2, weight=2) self.grid_rowconfigure(0, weight=1) self.grid_rowconfigure(1, weight=1) self.grid_rowconfigure(2, weight=1) self.grid_rowconfigure(3, weight=1) self.grid_rowconfigure(4, weight=1) self.grid_rowconfigure(5, weight=1) self.grid_rowconfigure(6, weight=1) self.grid_rowconfigure(7, weight=1) self.grid_rowconfigure(8, weight=1) # Set the size of the dialog self.resizable(True, True) self.geometry('600x700') # Read the current settings for each servo self.ReadAllCalibration() # Start polling for readings self.poll()
def ShotWid(): """ this simple widget accepts a shot and sets the current one It is a function in the IntegerCtl class, so it communicates with its vars easily and calls do_shot to update the shot. THe shot pulldown stops working in python (ordinary) after 1 pulldown? """ global hist_box, select_box, wild_box # root=Tix.Tk(className='ShotSelect') # was here but needs to # be in effect before Tix.StringVar() is called top = Tix.Frame(root, bd=1, relief=Tix.RAISED) hist_box = Tix.ComboBox(top, label="Shot", editable=True, history=True, variable=shot_string, command=do_shot, options='entry.width 8 listbox.height 10 ') hist_box.pack(side=Tix.TOP, anchor=Tix.W) hist_box.set_silent('33373') hist_balloon = Tix.Balloon(top) hist_balloon.bind_widget( hist_box, balloonmsg='Choose or enter shot number, valid ones are saved here' ) wild_box = Tix.ComboBox(top, label="Filter", editable=1, history=1, variable=wild_string, command=update_select, options='entry.width 20 listbox.height 5 ' ) # allow room for expressions wild_box.pack(side=Tix.TOP, anchor=Tix.W) wild_balloon = Tix.Balloon(top) wild_balloon.bind_widget( wild_box, balloonmsg='Choose or enter new filter in one of three forms,' + 'a Python expression (must have () or []), ' + 'a directory specification including a * or ' + 'the name of a file containing lines beginning with a shot number. ' 'Results can be chosen using "Filtered Shots"') select_box = Tix.ComboBox(top, label="Filtered Shots", history=False, variable=select_string, command=do_shot, options='entry.width 8 listbox.height 40 ') btn = Tix.Button(select_box, text='Clear', command=clear_select) btn.pack(anchor=Tix.CENTER) select_box.pack(side=Tix.TOP, anchor=Tix.W) select_balloon = Tix.Balloon(top) select_balloon.bind_widget( select_box, balloonmsg='pull down to find a shot selected by "Filter""') #wild_box.set_silent('MP1') # not silent - want it all to happen, but setvar doesn't work update_select(partial_name=wild_card) top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
def __init__(self, parent, bindir): self.root = parent self.bindir = bindir self.choices_ts = [ 'Displacement (filtered)', 'Acceleration (filtered)', 'Acceleration (unfiltered)' ] self.hist_old = self.choices_ts[0] self.spec_old = self.choices_ts[1] self.p = {} # dictionary to hold all Tk variables self.p['pmax'] = Tk.IntVar() self.p['pmax'].set(0) self.p['fltrng'] = Tk.IntVar() self.p['fltrng'].set(1) self.p['cutrng'] = Tk.IntVar() self.p['cutrng'].set(1) self.p['pltlog2'] = Tk.IntVar() self.p['pltlog2'].set(0) self.p['pltgrid'] = Tk.IntVar() self.p['pltgrid'].set(1) if self.bindir is None: self.choose_bin_directory() if self.bindir == '': sys.exit() ### Window layout setup self.root = parent self.entry_frame = Tk.Frame(root) self.entry_frame.pack(side='top', pady=5) self.eq_frame = Tk.Frame(root, borderwidth=2, relief='sunken') self.eq_frame.pack(side='top', fill=Tk.BOTH, expand=0) self.figure_frame = Tk.Frame(root) self.figure_frame.pack(side='top', anchor='n', expand=1, fill=Tk.BOTH) self.left_frame = Tk.Frame(self.figure_frame) self.left_frame.pack(side='left', anchor='n', expand=1, fill=Tk.BOTH) self.right_frame = Tk.Frame(self.figure_frame) self.right_frame.pack(side='left', anchor='n', expand=1, fill=Tk.BOTH) self.nav_frame = Tk.Frame(self.figure_frame) self.nav_frame.pack(side='right', anchor='center', expand=0, fill='none') self.root.wm_title("Strong motion analyser") self.f1 = Figure(figsize=(5., 5.), dpi=100) self.f2 = Figure(figsize=(6.4, 5.), dpi=100) self.canvas1 = FigureCanvasTkAgg(self.f1, master=self.left_frame) self.canvas2 = FigureCanvasTkAgg(self.f2, master=self.right_frame) self.canvas1.show() self.canvas1.get_tk_widget().pack(side='left', expand=1, fill=Tk.BOTH) self.canvas2.get_tk_widget().pack(side='left', expand=1, fill=Tk.BOTH) toolbar = NavigationToolbar2TkAgg(self.canvas1, self.left_frame) toolbar.update() self.canvas1._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) toolbar1 = NavigationToolbar2TkAgg(self.canvas2, self.right_frame) toolbar1.update() self.canvas2._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) DataHandler.__init__(self, self.bindir) PlotIterator.__init__(self) # Make initial plot of first record self.plotcanvas() # set line length of input file; needed to add comments to line # set number of points variable self.p['starttrim'] = Tk.IntVar() self.p['starttrim'].set(self.startt) self.p['endtrim'] = Tk.IntVar() self.p['endtrim'].set(self.endt) self.p['demean'] = Tk.IntVar() self.p['demean'].set(self.dmn) self.p['detrend'] = Tk.IntVar() self.p['detrend'].set(self.dtrnd) # set filter to default filter self.p['hlow'] = Tk.DoubleVar() self.p['hlow'].set(self.highp[0]) self.p['hhgh'] = Tk.DoubleVar() self.p['hhgh'].set(self.highp[1]) # setting up spin boxes for cutting trim_cntrl_st = Tk.Control(self.entry_frame, label='start', integer=True, step=1, variable=self.p['starttrim']) trim_cntrl_st.entry.config(font=10) trim_cntrl_st.label.config(font=10) trim_cntrl_st.pack(side='left', padx=5) trim_cntrl_ed = Tk.Control(self.entry_frame, label='end', integer=True, step=1, variable=self.p['endtrim']) trim_cntrl_ed.entry.config(font=10) trim_cntrl_ed.label.config(font=10) trim_cntrl_ed.pack(side='left', padx=5) # setting up trim button trim_button = Tk.Button(self.entry_frame, text='Cut', width=8, command=self.recalc, font=10) trim_button.pack(side='left', padx=10) # setting up spin boxes for filtering hp_cntrl_lw = Tk.Control(self.entry_frame, label='cutoff', max=10, min=0, integer=False, step=0.01, variable=self.p['hlow']) hp_cntrl_lw.entry.config(font=10) hp_cntrl_lw.label.config(font=10) hp_cntrl_lw.pack(side='left', padx=5) hp_cntrl_hg = Tk.Control(self.entry_frame, label='corner', max=10, min=0, integer=False, step=0.01, variable=self.p['hhgh']) hp_cntrl_hg.entry.config(font=10) hp_cntrl_hg.label.config(font=10) hp_cntrl_hg.pack(side='left', padx=5) # setting up filter button flt_button = Tk.Button(self.entry_frame, text='Filter', width=8, command=self.recalc, font=10) flt_button.pack(side='left', padx=10) # setting up combo box for spectra spec_box = Tk.ComboBox(self.entry_frame, label='Spectra', editable=False, dropdown=True, command=self.choose_spec, value=self.choices_ts[1]) spec_box.insert('end', self.choices_ts[0]) spec_box.insert('end', self.choices_ts[1]) spec_box.insert('end', self.choices_ts[2]) spec_box.label.config(font=10) spec_box.entry.config(font=10) #spec_box.listbox.config(font=10) spec_box.pack(side='left', padx=10) # setting up combo box for timeseries hist_box = Tk.ComboBox(self.entry_frame, label='Timeseries', editable=False, dropdown=True, command=self.choose_ts, value=self.choices_ts[0]) hist_box.insert('end', self.choices_ts[0]) hist_box.insert('end', self.choices_ts[1]) hist_box.insert('end', self.choices_ts[2]) hist_box.label.config(font=10) hist_box.entry.config(font=10) hist_box.pack(side='left', padx=10) # setting up earthquake info frame self.evtime = Tk.Label(self.eq_frame, text='Event time: %s' % self.v2.stream[0].stats. smdict.eventtime.strftime("%d/%m/%Y %H:%M:%S"), font=10, padx=20) self.evtime.pack(side='left') self.eqdist = Tk.Label(self.eq_frame, text='Epicentral distance: %d km' % self.v2.stream[0].stats.smdict.epicdist, font=10, padx=20) self.eqdist.pack(side='left') self.hdep = Tk.Label(self.eq_frame, text='Hypocentral depth: %d km' % self.v2.stream[0].stats.smdict.hypodep, font=10, padx=20) self.hdep.pack(side='left') self.lmag = Tk.Label(self.eq_frame, text='Local magnitude: %.2f' % self.v2.stream[0].stats.smdict.Ml, font=10, padx=20) self.lmag.pack(side='left') a = self.data[0].split() fname = a[0].split('_') if len(fname) > 3: # building site self.sensname = fname[2] + "/" + fname[3] else: # single instrument accelerometer self.sensname = fname[2] self.sens = Tk.Label(self.eq_frame, text='Sensor name: %s' % self.sensname, font=10, padx=20) self.sens.pack(side='left') # setting up navigation and save button p_button = Tk.Button(self.nav_frame, text='Previous', width=8, command=self.prev, font=10) p_button.pack(side='top', fill='x', anchor='center') n_button = Tk.Button(self.nav_frame, text='Next', width=8, command=self.next, font=10) n_button.pack(side='top', fill='x', anchor='center') n_button = Tk.Button(self.nav_frame, text='Save', width=8, command=self.savefile, font=10) n_button.pack(side='top', fill='x', anchor='center') # setting up radio buttons detrend = Tk.Checkbutton(self.nav_frame, text='Detrend', command=self.recalc, variable=self.p['detrend'], indicatoron=0, width=4, font=10) detrend.pack(side='top', fill='x', anchor='center') baldetrend = Tk.Balloon(self.nav_frame) baldetrend.bind_widget( detrend, balloonmsg= 'Choose whether to subtract linear trend from Volume 1 acceleration timeseries.' ) demean = Tk.Checkbutton(self.nav_frame, text='Demean', command=self.recalc, variable=self.p['demean'], indicatoron=0, width=4, font=10) demean.pack(side='top', fill='x', anchor='center') baldemean = Tk.Balloon(self.nav_frame) baldemean.bind_widget( demean, balloonmsg= 'Choose whether to subtract mean from Volume 1 acceleration timeseries.' ) maxb = Tk.Checkbutton(self.nav_frame, text='Max', command=self.plotmax, variable=self.p['pmax'], indicatoron=0, width=4, font=10) maxb.pack(side='top', fill='x', anchor='center') balmaxb = Tk.Balloon(self.nav_frame) balmaxb.bind_widget(maxb, balloonmsg='Plot maxima of timeseries.') fltrng = Tk.Checkbutton(self.nav_frame, text='Fltrng', command=self.plotfltrng, variable=self.p['fltrng'], indicatoron=0, width=4, font=10) fltrng.pack(side='top', fill='x', anchor='center') balfltrng = Tk.Balloon(self.nav_frame) balfltrng.bind_widget( fltrng, balloonmsg='Plot cutoff and corner frequencies of highpass filter.' ) cutrng = Tk.Checkbutton(self.nav_frame, text='Cutrng', command=self.plotmax, variable=self.p['cutrng'], indicatoron=0, width=4, font=10) cutrng.pack(side='top', fill='x', anchor='center') balcutrng = Tk.Balloon(self.nav_frame) balcutrng.bind_widget(cutrng, balloonmsg='Plot cutting window.') pltlog2 = Tk.Checkbutton(self.nav_frame, text='log2', command=self.plotfltrng, variable=self.p['pltlog2'], indicatoron=0, width=4, font=10) pltlog2.pack(side='top', fill='x', anchor='center') balpltlog2 = Tk.Balloon(self.nav_frame) balpltlog2.bind_widget( pltlog2, balloonmsg= 'Plot line with slope 2.0 through the maximum of the power spectrum.' ) pltgrid = Tk.Checkbutton(self.nav_frame, text='Grid', command=self.plotfltrng, variable=self.p['pltgrid'], indicatoron=0, width=4, font=10) pltgrid.pack(side='top', fill='x', anchor='center') balpltgrid = Tk.Balloon(self.nav_frame) balpltgrid.bind_widget(pltgrid, balloonmsg='Plot grid lines.') # setting up comment button self.p['comment'] = Tk.StringVar() cmnt_button = Tk.Button(self.nav_frame, text='Comment', width=8, command=self.add_comment, font=10) cmnt_button.pack(side='top', fill='x', anchor='center') cmnt_ent = Tk.Entry(self.nav_frame, textvariable=self.p['comment'], width=8) cmnt_ent.pack(side='top', fill='x', anchor='center') balcmnt = Tk.Balloon(self.nav_frame) balcmnt.bind_widget( cmnt_button, balloonmsg= 'Add a comment to the corresponding line in the input file.')
def __init__(self, w): # # defaults that can be overridden # self.options = {'initwait' : BALLOONWAIT, 'floatwin' : FLOATONTOP} for option in self.options.keys(): setattr(self,option,self.options[option]) # # where am I # self.path = sys.path[0] path1, path2 = os.path.split(self.path) if path2 == "library.zip": self.path=path1 # # crap for organizing orderly shutdown # z = w.winfo_toplevel() z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.shutdown()) self.exit = -1 self.root = w # # the help balloon # balloon = Tix.Balloon(w, initwait=self.initwait) # # folderFrame line: an entry for the folder where the files are # folderFrame = Tix.Frame(w) self.folderName = StringVar() self.treesFileName = StringVar() self.floatWin = IntVar() self.floatWin.set(FLOATONTOP) # # make window float or not # if sys.platform[0:3]=="win": self.floatWin.set(self.floatwin) def setFolder(event, self=self): name = self.dirLabelEntry.entry.get() self.folderName.set(name) self.treesFileDialog.fsbox.config(directory=name) self.treesFileName.set("") self.texFileName.set("") self.dirLabelEntry = dirLabelEntry= Tix.LabelEntry(folderFrame, takefocus=0, label='Folder: ', options = '''entry.width 20 label.width 9 label.anchor e''') dirLabelEntry.entry["textvariable"] = self.folderName dirLabelEntry.entry.bind("<KeyPress-Return>", setFolder) dirLabelEntry.pack(side=RIGHT, expand=YES, fill=X) balloon.bind_widget(dirLabelEntry, msg="You can enter the directory for the trees file here, but it's usually better to browse with the '...' button below.\n") folderFrame.pack(side=TOP, expand=YES, fill=X) # # next line: the Trees file # treesFrame = Tix.Frame(w) self.treesLabelEntry = treesLabelEntry = Tix.LabelEntry(treesFrame, label = " Trees file: ", options = ''' entry.width 20 label.width 9 label.anchor e ''') treesLabelEntry.entry["textvariable"] = self.treesFileName def treesFileCommand(filePath, self=self): dirName, fileName = os.path.split(filePath) self.treesFileName.set(fileName) if dirName!=self.folderName.get(): # print dirName # print self.folderName.get() self.folderName.set(dirName) self.treesFileDialog = treesFileDialog = Tix.ExFileSelectDialog(root, title="Trees File Selection", command=treesFileCommand) self.treesFileDialog.fsbox.config(pattern="*.txp") def selectTreesFile(dialog=treesFileDialog): dialog.popup() linepattern = re.compile("\s*(.+?)\s*=\s*(.+?)\s*$") # # load up history # self.historypath = historypath = os.path.join(self.path, "TreeButton.cfg") if os.path.exists(historypath): history = open(historypath,"r") line = history.readline() treesdir = treesFileDialog.fsbox.dir while line != "": linematch = linepattern.match(line) if linematch: if linematch.group(1)=="treesfolder": treesdir.insert(0,linematch.group(2)) elif linematch.group(1)=="folder": self.folderName.set(linematch.group(2)) elif linematch.group(1)=="treesfile": self.treesFileName.set(linematch.group(2)) else: item = linematch.group(1) if item == "floatwin": self.floatWin.set(int(linematch.group(2))) elif item in self.options.keys(): setattr(self,item,linematch.group(2)) else: print "Unknown Setup Option: %s"%line else: print 'matchless: '+line line = history.readline() for dialog in (treesFileDialog,): box = dialog.fsbox list = box.dir.slistbox.listbox if list.size()>0: box.config(directory=list.get(0)) tbt = Tix.Button(treesFrame,text="...", command=selectTreesFile) tbt.pack(side=RIGHT) treesLabelEntry.pack(side=RIGHT, expand=YES, fill=X) treesFrame.pack(side=TOP, expand=YES, fill=X) # # bottom line: the view buttons # runButFrame = Tix.Frame(w) def treesCommand(self=self): os.chdir(self.folderName.get()) treesFile = self.treesFileName.get() base, ext = os.path.splitext(treesFile) treesout = base+".tex" global errfilename trees.errfilename = base+".err" if 1: infile = open(treesFile, "r") outfile = open(treesout, "w") trees.process_file(trees.Source(infile), outfile) if trees.error_occurred: print "Trees had a problem" return else: print "Trees ran without issues" outfile.close() treesButFrame = Tix.Frame(runButFrame) txb = Tix.Button(treesButFrame, text="Run Trees", command=treesCommand) txb.pack(side=LEFT, anchor=W) if sys.platform[0:3]=="win": # floatFrame = Tix.Frame(w) floatLabel = Tix.Label(treesButFrame, text="Keep TreeButton on top") floatLabel.pack(side=RIGHT, anchor=E) floatCheck = Tix.Checkbutton(treesButFrame, variable=self.floatWin, command=lambda self=self: self.checkFloat()) floatCheck.pack(side=RIGHT, anchor=E) # floatFrame.pack(side=TOP, anchor=W) treesButFrame.pack(side=LEFT,anchor=N) runButFrame.pack(side=TOP) if sys.platform[0:3]=="win": # if 0: # disable this stuff for now menubar = Menu(w) w.configure(menu = menubar) system_menu = Menu(menubar, tearoff=0, name="system") system_menu.add_separator() for (label, command) in [("Run trees", treesCommand), ]: system_menu.add_command(label=label, command=command) menubar.add_cascade(menu = system_menu) # # load icon if possible s/b late to avoid goofy-looking startup # iconpath = os.path.join(self.path,'treerunner.ico') if os.path.exists(iconpath): self.iconpath = iconpath try: z.wm_iconbitmap(bitmap=iconpath) except: pass else: self.iconpath = None # # ready to rock and roll # print "TreeButton is ready."
# -*- coding:utf-8 -*- # User: liaochenchen # Date: 2019/12/13 # python 2.7 import Tkinter as tk import Tix root = Tix.Tk() but = Tix.Button(text="test") but.pack() status = Tix.Label(root, text=u"获取更新", bg="olive") ballon = Tix.Balloon(but, statusbar=status) root.mainloop() from Tkinter import * from Tix import * root = Tk() status = Label(root, height=3, width=30, bd=1, bg='yellow', wraplength=210, text="All angles are in degrees") status.grid(row=0, column=0, pady=10) bal = Balloon(root, statusbar=status) frame_1 = Frame(root, relief=RIDGE, bd=2) frame_1.grid(row=1, column=0) Angles = [StringVar(), StringVar()]
def __init__(self): # The instance of this class is the root of the model tree. Thus isRoot is set to True super(Application, self).__init__(nodeName=Scripting.rootName, isRoot=True) Scripting.nameSpace['locals'][Scripting.rootName] = self Scripting.nameSpace['globals'] = globals() self.homePage = 'https://github.com/xialulee/WaveSyn' filePath = getsourcefile(type(self)) dirPath = os.path.split(filePath)[0] # load config file configFileName = os.path.join(dirPath, 'config.json') with open(configFileName) as f: config = json.load(f) consoleMenu = config['ConsoleMenu'] self.editorInfo = config['EditorInfo'] self.lockAttribute('editorInfo') self.promptSymbols = config['PromptSymbols'] tagDefs = config['TagDefs'] # End load config file root = Tix.Tk() mainThreadId = thread.get_ident() from wavesynlib.interfaces.xmlrpc.server import CommandSlot valueChecker = ValueChecker(root) with self.attributeLock: setMultiAttr(self, # UI elements root = root, balloon = Tix.Balloon(root), tbicon = TaskbarIcon(root), # End UI elements mainThreadId = mainThreadId, execThreadLock = threading.RLock(), xmlrpcCommandSlot = CommandSlot(), # Validation Functions valueChecker = valueChecker, checkInt = valueChecker.checkInt, checkFloat = valueChecker.checkFloat, checkPositiveFloat = valueChecker.checkPositiveFloat, # End Validation Functions filePath = filePath, dirPath = dirPath, streamManager =StreamManager(), configFileName = configFileName ) from wavesynlib.basewindow import WindowDict self.windows = WindowDict() # Instance of ModelNode can be locked automatically. self.editors = EditorDict() class EditorObserver(object): # use SimpleObserver instead def __init__(self, wavesyn): self.wavesyn = wavesyn def update(self, editor): wavesyn = self.wavesyn code = editor.code if not code: return wavesyn.streamManager.write('WaveSyn: executing code from editor {0} listed as follows:\n'.format(id(editor)), 'TIP') wavesyn.streamManager.write(code, 'HISTORY') wavesyn.streamManager.write('\n') wavesyn.execute(code) self.editors.manager.addObserver(EditorObserver(self)) with self.attributeLock: self.monitorTimer = self.createTimer(interval=100, active=False) # Make wavesyn.editors.manager check wavesyn.editors every 100ms self.monitorTimer.addObserver(self.editors.manager) self.monitorTimer.addObserver(self.streamManager) frm = Frame(root) frm.pack(side=TOP, fill=X) self.console = ConsoleWindow(menu=consoleMenu, tagDefs=tagDefs) self.streamManager.addObserver(self.console.streamObserver) #! self.clipboard = Clipboard() self.scripting = Scripting(self) self.noTip = False self.monitorTimer.active = True
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#!/usr/local/bin/python