Ejemplo n.º 1
2
    def initUI(self):
        #setup title
        self.master.title("Component Creator")
        self.style = Style()
        self.style.theme_use("clam")

        #indicator label
        self.labelName = Label(self, text="Component Name:")
        self.labelName.place(x=10, y=10)
        self.master.update()

        # create variable and namefield for input of component name
        sv = StringVar()
        sv.trace("w", lambda name, index, mode, sv=sv: self.nameChanged(sv))
        self.nameField = Entry(self, textvariable=sv)
        self.nameField.place(x=10+self.labelName.winfo_width() + 10, y=10)
        self.master.update()

        # label for image name that will show img name for a given component name
        self.imgNameVar = StringVar()
        self.imgNameVar.set('imageName:')
        self.labelImageName = Label(self, textvariable=self.imgNameVar)
        self.labelImageName.place(x=10+self.labelName.winfo_width()+10,y=40)

        # checkbox for visible component or not
        self.cbVar = IntVar()
        self.cb = Checkbutton(self, text="Visible Component",  variable=self.cbVar)
        self.cb.place(x=10, y=70)

        # dropdown list for category
        self.labelCategory = Label(self, text="Category:")
        self.labelCategory.place(x=10, y=110)
        self.master.update()

        acts = ['UserInterface', 'Layout', 'Media', 'Animation', 'Sensors', 'Social', 'Storage',
                'Connectivity', 'LegoMindStorms', 'Experimental', 'Internal', 'Uninitialized']

        self.catBox = Combobox(self, values=acts)
        self.catBox.place(x=10+self.labelCategory.winfo_width()+10, y=110)

        # button to select icon image
        self.getImageButton = Button(self, text="Select icon", command=self.getImage)
        self.getImageButton.place(x=10, y=150)
        self.master.update()

        # explanation for resizing
        self.resizeVar = IntVar()
        self.resizeCB = Checkbutton(self,
            text="ON=Resize Image (Requires PIL)\nOFF=Provide 16x16 Image", variable=self.resizeVar)
        self.resizeCB.place(x=10+self.getImageButton.winfo_width()+10, y=150)

        # create button
        self.createButton = Button(self, text="Create", command=self.create)
        self.createButton.place(x=10, y=230)

        #cancel button
        self.cancelButton = Button(self, text="Cancel", command=self.quit)
        self.cancelButton.place(x=200, y=230)
Ejemplo n.º 2
0
 def __init__(self, app, w, b=None, inf=None):
     self.render_flag = 0
     self.l = w
     self.app = app
     if b:
         b.configure(command=self.done)
     self.inf = inf
     self._image = None
     self.tkimage = None
     self.top = 0
     self.left = 0
     self.right = 0
     self.bottom = 0
     self.blurred = None
     self.xor = None
     self.x0 = None
     self.y0 = None
     w.bind("<Button-1>", self.start)
     w.bind("<Double-Button-1>", self.start)
     w.bind("<Button1-Motion>", self.motion)
     w.bind("<ButtonRelease-1>", self.end)
     dummy_image = Image.frombytes('RGB', (1, 1), '\0\0\0')
     self.dummy_tkimage = PhotoImage(dummy_image)
     self.state = DRAG_NONE
     self.round = 1
     self.image = None
     w.configure(image=self.dummy_tkimage)
     self.v = IntVar(app)
Ejemplo n.º 3
0
    def interface_parametres(self, root):
        """!Création de l'interface de choix des paramètres de calcul

        On permet à l'utilisateur de choisir les modes numériques et expérimentaux
        ainsi que la méthode de projection
        """
        self.var_expans_param_frame_visible = IntVar()
        self.export_name = StringVar()
        self.param = None
        self.suffix = ['_NX', '_EX', '_ET', '_RD']
        listres = [
            "résultat numérique   extrait  NX",
            "résultat expérimental extrait EX", "résultat étendu ET",
            "résultat réduit RD"
        ]

        f = Frame(root, relief='sunken', borderwidth=1)

        self.param_proj_mesu = ParamProjMesuModal(
            f, u"Paramètres de PROJ_MESU_MODAL")
        self.param = self.param_proj_mesu.get_option()

        # parametres de proj_mesu_modal
        paraf = Frame(f, borderwidth=1)
        Label(paraf, text=u"Paramètres de PROJ_MESU_MODAL").grid(row=0,
                                                                 column=0,
                                                                 rowspan=2,
                                                                 sticky='nswe')
        Checkbutton(paraf,
                    text=u"Réglages",
                    command=self.display_expans_param_frame,
                    variable=self.var_expans_param_frame_visible,
                    indicatoron=0).grid(row=2, column=0, pady=5, sticky='e')
        paraf.grid(row=0, column=0, sticky='ew', pady=10, padx=10)

        # lancer le calcul
        launchf = Frame(f, borderwidth=1)
        Button(launchf, text="Calculer",
               command=self.prepare_calcul).grid(row=2, column=0, sticky='w')
        Entry(launchf, textvariable=self.export_name,
              bg='white').grid(row=2, column=1, pady=2)
        launchf.grid(row=1, column=0, sticky='ew', pady=10, padx=10)

        self.liste_num = ModeFreqList(f, u"Modes Numériques")
        self.liste_num.grid(row=0,
                            column=3,
                            rowspan=3,
                            sticky='nsew',
                            pady=10,
                            padx=10)
        self.liste_exp = ModeFreqList(f, u"Modes Expérimentaux")
        self.liste_exp.grid(row=0,
                            column=4,
                            rowspan=3,
                            sticky='nsew',
                            pady=10,
                            padx=10)

        f.grid(row=1, sticky='ew')
        return f
Ejemplo n.º 4
0
    def __init__(self, master):
        self.master = master
        master.title("Calculator")
        self.calculator = Calculator()

        self.entered_number = 0

        self.total_label_text = IntVar()
        self.total_label = Label(master, textvariable=self.total_label_text)

        self.label = Label(master, text="Total:")

        vcmd = master.register(self.validate) # we have to wrap the command
        self.entry = Entry(master, validate="key", validatecommand=(vcmd, '%P'))

        self.add_button = Button(master, text="+", command=lambda: self.update("add"))
        self.subtract_button = Button(master, text="-", command=lambda: self.update("subtract"))
        self.reset_button = Button(master, text="Reset", command=lambda: self.update("reset"))

        # LAYOUT

        self.label.grid(row=0, column=0, sticky=W)
        self.total_label.grid(row=0, column=1, columnspan=2, sticky=E)

        self.entry.grid(row=1, column=0, columnspan=3, sticky=W+E)

        self.add_button.grid(row=2, column=0)
        self.subtract_button.grid(row=2, column=1)
        self.reset_button.grid(row=2, column=2, sticky=W+E)
        self.update_total()
    def startwindow(self):

        self.var1 = IntVar()
        self.textvar = StringVar()

        self.Label1 = Label(self.master, text="Search distance (meters)")
        self.Label1.grid(row=0, column=0)

        self.Label2 = Label(self.master, textvariable=self.textvar)
        self.Label2.grid(row=2, column=0)

        self.rb1 = Radiobutton(self.master,
                               text="5000",
                               variable=self.var1,
                               value=5000,
                               command=self.cb1select)
        self.rb1.grid(row=1, column=0, sticky=W)

        self.rb2 = Radiobutton(self.master,
                               text="625",
                               variable=self.var1,
                               value=625,
                               command=self.cb1select)
        self.rb2.grid(row=1, column=1, sticky=W)

        self.rb3 = Radiobutton(self.master,
                               text="160",
                               variable=self.var1,
                               value=160,
                               command=self.cb1select)
        self.rb3.grid(row=1, column=2, sticky=W)

        self.Button1 = Button(self.master, text="ok", command=self.ButtonClick)
        self.Button1.grid(row=2, column=2)
    def initUI(self):
        
        photo = ImageTk.PhotoImage(file='icon/main_bg_4.jpg')
        w = Tkinter.Label(self,image=photo)
        w.photo = photo 
        w.place(x=0, y=0, relwidth=1, relheight=1)
        #ackground_label.pack()
        
        
        self.api = IntVar()
        self.parent.title("Face Recognition System")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)
        
        faceplus = Radiobutton(self, text="Face++", variable=self.api, value=1)
        faceplus.place(x=50, y=40)
        
        facer = Radiobutton(self, text="FaceR Animetrics", variable=self.api, value=2)
        facer.place(x=200, y=40)

        start = Button(self, text="Start Recognition",
            command=self.startRecognition)
        start.place(x=100, y=80)
        
        helpButton = Button(self, text="Help",
            command=self.giveHelp)
        helpButton.place(x=100, y=110)
    
        quitButton = Button(self, text="Quit",
            command=self.quitGUI)
        quitButton.place(x=100, y=140)
Ejemplo n.º 7
0
    def build_dlg(self):
	top = self.top

        label = Label(top, name = 'label',
                      text = _("Please select the object categories whose "
                               "default properties you want to change"))
        label.pack(side = TOP, anchor = W)
        frame = Frame(top)
        frame.pack(side = TOP)
        self.var_graphics = IntVar(top)
        if self.category != 'font':
            self.var_graphics.set(1)
        button = Checkbutton(frame, text = _("Graphics Objects"),
                             state = (self.category == 'font'
                                      and DISABLED or NORMAL),
                             variable = self.var_graphics)
        button.pack(side = TOP, anchor = W)
        self.var_text = IntVar(top)
        if self.category == 'font':
            self.var_text.set(1)
        button = Checkbutton(frame, text = _("Text Objects"),
                             state = (self.category == 'line'
                                      and DISABLED or NORMAL),
                             variable = self.var_text)
        button.pack(side = TOP, anchor = W)

	but_frame = Frame(top)
	but_frame.pack(side = TOP, fill = BOTH, expand = 1)

	button = Button(but_frame, text = _("OK"), command = self.ok)
	button.pack(side = LEFT, expand = 1)
	button = Button(but_frame, text = _("Cancel"), command = self.cancel)
	button.pack(side = RIGHT, expand = 1)
Ejemplo n.º 8
0
    def __init__(self, tree, settings):
        self._trees = (tree, )

        self._top = Tk()

        cf = self._cframe = CanvasFrame(self._top)

        # Size is variable.
        self._size = IntVar(self._top)
        self._size.set(12)
        bold = (settings['font'], -int(12 * settings['scale']), 'bold')
        norm = (settings['font'], -int(12 * settings['scale']))

        self._width = 1
        self._widgets = []
        widget = TreeWidget(
            cf.canvas(),
            tree,
            node_font=bold,
            leaf_color=settings['terminal_color'],
            node_color=settings['nonterminal_color'],
            roof_color='#004040',
            roof_fill='white',
            line_color='#004040',
            leaf_font=norm,
        )
        widget['xspace'] = int(settings['scale'] * widget['xspace'])
        widget['yspace'] = int(settings['scale'] * widget['yspace'])
        self._widgets.append(widget)
        cf.add_widget(widget, 0, 0)

        self._layout()
        self._cframe.pack(expand=1, fill='both', side='left')
Ejemplo n.º 9
0
 def add_customer(self, event=None):
     # validate and show errors
     if self.fname.get() == '':
         showerror("Error!", "First name field blank!")
     elif self.lname.get() == '':
         showerror("Error!", "Last name field blank!")
     elif self.mname.get() == '':
         showerror("Error!", "Middle initial field blank!")
     elif self.payment.get() not in ("Drop In", "Punch Card", "Monthly", "Inactive"):
         showerror("Error!", "Incorect Customer type!")
     elif not re.compile(r'[01]?\d/[0123]?\d/[12]\d{1,3}').search(self.date.get()):
         showerror("Error!", "Bad entry for date, use format mm/dd/yyyy")
     else:
         # do work
         name = ' '.join([self.fname.get(),self.mname.get(),self.lname.get()])
         old, row = self.customers.find(str(self.lname.get()).strip(), str(self.fname.get()).strip(),
                                        str(self.mname.get()).strip())
         new = [str(self.lname.get()).strip(), str(self.fname.get()).strip(), str(self.mname.get()).strip(),
                str(self.payment.get()).strip(), datetime.strptime(self.date.get(), "%m/%d/%Y")]
         
         if not old: #add customer
             self.customers.add(new)
             self.output_text("+ - New Customer: " + name + " (" + self.payment.get() + ")\n")
             self.refresh()
         else:
             var = IntVar()
             
             diag = AlreadyExistsDialog(self.root, new, old, var)
             diag.show()
             if var.get() == 0: # edit
                 pass
             if var.get() == 1: # replace customer
                 self.customers.replace(row, new)
                 self.output_text("+ - Modified: " + name + " (" + self.payment.get() + ")\n")
                 self.refresh()
Ejemplo n.º 10
0
Archivo: tree.py Proyecto: sp00/nltk
    def __init__(self, *trees):
        from math import sqrt, ceil

        self._trees = trees

        self._top = Tk()
        self._top.title('NLTK')
        self._top.bind('<Control-x>', self.destroy)
        self._top.bind('<Control-q>', self.destroy)

        cf = self._cframe = CanvasFrame(self._top)
        self._top.bind('<Control-p>', self._cframe.print_to_file)

        # Size is variable.
        self._size = IntVar(self._top)
        self._size.set(12)
        bold = ('helvetica', -self._size.get(), 'bold')
        helv = ('helvetica', -self._size.get())

        # Lay the trees out in a square.
        self._width = int(ceil(sqrt(len(trees))))
        self._widgets = []
        for i in range(len(trees)):
            widget = TreeWidget(cf.canvas(), trees[i], node_font=bold,
                                leaf_color='#008040', node_color='#004080',
                                roof_color='#004040', roof_fill='white',
                                line_color='#004040', draggable=1,
                                leaf_font=helv)
            widget.bind_click_trees(widget.toggle_collapsed)
            self._widgets.append(widget)
            cf.add_widget(widget, 0, 0)

        self._layout()
        self._cframe.pack(expand=1, fill='both')
        self._init_menubar()
Ejemplo n.º 11
0
    def __init__(self, parent, question_text, ans1_text, ans2_text, ans3_text,
                 ans4_text, exp1_text, exp2_text, exp3_text, exp4_text,
                 correct_ans):
        # assigning parameters to attributes
        self.parent = parent
        self.qtext = str(question_text)
        self.text1 = str(ans1_text)
        self.text2 = str(ans2_text)
        self.text3 = str(ans3_text)
        self.text4 = str(ans4_text)
        self.exp1 = str(exp1_text)
        self.exp2 = str(exp2_text)
        self.exp3 = str(exp3_text)
        self.exp4 = str(exp4_text)
        self.ans = int(correct_ans)

        # creating Tkinter variables
        self.ans_input = IntVar()
        self.is_correct = BooleanVar()
        self.efbg = StringVar()
        self.is_correct_text = StringVar()
        self.exp_text = StringVar()

        # developer mode
        if dev:
            self.ans_input.set(self.ans)

        # questionwide bgcolor, fgcolor
        self.bgcolor = GrayScale(80)
        self.fgcolor = GrayScale(20)

        # creating parent frame
        self.parent_frame()
        self.question_frame()
Ejemplo n.º 12
0
 def displaySectionForPrincipal(self, subject):
     self.course = subject
     rows = 24
     columns = 3
     for row in range(rows):
         for column in range(columns):
             empty = Label(self)
             empty.grid(row=row, column=column, padx=1, pady=1, sticky="nsew")        
     label = Label(self, text=subject)
     label.grid(row=0, column=0, columnspan=3, padx=1, pady=1, sticky="nsew")
     self.sections = courseSections[subject].keys()
     self.noSection = IntVar()
     mb = Menubutton(self, text="Change Section")
     mb.menu = Menu(mb)
     mb["menu"] = mb.menu
     mb.menu.add_radiobutton(label=self.sections[0], value=0, 
                             variable=self.noSection, command=self.displaySection)
     mb.menu.add_radiobutton(label=self.sections[1], value=1, 
                             variable=self.noSection, command=self.displaySection)
     mb.grid(row=2, column=0, columnspan=2, padx=1, pady=1, sticky="nsew")
     def viewSection():
         self.displaySectionForPrincipal(subject.get())
     subject = StringVar()        
     subMb = Menubutton(self, text="Change Subject")
     subMb.menu=Menu(subMb)
     subMb["menu"] = subMb.menu
     for course, sections in courseSections.items():
         subMb.menu.add_radiobutton(label=course, value=course,
                                 variable=subject, command=viewSection)
     subMb.grid(row=2, column=2, padx=1, pady=1, sticky="nsew")
     self.displaySection()
Ejemplo n.º 13
0
    def create_widgets(self, frame, idx, set_active_layer, rename,
		       set_layer_state, set_color, context_menu):
	self.index.SetValue(idx)
	idx = (self.index,)
	self.button = UpdatedRadiobutton(frame, anchor = W, value = idx,
					 width = 10,
					 variable = self.active_var,
					 command = set_active_layer)
	self.button.bind('<ButtonPress-3>', context_menu)
	self.button.bind('<ButtonPress-2>', rename)
	self.button.bind('<Double-Button-1>', rename)
	self.var_visible = IntVar(frame)
	self.visible = UpdatedCheckbutton(frame, variable = self.var_visible,
					  indicatoron = 0, selectcolor = '',
					  command = set_layer_state,
					  args = idx)
	self.var_printable = IntVar(frame)
	self.printable = UpdatedCheckbutton(frame,
					    variable = self.var_printable,
					    indicatoron = 0, selectcolor = '',
					    command = set_layer_state,
					    args = idx)
	self.var_locked = IntVar(frame)
	self.locked = UpdatedCheckbutton(frame, variable = self.var_locked,
					 indicatoron = 0, selectcolor = '',
					 command = set_layer_state, args = idx)
	self.var_outlined = IntVar(frame)
	self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined,
					   indicatoron = 0, selectcolor = '',
					   command = set_layer_state,
					   args = idx)
	self.color = ColorButton(frame, command = set_color, args = idx,
				 width = 2,
				 dialog_master =
				 frame.master.master.master.master)
Ejemplo n.º 14
0
 def __init__(self, parent, *args, **kwargs):
     tk.Frame.__init__(self, parent, *args, **kwargs)
     self.parent = parent
     # GUI INIT: 2 sliders and 1 button
     self.t = tk.Scale(troughcolor="light yellow",
                       from_=100,
                       to=-100,
                       width=40,
                       length=200)
     self.t.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
     self.s = tk.Scale(troughcolor="light cyan",
                       from_=-100,
                       to=100,
                       width=40,
                       length=250,
                       orient=tk.HORIZONTAL)
     self.s.pack(side=tk.LEFT, fill=tk.X)
     self.after(50, self.timer)
     self.b = tk.Button(bg="light green",
                        repeatdelay=1,
                        repeatinterval=50,
                        width=10,
                        height=2,
                        text="SERVO",
                        command=self.buttonCallback)
     self.b.pack(side=tk.LEFT)
     self.mode_control = IntVar()
     self.m = tk.Checkbutton(text="PRO MODE", variable=self.mode_control)
     self.m.pack()
Ejemplo n.º 15
0
    def show_Binary(self):  ## input Thresh_Binary

        if (hasattr(self, 'ThBinary')):
            #(self.varHigh.get()> self.varLow.get())
            self.ThBinary.deiconify()
        else:
            self.ThBinary = Tk()
            self.ThBinary.geometry("350x100+350+350")
            self.ThBinary.title("Binary")
            self.scale_L = Scale(self.ThBinary,
                                 from_=255,
                                 to=0,
                                 command=self.onScale_L)
            self.scale_L.pack(side=LEFT, padx=10)

            self.varLow = IntVar()
            self.label1 = Label(self.ThBinary, text="LOW")
            self.label1.pack(side=LEFT, padx=0)

            self.scale_H = Scale(self.ThBinary,
                                 from_=255,
                                 to=0,
                                 command=self.onScale_H)
            self.scale_H.pack(side=LEFT, padx=20)

            self.varHigh = IntVar()
            self.label2 = Label(self.ThBinary, text="HIGH")
            self.label2.pack(side=LEFT, padx=1)

            binary = Button(self.ThBinary,
                            text="OK",
                            width=5,
                            background="green",
                            command=self.getdata_Binary)
            binary.pack(side=LEFT)
Ejemplo n.º 16
0
    def __init__(self, pvapp, top):
        """
        Constructor
        """
        self.pvapp = pvapp
        Frame.__init__(self, top)
        self.pack(expand=True)  # if user resizes, expand Frame
        self.pack(fill='both')
        self.focus_set()  # get the focus
        self.grab_set()  # make this window modal

        self['bg'] = 'black'  # set black background
        self['padx'] = '15'  # pad sides with 15 points
        self['pady'] = '5'  # pad top/bottom 5 points
        self.master.title('PVmodule')  # set title bar
        self.SPlogoLabel = Label(self,
                                 image=self.pvapp.SPlogo,
                                 cnf={'borderwidth': '0'})
        self.SPlogoLabel.pack({'side': 'top'})

        self.numberCells = IntVar(self)  # bind numberCells
        self.numberCells.set(MODULE_SIZES[0])  # default value
        # pylint: disable = W0142
        self.numberCellsOption = OptionMenu(self, self.numberCells,
                                            *MODULE_SIZES)
        # pylint: enable = W0142
        self.numberCellsOption.pack({'side': 'top', 'fill': 'both'})

        self.QUIT = Button(self, cnf={'text': 'Quit', 'command': self.quit})
        self.QUIT.pack({'side': 'top', 'fill': 'both'})
Ejemplo n.º 17
0
    def initUI(self):
        self.parent.title("simple")

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(3, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(4, pad=3)

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W + E)

        cls = Button(self, text="Cls")
        cls.grid(row=1, column=0)

        quitbutton = Button(self, text="quit", command=self.parent.destroy)
        quitbutton.grid(row=4, column=0)

        self.var = IntVar()

        cb = Checkbutton(self,
                         text="show title",
                         variable=self.var,
                         command=self.onClick)
        cb.select()
        cb.grid(row=2, column=2)
        self.pack()
Ejemplo n.º 18
0
class Transmitter(object):
    def __init__(self, sstv, root, progress):
        def encode_line_hooked(line):
            progress.update_image(line)
            return self.original_encode_line(line)
        self.progress = progress
        self.sstv = sstv
        self.original_encode_line = sstv.encode_line
        sstv.encode_line = encode_line_hooked
        self.root = root
        self.tx_enabled = IntVar()
        self.audio_thread = None
        self.stopping = False

    def start_stop_tx(self):
        if self.tx_enabled.get():
            self.stopping = False
            self.audio_thread = AudioThread(self.sstv, self)
            self.audio_thread.start()
        else:
            self.stop()
            if self.progress is not None:
                self.progress.update_image()

    def stop(self):
        if self.audio_thread is not None:
            self.stopping = True
            self.audio_thread.stop()

    def audio_thread_ended(self):
        if not self.stopping:
            self.tx_enabled.set(0)

    def close(self):
        self.root.destroy()
Ejemplo n.º 19
0
    def initUI(self):

        self.parent.title("Listbox + Scale + ChkBtn")
        self.pack(fill=BOTH, expand=1)
        acts = ['Scarlett Johansson', 'Rachel Weiss',
            'Natalie Portman', 'Jessica Alba']

        lb = Listbox(self)
        for i in acts:
            lb.insert(END, i)

        lb.bind("<<ListboxSelect>>", self.onSelect)
        lb.place(x=20, y=20)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.place(x=20, y=190)

        scale = Scale(self, from_=0, to=100, command=self.onScale)
        scale.place(x=20, y=220)

        self.var_scale = IntVar()
        self.label_scale = Label(self, text=0, textvariable=self.var_scale)
        self.label_scale.place(x=180, y=220)

        self.var_chk = IntVar()
        cb = Checkbutton(self, text="Test", variable=self.var_chk,
                command=self.onClick)
        cb.select()
        cb.place(x=220, y=60)
Ejemplo n.º 20
0
def init():
    """初始化页面"""
    global face_file_list, face_image, face_label, detect_label

    all_files = os.listdir(image_dir)
    face_file_list = filter(lambda x: x.endswith('jpg'), all_files)
    get_face_record(offset)


    place_image(offset)
    face_image = Label(master, image=tk_image)
    face_image.place(anchor=u'nw', x=10, y=40)

    face_label = IntVar()
    face_label.set(face_record.label)
    score_ugly = Radiobutton(master, text=u'丑', variable=face_label,
                             value=0, command=set_face_label)
    score_ugly.place(anchor=u'nw', x=120, y=10)
    score_normal = Radiobutton(master, text=u'一般', variable=face_label,
                               value=1, command=set_face_label)
    score_normal.place(anchor=u'nw', x=160, y=10)
    score_pretty = Radiobutton(master, text=u'漂亮', variable=face_label,
                               value=2, command=set_face_label)
    score_pretty.place(anchor=u'nw', x=220, y=10)

    detect_label = Label(master, text=u'')
    detect_label.place(anchor=u'nw', x=580, y=10)

    handle_detect()
Ejemplo n.º 21
0
    def _init_menu(self):

        self._menubar = Menu(self._parent)
        menubar = self._menubar
        self._parent.config(menu=menubar)

        #new_menu = Menu(menubar, tearoff=0)
        #new_menu.add_command(label="Billiard Table", command=self.on_new_similarity_surface)

        file_menu = Menu(menubar, tearoff=0)
        #file_menu.add_cascade(label="New", menu=new_menu)
        file_menu.add_command(label="Octagon", command=self.add_octagon)
        file_menu.add_command(label="MegaWollmilchsau",
                              command=self.add_mega_wollmilchsau)
        file_menu.add_separator()
        file_menu.add_command(label="About", command=self.on_about)
        file_menu.add_command(label="Export PostScript",
                              command=self.on_export)
        file_menu.add_command(label="Exit",
                              command=self.exit,
                              accelerator="Alt+F4")
        menubar.add_cascade(label="File", underline=0, menu=file_menu)

        self._surface_menu = Menu(menubar, tearoff=0)
        self._selected_surface = IntVar()
        self._selected_surface.set(-1)
        menubar.add_cascade(label="Surface",
                            underline=0,
                            menu=self._surface_menu)
        self._surface_menu.add_radiobutton(label="None",
                                           command=self.menu_select_surface,
                                           variable=self._selected_surface,
                                           value=-1)
Ejemplo n.º 22
0
    def __init__(self, tree, settings):
        self._trees = (tree,)

        self._top = Tk()

        cf = self._cframe = CanvasFrame(self._top)

        # Size is variable.
        self._size = IntVar(self._top)
        self._size.set(12)
        bold = (settings["font"], -int(12 * settings["scale"]), "bold")
        norm = (settings["font"], -int(12 * settings["scale"]))

        self._width = 1
        self._widgets = []
        widget = TreeWidget(
            cf.canvas(),
            tree,
            node_font=bold,
            leaf_color=settings["terminal_color"],
            node_color=settings["nonterminal_color"],
            roof_color="#004040",
            roof_fill="white",
            line_color="#004040",
            leaf_font=norm,
        )
        widget["xspace"] = int(settings["scale"] * widget["xspace"])
        widget["yspace"] = int(settings["scale"] * widget["yspace"])
        self._widgets.append(widget)
        cf.add_widget(widget, 0, 0)

        self._layout()
        self._cframe.pack(expand=1, fill="both", side="left")
    def __init__(self, parent):
        
        self.serialStatus = False

        #create variables
        self.startmotor = BooleanVar()
        self.logstate = BooleanVar()
        self.loggedData = []
        self.throttlevar = StringVar()
        self.throttleval = IntVar()

        #default values
        self.throttlevar.set("0%")
        self.throttleval.set(0)

        #base frame init
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initUI()
        self.centerWindow()

        self.PERIOD_LENGTH_Log = 100 #milliseconds
        self.PERIOD_LENGTH_Scan = 1000 #milliseconds
        self.PERIOD_LENGTH_Refresh = 300 #milliseconds

        self.parent.after(0, self.runScan)
        self.parent.after(0, self.runLog)
        self.parent.after(0, self.runRefresh)
Ejemplo n.º 24
0
    def __initUI(self, grid):
        self.parent.title("Sudoku")
        self.pack(fill=BOTH, expand=1)
        self.canvas = Canvas(self, width=self.WIDTH, height=self.HEIGHT)
        self.canvas.pack(fill=BOTH, side=TOP)
        clear_button = Button(self, text="Clear answers")

        var1 = IntVar()
        Checkbutton(self, text="Sudoku", variable=var1).pack(side=LEFT)
        self.var2 = IntVar()
        Checkbutton(self, text="N Queens", variable=self.var2).pack(side=LEFT)
        self.entry = Entry(self)
        self.entry.pack(side=LEFT)

        solve_button = Button(self, text="Solve!", command=self.__solve)
        load_Button = Button(self, text="Load data", command=self.__loadData)
        load_Button.pack(side=RIGHT)
        solve_button.pack(side=LEFT)
        clear_button.pack(fill=BOTH, side=BOTTOM)

        self.__draw_grid(10)
        self.__draw_puzzle(grid)

        self.canvas.bind("<Button-1>", self.__cell_clicked)
        self.canvas.bind("<Key>", self.__key_pressed)
Ejemplo n.º 25
0
 def __init__(self, parent, subject):
     print("Controller : __init__")
     self.subject = subject
     self.amp = IntVar()
     self.scale_amp = Scale(parent,
                            variable=self.amp,
                            label="Amplitude",
                            orient="horizontal",
                            length=250,
                            from_=0,
                            to=5,
                            relief="sunken",
                            sliderlength=20,
                            tickinterval=1,
                            command=self.update_amplitude)
     self.freq = IntVar()
     self.scale_freq = Scale(parent,
                             variable=self.freq,
                             label="Frequence",
                             orient="horizontal",
                             length=250,
                             from_=0,
                             to=5,
                             relief="sunken",
                             sliderlength=20,
                             tickinterval=1,
                             command=self.update_frequence)
Ejemplo n.º 26
0
class waitWidget(Frame):  # pylint: disable=R0924,R0904
    """
    A wait widget that shows something is happening.
    """
    def __init__(self, queue, master):
        self.queue = queue
        Frame.__init__(self, master)
        self.pack(fill="both")
        self.focus_set()  # get the focus
        self.grab_set()  # make this window modal
        master.resizable(False, False)  # not resizable
        master.title("")  # no title
        # don't let user close window using X - instead call timer
        master.protocol("WM_DELETE_WINDOW", self.timer)
        self.wait = IntVar(master, 0, "wait")
        Label(master, bitmap="hourglass").pack(fill="both")
        Label(master, text="Please wait ...").pack(fill="both")
        Label(master, textvariable=self.wait).pack(fill="both")
        self.timer()

    def timer(self):
        """
        A callback that counts milliseconds until SELF.QUEUE has somthing in it
        """
        wait = self.wait.get() + 1
        if not self.queue.empty():
            # when queue is filled, quit loop and print elapsed time
            logging.debug('elapsed time = %2.1f [s]', wait * 0.10)
            self.quit()
        self.wait.set(wait)
        # loop over this callback every 100[ms] until queue is filled
        self.after(100, self.timer)
Ejemplo n.º 27
0
	def init(self, master):
		PluginPanel.init(self, master)

		top = TFrame(self.panel, style='FlatFrame', borderwidth=5)
		top.pack(side = TOP, fill=BOTH)

		sign = TFrame(top, style='RoundedFrame', borderwidth=5)
		sign.pack(side = TOP)

		self.sign=TLabel(sign, image='shaping_trim')
		self.sign.pack(side=TOP)

		button = UpdatedButton(top, text = _("Apply"),
								command = self.apply_action,
								sensitivecb = self.is_correct_selection)
		button.pack(side = BOTTOM, expand = 1, fill = X)
		self.Subscribe(SELECTION, button.Update)
		
		button_frame = TFrame(top, style='FlatFrame', borderwidth=1)
		button_frame.pack(side = BOTTOM, fill=X, pady=5)
				
		self.var_originals = IntVar(top)
		self.var_originals.set(0)
		
		self.autoupdate_check = TCheckbutton(button_frame, text = _("Leave originals"), 
											variable = self.var_originals)
		self.autoupdate_check.pack(side = LEFT, anchor=W, padx=10)

		self.init_from_doc()
		self.subscribe_receivers()
Ejemplo n.º 28
0
 def input_input_checkbox(self, e):
     var = IntVar(master=self.frame)
     self.master.serialized[e.name] = lambda: var.get() and True or False
     if e.default is not None:
         var.set(e.default)
     w = Checkbutton(self.frame, text=self.compile_text(e.label), variable=var)
     self.pack_element(w)
Ejemplo n.º 29
0
class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent
        self.initUI()

    def initUI(self):

        self.parent.title("Scale")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        scale = Scale(self, from_=0, to=100, command=self.onScale)
        scale.place(x=20, y=20)

        self.var = IntVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.place(x=130, y=70)

    def onScale(self, val):

        v = int(float(val))
        self.var.set(v)
Ejemplo n.º 30
0
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.observers = []

        self.CLASS_NAME = [
            'Class {0}'.format(i + 1) for i in range(MAX_NUMBER_OF_CLASSES)
        ]

        self.selected_class = IntVar()
        self.class_buttons = {}
        for i in range(MAX_NUMBER_OF_CLASSES):
            class_button = Radiobutton(self,
                                       text=self.CLASS_NAME[i],
                                       fg=CLASS_COLOR[i],
                                       state='disabled',
                                       variable=self.selected_class,
                                       value=i,
                                       command=self._on_sample_class_selection)
            class_button.pack(anchor='w', padx=5)
            self.class_buttons[i] = class_button

        self.label = Label(self)
        self.label.pack()

        self.class_number = DEFAULT_NUMBER_OF_CLASS
        self.samples = [[]] * MAX_NUMBER_OF_CLASSES
        self.samples_coordinates = [[]] * MAX_NUMBER_OF_CLASSES
        self.select_default_class()
Ejemplo n.º 31
0
class NumberOfClasses(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        
        number_of_classes_label = Label(self, text = 'Number of classes: ')
        number_of_classes_label.grid(row = 0, column = 0)
        
        number_options = range(DEFAULT_NUMBER_OF_CLASS, MAX_NUMBER_OF_CLASSES+1)
        self.selected_number = IntVar(self, value = DEFAULT_NUMBER_OF_CLASS)
        option_menu = OptionMenu(self, self.selected_number, *number_options, 
                                 command = self._on_number_selection)
        option_menu.grid(row = 0, column = 1)

        self.observers = []
        
    def register_observer(self, observer):
        self.observers.append(observer)
    
    def notify_observers(self, class_number):
        for observer in self.observers:
            observer.set_class_number(class_number)
        
    def _on_number_selection(self, selected_number):
        self.notify_observers(selected_number)
    
    def get(self):
        return self.selected_number.get()
    
    def reset(self):
        self.selected_number.set(DEFAULT_NUMBER_OF_CLASS)
Ejemplo n.º 32
0
    def __init__(self, master, track, sequencer):
        TrackFrame.__init__(self, master, track)

        self.id_label = Label(self, text=str(track.id))
        self.id_label.pack(side='left')

        self.instrument_label = Label(self, text=str(track.instrument_tone), width=3)
        self.instrument_label.pack(side='left')

        mute_var = IntVar()

        self.mute_toggle = Checkbutton(self, command=lambda: check_cmd(track, mute_var), variable=mute_var)
        self.mute_toggle.pack(side='left')

        mute_var.set(not track.mute)

        rhythm_frame = Frame(self)
        rhythm_frame.pack(side='right')

        subdivision = sequencer.measure_resolution / sequencer.beats_per_measure

        self.buttons = []

        for b in range(0, len(self.track.rhythms)):
            button = RhythmButton(rhythm_frame, track, b, not b % subdivision)
            self.buttons.append(button)
            button.grid(row=0, column=b, padx=1)

        self.beat = 0
Ejemplo n.º 33
0
class NumberOfClasses(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent

        number_of_classes_label = Label(self, text='Number of classes: ')
        number_of_classes_label.grid(row=0, column=0)

        number_options = range(DEFAULT_NUMBER_OF_CLASS,
                               MAX_NUMBER_OF_CLASSES + 1)
        self.selected_number = IntVar(self, value=DEFAULT_NUMBER_OF_CLASS)
        option_menu = OptionMenu(self,
                                 self.selected_number,
                                 *number_options,
                                 command=self._on_number_selection)
        option_menu.grid(row=0, column=1)

        self.observers = []

    def register_observer(self, observer):
        self.observers.append(observer)

    def notify_observers(self, class_number):
        for observer in self.observers:
            observer.set_class_number(class_number)

    def _on_number_selection(self, selected_number):
        self.notify_observers(selected_number)

    def get(self):
        return self.selected_number.get()

    def reset(self):
        self.selected_number.set(DEFAULT_NUMBER_OF_CLASS)
Ejemplo n.º 34
0
 def __init__(self, canvas, parent, item, menuList=[]):
     self.canvas = canvas
     self.parent = parent
     self.item = item
     self.state = 'collapsed'
     self.selected = 0
     self.children = {}
     self.kidKeys = []
     self.x = self.y = None
     self.iconimages = {}  # cache of PhotoImage instances for icons
     self.menuList = menuList
     self.menuVar = IntVar()
     self.menuVar.set(0)
     self._popupMenu = None
     self.image_id = None
     if self.menuList:
         if self.menuList[-1] == 'Separator':
             self.menuList = self.menuList[:-1]
         self._popupMenu = Menu(self.canvas, tearoff=0)
         for i in range(len(self.menuList)):
             item = self.menuList[i]
             if item == 'Separator':
                 self._popupMenu.add_separator()
             else:
                 self._popupMenu.add_radiobutton(
                     label=item,
                     variable=self.menuVar,
                     value=i,
                     indicatoron=0,
                     command=self.popupMenuCommand)
Ejemplo n.º 35
0
class Example(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent        
        self.initUI()
        
        
    def initUI(self):
      
        self.parent.title("Scale")
        self.style = Style()
        self.style.theme_use("default")        
        
        self.pack(fill=BOTH, expand=1)

        scale = Scale(self, from_=0, to=100, 
            command=self.onScale)
        scale.pack(side=LEFT, padx=15)

        self.var = IntVar()
        self.label = Label(self, text=0, textvariable=self.var)        
        self.label.pack(side=LEFT)
        

    def onScale(self, val):

        v = int(float(val))
        self.var.set(v)
Ejemplo n.º 36
0
    def __init__(self, master, mech):
        self.mech = mech
        frame = Frame(master)
        frame.grid()
        rct_label = Label(frame, text='Select Reactants')
        rct_label.grid(column=1, row=1)
        and_or = Label(frame, text='AND/OR')
        and_or.grid(column=3, row=1)
        prod_label = Label(frame, text='Select Products')
        prod_label.grid(column=4, row=1)
        what_to_do = Label(frame, text='Execute')
        what_to_do.grid(column=6, row=1)
        reactants_scrollbar = Scrollbar(frame, orient=VERTICAL)
        self.reactants = Listbox(frame,
                                 selectmode=EXTENDED,
                                 exportselection=0,
                                 yscrollcommand=reactants_scrollbar.set)
        self.reactants.grid(column=1, row=2)
        reactants_scrollbar.config(command=self.reactants.yview)
        reactants_scrollbar.grid(column=2, row=2, sticky=N + S)

        self.logical_and = IntVar()
        self.logical_and.set(1)
        c = Checkbutton(frame, text="AND", variable=self.logical_and)
        c.grid(column=3, row=2)

        products_scrollbar = Scrollbar(frame, orient=VERTICAL)
        self.products = Listbox(frame, selectmode=EXTENDED, exportselection=0)
        self.products.grid(column=4, row=2)
        products_scrollbar.config(command=self.products.yview)
        products_scrollbar.grid(column=5, row=2, sticky=N + S)

        self.method_list = Listbox(frame,
                                   selectmode=EXTENDED,
                                   exportselection=0)
        self.method_list.grid(column=6, row=2)
        #self.methods = [k for k in dir(self.mech) if k[:1] != '_' and isinstance(getattr(self.mech, k), MethodType)]
        self.methods = [
            'plot_rxns', 'find_rxns', 'print_rxns', 'print_irrs',
            'print_net_rxn', 'plot_proc'
        ]
        method_labels = [
            'Plot Reactions', 'Show Rxn Ids', 'Print Rxns', 'Print IRRs',
            'Print Net Rxn', 'Process Plot'
        ]
        for method in method_labels:
            self.method_list.insert(END, method)

        species_keys = self.mech.species_dict.keys()
        species_keys.sort()
        self.species_objects = [
            self.mech.species_dict[spc] for spc in species_keys
        ]

        for spc in species_keys:
            self.reactants.insert(END, spc)
            self.products.insert(END, spc)
        self.execute_button = Button(frame, text="go", command=self.execute)
        self.execute_button.grid(column=6, row=4)
Ejemplo n.º 37
0
    def __init__(self, parent=None, width=800, height=800):
        """ initialisation

        parent : une application
        width,height : dimension de l'oscilloscpe
        """
        Frame.__init__(self)
        self.master.title("Oscilloscope")
        # Modelethreading.Thread(None, affiche, None, (200,), {'nom':'thread a'}) 
        self.time = 0
        self.signal = None
        # # Vues
        # self.menuBar         = MenuBar(parent=self)
        # self.screen          = Screen(parent=self)
        # self.frame = Frame(master=self)
        # # Controleurs
        # self.time_control = TimeBase(parent=self)
        # self.signal_controlX = Generator(parent=self, name="X", color="red")
        # self.signal_controlY = Generator(parent=self, name="Y", color="blue")
        # # Affichage Vues, Controleurs
        # self.menuBar.pack()
        # self.screen.pack()

        # self.signal_controlX.pack(side="left")
        # self.signal_controlY.pack(side="left")
        # self.time_control.pack()

        # Vues
        self.menuBar          = MenuBar(parent=self)
        self.screenT          = Screen(parent=self)
        self.screenXY         = Screen(parent=self)
        # Controleurs
        self.signal_controlX = Generator(parent=self, name="X", color="red")
        self.signal_controlY = Generator(parent=self, name="Y", color="blue")
        self.signal_controlXY = Generator(parent=self, name="XY", color="blue")
        self.time_control = TimeBase(parent=self)
        self.varX  = IntVar()
        self.varY  = IntVar()
        self.varXY = IntVar()
        self.showX = Checkbutton(parent, text="X", variable=self.varX, command=lambda: self.update_show("X"))
        self.showY = Checkbutton(parent, text="Y", variable=self.varY, command=lambda: self.update_show("Y"))
        self.showXY = Checkbutton(parent, text="XY", variable=self.varXY, command=lambda: self.update_show("XY"))
        self.varX.set(1)
        self.varY.set(1)
        self.varXY.set(1)

        # Affichage Vues, Controleurs
        self.menuBar.grid(column=0, row=0)
        self.screenT.grid(column=0,row=1)
        self.screenXY.grid(column=1,row=1)
        self.signal_controlX.grid(column=0, row=2)
        self.signal_controlY.grid(column=0, row=3)
        self.time_control.grid(column=0, row=4)

        self.showX.grid(column=1, row=2)
        self.showY.grid(column=1, row=3)
        self.showXY.grid(column=1, row=4)

        self.configure(width=width, height=height)
Ejemplo n.º 38
0
 def __init__(self, master, main_window, doc, info):
     self.var_auto_update = IntVar(master)
     self.var_auto_update.set(1)
     self.info = info
     self.title = info.menu_text
     self.vars = []
     name = 'dlg' + info.class_name
     PropertyPanel.__init__(self, master, main_window, doc, name = name)
Ejemplo n.º 39
0
 def test_invalid_value(self):
     v = IntVar(self.root, name="name")
     self.root.globalsetvar("name", "value")
     with self.assertRaises(ValueError):
         v.get()
     self.root.globalsetvar("name", "345.0")
     with self.assertRaises(ValueError):
         v.get()
Ejemplo n.º 40
0
 def test_invalid_value(self):
     v = IntVar(self.root, name='name')
     self.root.globalsetvar('name', 'value')
     with self.assertRaises(ValueError):
         v.get()
     self.root.globalsetvar('name', '345.0')
     with self.assertRaises(ValueError):
         v.get()
Ejemplo n.º 41
0
class MainApplication(tk.Frame):
    throttle = 0
    steering = 0
    mode = 0
    myRobot = BROBOT()

    def draw(self):
        print "DRAW"

    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        # GUI INIT: 2 sliders and 1 button
        self.t = tk.Scale(troughcolor="light yellow",
                          from_=100,
                          to=-100,
                          width=40,
                          length=200)
        self.t.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.s = tk.Scale(troughcolor="light cyan",
                          from_=-100,
                          to=100,
                          width=40,
                          length=250,
                          orient=tk.HORIZONTAL)
        self.s.pack(side=tk.LEFT, fill=tk.X)
        self.after(50, self.timer)
        self.b = tk.Button(bg="light green",
                           repeatdelay=1,
                           repeatinterval=50,
                           width=10,
                           height=2,
                           text="SERVO",
                           command=self.buttonCallback)
        self.b.pack(side=tk.LEFT)
        self.mode_control = IntVar()
        self.m = tk.Checkbutton(text="PRO MODE", variable=self.mode_control)
        self.m.pack()

    def buttonCallback(self):
        self.myRobot.servo(1)
        time.sleep(0.2)
        self.myRobot.servo(0)

    def timer(self):  # Timer at 50ms interval to read slider values
        if (self.t.get() != self.throttle):
            self.throttle = self.t.get()
            self.myRobot.throttle(self.throttle / 100.0)
            #print "THROTTLE:",self.throttle
        if (self.s.get() != self.steering):
            self.steering = self.s.get()
            self.myRobot.steering(self.steering / 100.0)
            #print "STEERING:",self.steering
        if (self.mode_control.get() != self.mode):
            self.mode = self.mode_control.get()
            self.myRobot.mode(self.mode)
            #print "MODE:",self.mode
        self.after(50, self.timer)
Ejemplo n.º 42
0
    def init(self, master):
        PluginPanel.init(self, master)

        self.initial_color = self.default_color
        self.current_color = copy.copy(self.initial_color)

        top = TFrame(self.panel, style='FlatFrame', borderwidth=5)
        top.pack(side=TOP, fill=BOTH)

        self.selector = ColorSpaceSelector(top, self.refresh_widgets,
                                           self.current_color, self.sign)
        self.selector.pack(side=TOP, expand=1, fill=X)

        self.picker = ColorChooserWidget(top, self.refresh_widgets,
                                         self.current_color)
        self.picker.pack(side=TOP, expand=1, fill=X)

        self.digitizer = ColorDigitizer(top, self.refresh_widgets,
                                        self.current_color)
        self.digitizer.pack(side=TOP, expand=1, fill=X)

        button = UpdatedButton(top,
                               text=_("Apply"),
                               command=self.apply_pattern,
                               sensitivecb=self.is_selection)
        button.pack(side=BOTTOM, expand=1, fill=X)
        self.Subscribe(SELECTION, button.Update)

        button_frame = TFrame(top, style='FlatFrame', borderwidth=1)
        button_frame.pack(side=BOTTOM, fill=X, pady=5)

        button = TButton(button_frame,
                         style='TSmallbutton',
                         text=' ',
                         image='small_colorpicker',
                         command=self.copy_from)
        button.pack(side=LEFT)
        tooltips.AddDescription(button, _("Copy From..."))

        button = TButton(button_frame,
                         style='TSmallbutton',
                         text=' ',
                         image='restore_color',
                         command=self.restore_color)
        button.pack(side=LEFT, padx=5)
        tooltips.AddDescription(button, _("Restore color"))

        self.var_autoupdate = IntVar(top)
        self.var_autoupdate.set(1)

        self.autoupdate_check = TCheckbutton(button_frame,
                                             text=_("Auto Update"),
                                             variable=self.var_autoupdate,
                                             command=self.init_from_doc)
        self.autoupdate_check.pack(side=RIGHT, anchor=W, padx=10)

        self.init_from_doc()
        self.subscribe_receivers()
Ejemplo n.º 43
0
class GUI(object):

    def __init__(self, master):
        self.master = master
        master.title("Calculator")
        self.calculator = Calculator()

        self.entered_number = 0

        self.total_label_text = IntVar()
        self.total_label = Label(master, textvariable=self.total_label_text)

        self.label = Label(master, text="Total:")

        vcmd = master.register(self.validate) # we have to wrap the command
        self.entry = Entry(master, validate="key", validatecommand=(vcmd, '%P'))

        self.add_button = Button(master, text="+", command=lambda: self.update("add"))
        self.subtract_button = Button(master, text="-", command=lambda: self.update("subtract"))
        self.reset_button = Button(master, text="Reset", command=lambda: self.update("reset"))

        # LAYOUT

        self.label.grid(row=0, column=0, sticky=W)
        self.total_label.grid(row=0, column=1, columnspan=2, sticky=E)

        self.entry.grid(row=1, column=0, columnspan=3, sticky=W+E)

        self.add_button.grid(row=2, column=0)
        self.subtract_button.grid(row=2, column=1)
        self.reset_button.grid(row=2, column=2, sticky=W+E)
        self.update_total()

    def update_total(self):
        self.total_label_text.set(self.calculator.total)

    def validate(self, new_text):
        if not new_text: # the field is being cleared
            self.entered_number = 0
            return True

        try:
            self.entered_number = int(new_text)
            return True
        except ValueError:
            return False

    def update(self, method):
        if method == "add":
            self.calculator.add(self.entered_number)
        elif method == "subtract":
            self.calculator.sub(self.entered_number)
        else: # reset
            self.calculator.reset()

        self.update_total()
        self.entry.delete(0, END)
Ejemplo n.º 44
0
class Checkbox(Checkbutton):
    def __init__(self, master, text, default=None, **args):
        self.var = IntVar()
        Checkbutton.__init__(self, master, text=text, variable=self.var, **args)
        if default is not None:
            self.var.set(default)

    def get(self):
        return self.var.get()
Ejemplo n.º 45
0
    def update_syntax(self, key=None):

        if not key is None: self.text_changed()
        for name in self.tag_names(): self.tag_delete(name)
        self.create_syntas_tags()

        #directives
        self.highlight_pattern("(#"+"|#".join(directives)+")", "directive")
        self.highlight_pattern("#[ ]*[define|include|ifndef|endif|pragma][ ]*.*", "directive")

        #decimal
        self.highlight_pattern("\y[\d]+\y", "number")

        #floats
        self.highlight_pattern("\y[\d]+\.[\d]+\y", "number")

        #bin
        self.highlight_pattern("\y0[Bb][01]+\y", "number")

        #hexa
        self.highlight_pattern("\y0[Xx][A-Fa-f\d]+\y", "number")

        #reserved
        self.highlight_pattern("("+"|".join(const)+")", "reserved")

        ##operators
        #self.highlight_pattern("[()\[\]{}<>=\-\+\*\\%#!~&^,]", "operators")

        #library.function
        self.highlight_pattern("[^0-9][a-zA-Z0-9_]*\.[^0-9][a-zA-Z0-9_][^\\(]*", "reserved")

        #double quotation
        self.highlight_pattern(r'"[^"\\]*(\\.[^"\\]*)*"', "dquot")

        #single quotation
        self.highlight_pattern(r"'[^'\\]*(\\.[^'\\]*)*'", "squot")

        #single line comment
        self.highlight_pattern(r'//[^\n]*', "scomment")

        #multi line comment
        start = self.index("1.0")
        end = self.index("end")
        self.mark_set("matchStart", start)
        self.mark_set("matchEnd", start)
        self.mark_set("searchLimit", end)

        count = IntVar()
        self.mark_set("searchLimit", "end")
        while True:
            index = self.search("/*", "matchEnd", "searchLimit", count=count, regexp=False)
            if index == "": break
            self.mark_set("matchStart", index)
            index = self.search("*/", "matchEnd", "searchLimit", count=count, regexp=False)
            self.mark_set("matchEnd", "%s+%sc" % (index, count.get()))
            self.tag_add("dcomment", "matchStart", "matchEnd")
Ejemplo n.º 46
0
class Calculator:

    def __init__(self, master):
        self.master = master
        master.title("Simple Calculator")

        self.total = 0
        self.entered_number = 0

        self.total_label_text = IntVar()
        self.total_label_text.set(self.total)
        self.total_label = Label(master, textvariable=self.total_label_text)

        self.label = Label(master, text="Result:")

        vcmd = master.register(self.validate) 
        self.entry = Entry(master, validate="key", validatecommand=(vcmd, '%P'))

        self.add_button = Button(master, text="+", command=lambda: self.update("add"))
        self.subtract_button = Button(master, text="-", command=lambda: self.update("subtract"))
        self.divide_button = Button(master, text="/", command=lambda: self.update("divide"))
        self.multipy_button = Button(master, text="*", command=lambda: self.update("multiply"))

        

        self.label.grid(row=0, column=0, sticky=W)
        self.total_label.grid(row=0, column=1, columnspan=4, sticky=E)

        self.entry.grid(row=1, column=0, columnspan=3, sticky=W+E)

        self.add_button.grid(row=2, column=0)
        self.subtract_button.grid(row=2, column=1)
        self.multiply_button.grid(row=2, column=2)
        self.divide_button.grid(row=2, column=3)

    def validate(self, new_text):
        if not new_text: 
            self.entered_number = 0
            return True

        try:
            self.entered_number = int(new_text)
            return True
        except ValueError:
            return False

    def update(self, method):
        if method == "add":
            self.total += self.entered_number
        elif method == "subtract":
            self.total -= self.entered_number
        else: # reset
            self.total = 0

        self.total_label_text.set(self.total)
        self.entry.delete(0, END)
Ejemplo n.º 47
0
 def __init__(self, parent=None, picks=[], side=LEFT, anchor=W, default=[]):
     Frame.__init__(self, parent)
     self.vars = []
     for i,pick in enumerate(picks):
         var = IntVar()
         chk = Checkbutton(self, text=pick, variable=var)
         chk.pack(side=side, anchor=anchor, expand=YES)
         if i< len(default):
             var.set(default[i])
         self.vars.append(var)
Ejemplo n.º 48
0
class Calculator:

    def __init__(self, master):
        self.master = master
        master.title("Calculator")

        self.total = 0
        self.entered_number = 0

        self.total_label_text = IntVar()
        self.total_label_text.set(self.total)
        self.total_label = Label(master, textvariable=self.total_label_text)

        self.label = Label(master, text="Total:")

        vcmd = master.register(self.validate) # we have to wrap the command
        self.entry = Entry(master, validate="key", validatecommand=(vcmd, '%P'))

        self.add_button = Button(master, text="+", command=lambda: self.update("add"))
        self.subtract_button = Button(master, text="-", command=lambda: self.update("subtract"))
        self.reset_button = Button(master, text="Reset", command=lambda: self.update("reset"))

        # LAYOUT

        self.label.grid(row=0, column=0, sticky=W)
        self.total_label.grid(row=0, column=1, columnspan=2, sticky=E)

        self.entry.grid(row=1, column=0, columnspan=3, sticky=W+E)

        self.add_button.grid(row=2, column=0)
        self.subtract_button.grid(row=2, column=1)
        self.reset_button.grid(row=2, column=2, sticky=W+E)

    def validate(self, new_text):
        if not new_text: # the field is being cleared
            self.entered_number = 0
            return True

        try:
            self.entered_number = int(new_text)
            return True
        except ValueError:
            return False

    def update(self, method):
        if method == "add":
            self.total += self.entered_number
        elif method == "subtract":
            self.total -= self.entered_number
        else: # reset
            self.total = 0

        self.total_label_text.set(self.total)
        self.entry.delete(0, END)
Ejemplo n.º 49
0
class Example(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent
        self.initUI()

    def initUI(self):

        self.parent.title("Listbox + Scale + ChkBtn")
        self.pack(fill=BOTH, expand=1)
        acts = ['Scarlett Johansson', 'Rachel Weiss',
            'Natalie Portman', 'Jessica Alba']

        lb = Listbox(self)
        for i in acts:
            lb.insert(END, i)

        lb.bind("<<ListboxSelect>>", self.onSelect)
        lb.place(x=20, y=20)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.place(x=20, y=190)

        scale = Scale(self, from_=0, to=100, command=self.onScale)
        scale.place(x=20, y=220)

        self.var_scale = IntVar()
        self.label_scale = Label(self, text=0, textvariable=self.var_scale)
        self.label_scale.place(x=180, y=220)

        self.var_chk = IntVar()
        cb = Checkbutton(self, text="Test", variable=self.var_chk,
                command=self.onClick)
        cb.select()
        cb.place(x=220, y=60)

    def onSelect(self, val):
        sender = val.widget
        idx = sender.curselection()
        value = sender.get(idx)
        self.var.set(value)

    def onScale(self, val):
        v = int(float(val))
        self.var_scale.set(v)

    def onClick(self):
        if self.var_chk.get() == 1:
            self.var.set("checked")
        else:
            self.var.set("unchecked")
Ejemplo n.º 50
0
class RadioButtonlist(ttk.Frame):
    def __init__(self,master=None,buttonnamelist=[],**kw):
        ttk.Frame.__init__(self, master=None, **kw)
        self.__buttonlist=[]
        self.__vat= IntVar()
        self.__vat.set(0)
        for i in range(len(buttonnamelist)):
            self.__buttonlist.append(ttk.Radiobutton(self,text=buttonnamelist[i],variable=self.__vat,value=i))
            self.__buttonlist[i].pack(anchor = 'nw',side = 'left',padx=5,pady=5)
    
    def getvalue(self):
        return self.__vat.get()
Ejemplo n.º 51
0
    def __init_grid(self):

        # Road list
        self.__roads_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=27, exportselection=0)
        for road in self.__roads:
            self.__roads_list_box.insert('end', road)

        # Nature list
        self.__natures_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=6, width=22, exportselection=0)
        for nature in self.__natures:
            self.__natures_list_box.insert('end', nature)

        # Start with all natures selected
        self.__natures_list_box.select_set(0, END)\

        # Days list
        self.__days_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=8, width=22, exportselection=0)
        for day in ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']:
            self.__days_list_box.insert('end', day)

        # Hours list
        self.__hours_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=24, width=7, exportselection=0)
        for hour in range(24):
            self.__hours_list_box.insert('end', hour)

        # Check button draw overall
        self.__draw_overall_var = IntVar()
        self.__draw_overall_check_box = \
            Checkbutton(self.__root, text = "Draw Overall Curve?",
                        variable = self.__draw_overall_var, onvalue = 1,
                        offvalue = 0, height=2, width = 20)

        # Check button draw nature
        self.__draw_nature_var = IntVar()
        self.__draw_nature_check_box = \
            Checkbutton(self.__root, text = "Draw Curve Per Nature?",
                        variable = self.__draw_nature_var, onvalue = 1,
                        offvalue = 0, height=2, width = 20)

        # Check button show data
        self.__show_data_var = IntVar()
        self.__show_data_var.set(1)
        self.__show_data_check_box = \
            Checkbutton(self.__root, text = "Show data?",
                        variable = self.__show_data_var, onvalue = 1,
                        offvalue = 0, height=2, width = 20)

        # Go button
        self.__go_button = Button(self.__root, text='GO', command = lambda: self.__generate_graph())

        # Errors text box
        self.__error_text_box = Text(self.__root, height=28, width=18, fg="red")
        self.__error_text_box.tag_config('justified', justify=CENTER)
Ejemplo n.º 52
0
    def __init__(self):
        # basics settings
        Tk.__init__(self)               # constructor of parent graphic class
        ### Variables
        # GUI variables
        self.nbshp = StringVar()    # number of shapefiles
        self.nbtab = StringVar()    # number of MapInfo files
        self.opt_doc = IntVar()  # option activer/désactiver l'export au format word
        self.opt_xls = IntVar()  # option activer/désactiver l'export au format excel
        self.opt_xml = IntVar()  # option activer/désactiver l'export au format xml

        # Dictionaries
        self.lang = {}
        self.blabla = {}
        self.profils = {}      # dictionnaire des profils existants

        # Settings
        self.deflang = 'Français'
        self.defcodlang = 'FR'
        self.defrep = './'
        self.defdoc = 1
        self.defxls = 0
        self.defxml = 0
        self.opt_doc.set(self.defdoc)    # activated by default
        self.opt_xls.set(self.defxls)
        self.opt_xml.set(self.defxml)

        # Load needed data
        self.load_settings()
        self.listing_lang()
        self.load_texts(self.defcodlang)
        self.profils[self.blabla.get('gui_nouvprofil')] = ""

        # Main frame basic settings
        self.focus_force()              # put the window on foreground
        self.resizable(width = True,      # freeze dimensions
                       height = False)
        self.iconbitmap('../data/images/metadator.ico')     # icon
        self.title(self.blabla.get('gui_titre'))
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # Frames
        FrGlobal('Global', self.blabla).grid(row = 1, column = 0,
                                             sticky = N+S+W+E, padx = 2, pady = 2)
        FrOptions('Settings', self.blabla, self.profils).grid(row = 2, column = 0,
                                             sticky = N+S+W+E, padx = 2, pady = 2)
        FrProgres('Progression', self.blabla).grid(row = 3, column = 0,
                                             sticky = N+S+W+E, padx = 2, pady = 2)
Ejemplo n.º 53
0
class Application(object):

    def __init__(self, root):
        self.counter = IntVar()
        self.counter.set(0)

        self.label = Label(root,
                           width=5,
                           font=("Helvetica", 20, "bold italic"),
                           textvariable=self.counter)
        self.label.pack(side="left")

        self.up = Button(root,
                         text="up",
                         background="RED",
                         command=self.increment)
        self.up.pack(side="left")

        self.down = Button(root,
                           text="down",
                           background="GREEN",
                           command=self.decrement)
        self.down.pack(side="left")

    def increment(self):
        self.counter.set(self.counter.get() + 1)

    def decrement(self):
        self.counter.set(max(0, self.counter.get() - 1))
Ejemplo n.º 54
0
class Application(object):

    def __init__(self, root):
        self.counter = IntVar()
        self.counter.set(0)

        self.label = Label(root, textvariable=self.counter)
        self.label.pack()

        self.button = Button(root, text="add one", command=self.increment)
        self.button.pack()

    def increment(self):
        self.counter.set(self.counter.get() + 1)
Ejemplo n.º 55
0
class SetDefaultPropertiesDlg(SKModal):

	title = _("Set Default Properties")

	def __init__(self, master, category):
		self.category = category
		SKModal.__init__(self, master, name='setdefaults')

	def build_dlg(self):

		root = self.top
		top = TFrame(root, style='FlatFrame', borderwidth=13)
		top.pack(side=TOP)

		label = TLabel(top, text=_("Please select the object categories whose\n default properties you want to change"))
		label.pack(side=TOP, anchor=W)
		frame = TFrame(top, style='FlatFrame', borderwidth=10)
		frame.pack(side=TOP)
		self.var_graphics_style = IntVar(top)
		self.var_graphics_style.set(0)
		if self.category != 'font':
			self.var_graphics_style.set(1)
		button = TCheckbutton(frame, text=_("Graphics Objects"), state=(self.category == 'font' and DISABLED or NORMAL), variable=self.var_graphics_style)
		button.pack(side=TOP, anchor=W)
		self.var_text_style = IntVar(top)
		self.var_text_style.set(0)
		if self.category == 'font':
			self.var_text_style.set(1)
		button = TCheckbutton(frame, text=_("Text Objects"), state=(self.category == 'line' and DISABLED or NORMAL), variable=self.var_text_style)
		button.pack(side=TOP, anchor=W)

		label = TLabel(top, style="HLine")
		label.pack(side=TOP, fill=BOTH)

		but_frame = TFrame(top, style='FlatFrame')
		but_frame.pack(side=TOP, fill=BOTH, expand=1)

		button = TButton(but_frame, text=_("Cancel"), command=self.cancel)
		button.pack(side=RIGHT, expand=1)

		button = TButton(but_frame, text=_("OK"), command=self.ok)
		button.pack(side=RIGHT, expand=1)


		root.resizable (width=0, height=0)

	def ok(self, *args):
		graph = self.var_graphics_style.get()
		text = self.var_text_style.get()
		self.close_dlg((graph, text))
Ejemplo n.º 56
0
	def search_pattern(self, pattern, tag, start="1.0", end="end", regexp=False):
		start = self.index(start)
		end = self.index(end)
		self.mark_set("matchStart", start)
		self.mark_set("matchEnd", start)
		self.mark_set("searchLimit", end)
		count = IntVar()
		while True:
			index = self.search(pattern, "matchEnd", "searchLimit", count=count, regexp=regexp)
			if index == "":
				break
			self.mark_set("matchStart", index)
			self.mark_set("matchEnd", "%s+%sc" % (index, count.get()))
			self.tag_add(tag, "matchStart", "matchEnd")
Ejemplo n.º 57
0
    def __init__(self,parent,view,lissajou,subjectSig,subjects):

        self.cursorFrame = Frame(parent)
        self.selectionFrame = Frame(self.cursorFrame)
        self.view = view
        self.lissajou = lissajou
        self.subjects = subjects
        self.subjectSig=subjectSig
        self.amp=IntVar()
        self.scale_amp=Scale(self.cursorFrame,variable=self.amp,
                          label="Amplitude",
                          orient="horizontal",length=250,from_=0,to=10,
                          sliderlength=50,tickinterval=1,showvalue=0,
                          command=self.update)
        self.freq=IntVar()
        self.scale_freq=Scale(self.cursorFrame,variable=self.freq,
                          label="Frequence",
                          orient="horizontal",length=250,from_=0,to=10,
                          sliderlength=50,tickinterval=0,showvalue=0,
                          command=self.update)
        self.offset=DoubleVar()
        self.scale_offset=Scale(self.cursorFrame,variable=self.offset,
                          label="Offset",
                          orient="horizontal",length=250,from_=-10.0,to=10.0,
                          sliderlength=50,tickinterval=5,showvalue=0,
                          command=self.update)

        self.phase=IntVar()
        self.scale_phase=Scale(self.cursorFrame,variable=self.phase,
                          label="Phase",
                          orient="horizontal",length=250,from_=-90,to=90,
                          sliderlength=10,tickinterval=45,showvalue=0,
                          command=self.update)


        self.voltVar = DoubleVar()
        self.voltVar.set(1)
        self.button1 = Radiobutton(self.selectionFrame, text="1V", variable=self.voltVar,
                                    value=1.0*5.0,command =lambda:self.update(None))
        self.button1.select()

        self.button2 = Radiobutton(self.selectionFrame, text="2V", variable=self.voltVar,
                                    value=2.0*5.0, command =lambda:self.update(None))

        self.button5 = Radiobutton(self.selectionFrame, text="5V", variable=self.voltVar,
                                    value=5.0*5.0, command =lambda:self.update(None))

        self.isOffsetVar= IntVar()
        self.isOffset = Checkbutton(self.selectionFrame,text = "Offset",variable = self.isOffsetVar,
                                    command =lambda:self.update(None))
Ejemplo n.º 58
0
 def __init__(self, master):
     Frame.__init__(self, master, width = 15)
     self.initComplete = False
     self.getVar = IntVar()
     self.postVar = IntVar()
     self.getCheckButton = Checkbutton(self, \
         text = "GET", width = 6, variable = self.getVar, \
         command = self.__singleSelectCommandGet, onvalue = 1, offvalue = 0)
     self.postCheckButton = Checkbutton(self, \
         text = "POST", width = 6, variable = self.postVar, \
         command = self.__singleSelectCommandPost, onvalue = 1, offvalue = 0)
     self.label = Label(self, text = "Use Method:", padx = 3)
     self.__boxComponents()
     self.initComplete = True
Ejemplo n.º 59
0
class CheckbuttonEntry(BaseWiget):
	def __init__(self,  parent, **kw):
		BaseWiget.__init__(self,parent, **kw)
		self.old_value = ""
		self.var = IntVar()
		self.cbtn = Checkbutton(self, text=self.caption, variable=self.var)
		self.cbtn.grid(row=1, column=0)
		self.var.trace("w", self._onChangeVariable)
		self.old_value = self.getValue()
		self.onEndSetupContent()



	#------------- интерфейс -------------#
	def setValue(self, value):
		print "setValue", value
		if self.old_value  == value:
			return

		self.old_value  = value
		self.var.set(value)


	def getValue(self):
		return self.var.get()

	def getDictValue(self):
		raise NotImplementedError

	def forceSave(self):
		"""принудительное сохранение"""
		self._onEndInput()



	#------------- внутренние методы -------------#	

	def _onEndInput(self):
		value = self.getValue()
		if self.old_value != value:
			self.onValueChangeEndByUser(self.old_value, value)
			self.old_value = value


	def _onChangeVariable(self, *event):
		value = self.getValue()
		if self.old_value == value:
			return
		self._onEndInput()
Ejemplo n.º 60
0
class PropertyPanel(SketchPanel):

    receivers = SketchPanel.receivers[:]

    def __init__(self, master, main_window, doc, *args, **kw):
	self.var_auto_update = IntVar(master)
	self.var_auto_update.set(1)
	apply(SketchPanel.__init__, (self, master, main_window, doc) +args, kw)

    receivers.append((SELECTION, 'selection_changed'))
    receivers.append((EDITED, 'selection_changed'))
    def selection_changed(self, *args):
	if self.var_auto_update.get():
	    self.Update()

    def create_std_buttons(self, master, update_from = 1):
	button_frame = Frame(master)

	button = Checkbutton(button_frame, text = _("Auto Update"),
			     variable = self.var_auto_update)
	button.pack(side = TOP, expand = 1, fill = X)

	if update_from:
	    button = UpdatedButton(button_frame, text = _("Update From..."),
				   command = self.update_from_object)
	    button.pack(side = TOP, expand = 1, fill = X)

	button = UpdatedButton(button_frame, text = _("Apply"),
			       command = self.do_apply,
			       sensitivecb = self.can_apply)
	button.pack(side = LEFT, expand = 1, fill = X)
	self.Subscribe(SELECTION, button.Update)
	button = UpdatedButton(button_frame, text = _("Close"),
			       command = self.close_dlg)
	button.pack(side = RIGHT, expand = 1, fill = X)

	return button_frame

    def update_from_object(self):
	self.main_window.canvas.PickObject(self.update_from_object_cb)

    def update_from_object_cb(self, obj):
	pass

    can_apply = SketchPanel.doc_has_selection

    def SetDocument(self, doc):
	SketchPanel.SetDocument(self, doc)
	self.selection_changed()