Esempio n. 1
0
class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

    def createWidgets(self):
        self.titleLabel = Label(self, text='please input number and digit !')
        self.titleLabel.pack()
        self.numberLabel = Label(self, text='number: ')
        self.numberLabel.pack()
        self.numberInput = Entry(self)
        self.numberInput.pack()
        self.digitLabel = Label(self, text='digit: ')
        self.digitLabel.pack()
        self.digitInput = Entry(self)
        self.digitInput.pack()
        self.runButton = Button(self, text='run', command=self.run)
        self.runButton.pack()
        self.quitButton = Button(self, text='quit', command=self.quit)
        self.quitButton.pack()

    # run Button
    def run(self):
        number = self.numberInput.get()
        digit = self.digitInput.get()

        with open('E:/pycharm/practice1/image/verify.txt', 'w') as f:
            verify = verify_str(number, digit)
            f.write(verify)

        tkMessageBox.showinfo('verify', verify)
class MyDialog:

    def __init__(self, parent):

        top = self.top = Toplevel(parent)

        Label(top, text="Approved user names separated by a comma\nEmpty to allow all.").pack()

        self.e = Entry(top)
        self.e.pack(padx=5)
        self.APPROVED_USERS = []
        self.ALLOW_ALL = False

        b = Button(top, text="OK", command=self.ok)
        b.pack(pady=5)

    def ok(self):

        print "value is", self.e.get()
        self.APPROVED_USERS = [x.strip().lower() for x in self.e.get().split(',') if len(x.strip())>0]
        if len(self.APPROVED_USERS)==0:
        	self.ALLOW_ALL=True
        print 'APPROVED_USERS', self.APPROVED_USERS
        print 'ALLOW_ALL', self.ALLOW_ALL

        self.top.destroy()
Esempio n. 3
0
class HomunculusDirectory(Homunculus):
    def __init__(self, params):
        Homunculus.__init__(self, params[0])
        self.title(settings.HOMUNCULUS_VERSION + settings.HMC_TITLE_DIRECTORY)

        self.geometry("640x50+" + str(int(self.winfo_screenwidth()/2 - 320)) + "+" +
                      str(int(self.winfo_screenheight()/2 - 25)))
        Label(self, text="Enter directory or say 'browse'", name="pathlabel").pack()
        self.content = StringVar()
        self.word_box = Entry(self, name="word_box", width=640, textvariable=self.content)
        self.word_box.pack()

    def xmlrpc_get_message(self):
        if self.completed:
            response = {"mode": "ask_dir"}
            response["path"] = self.word_box.get()

            Timer(1, self.xmlrpc_kill).start()
            self.after(10, self.withdraw)
            return response
        else:
            return None

    def _ask_directory(self):
        dir_opt = {}
        dir_opt['initialdir'] = os.path.expanduser('~')  #os.environ["HOME"]
        dir_opt['mustexist'] = False
        dir_opt['parent'] = self
        dir_opt['title'] = 'Please select directory'
        result = tkFileDialog.askdirectory(**dir_opt)
        self.content.set(result)

    def xmlrpc_do_action(self, action, details=None):
        if action == "dir":
            self.after(10, self._ask_directory)
Esempio n. 4
0
def test_tabs():
    a = Tk()
    n = Notebook( a, TOP )

    # uses the Notebook's frame
    f1 = Frame( n() )
    b1 = Button( f1, text="Ignore me" )
    e1 = Entry( f1 )
    # pack your widgets before adding the frame 
    # to the Notebook (but not the frame itself)!
    b1.pack( fill=BOTH, expand=1 )
    e1.pack( fill=BOTH, expand=1 )

    # keeps the reference to the radiobutton (optional)
    x1 = n.add_screen( f1, "Tab 1" )

    f2 = Frame( n() )
    # this button destroys the 1st screen radiobutton
    b2 = Button( f2, text='Remove Tab 1', command=lambda:x1.destroy() )
    b3 = Button( f2, text='Beep...', command=lambda:Tk.bell( a ) )
    b2.pack( fill=BOTH, expand=1 )
    b3.pack( fill=BOTH, expand=1 )

    f3 = Frame( n() )


    n.add_screen( f2, "Tab 2" )
    n.add_screen( f3, "Minimize" )
    a.mainloop()
Esempio n. 5
0
	def initUI(self):
		
		self.pack(fill=BOTH, expand=1)
		
		#create special frame for buttons at the top
		frame = Frame(self)
		frame.pack(fill=X)
		
		search = Entry(frame)
		
		def callback():
			#create new window
			main(Search.SearchFrontPage(search.get()))
		
		b = Button(frame, text="Search", width=5, command=callback)
		b.pack(side=RIGHT)
		search.pack(side=RIGHT)
		
		def login():
			#change login credentials
			self.credentials = reddituserpass.main()
			self.parent.destroy()
		
		login = Button(frame, text="Login", width=5, command=login)
		login.pack(side=LEFT)
		
		self.drawWindow()
 def create_widgets(self):
     self.name = StringVar(self.parent)
     self.fontSize = StringVar(self.parent)
     self.frameMain = Frame(self, borderwidth=2, relief=SUNKEN)
     self.frameMain.pack(side=TOP, expand=TRUE, fill=BOTH)
     self.messageInfo = Message(self.frameMain,
                                anchor=W,
                                justify=LEFT,
                                padx=5,
                                pady=5,
                                text=self.message)  #,aspect=200)
     entryName = Entry(self.frameMain, textvariable=self.name, width=30)
     entryName.focus_set()
     self.messageInfo.pack(padx=5, pady=5)  #, expand=TRUE, fill=BOTH)
     entryName.pack(padx=5, pady=5)
     frameButtons = Frame(self, pady=2)
     frameButtons.pack(side=BOTTOM)
     self.buttonOk = Button(frameButtons,
                            text='Ok',
                            width=8,
                            command=self.Ok)
     self.buttonOk.pack(side=LEFT, padx=5)
     self.buttonCancel = Button(frameButtons,
                                text='Cancel',
                                width=8,
                                command=self.Cancel)
     self.buttonCancel.pack(side=RIGHT, padx=5)
Esempio n. 7
0
def buscar(pattern, index):
    def listar(event):
        lista.delete(0, END)
        ix = open_dir(index)
        with ix.searcher() as searcher:
            query = QueryParser(pattern,
                                ix.schema).parse(unicode(entrada.get()))
            results = searcher.search(query)
            for r in results:
                lista.insert(END, r['titulo'])
                lista.insert(END, r['fecha'])
                lista.insert(END, r['username'])
                lista.insert(END, '')

    root = Tkinter.Toplevel()
    frame1 = Frame(root)
    entrada = Entry(frame1, bd=2, width=60)
    lab = Label(frame1, text="Buscar: ")

    entrada.bind("<Return>", listar)
    sc = Scrollbar(root)
    sc.pack(side=RIGHT, fill=Y)
    lista = Listbox(root, yscrollcommand=sc.set)
    frame1.pack(side=TOP)

    lista.pack(side=TOP, fill=BOTH)
    lab.pack(side=LEFT)
    entrada.pack(side=LEFT)
    sc.config(command=lista.yview)
    root.mainloop()
Esempio n. 8
0
 def addVar(self,
            names,
            lbs,
            ubs,
            tols,
            currValues,
            _name='',
            _lb='',
            _ub='',
            _tol='',
            _val=''):
     nameEntry, lb, ub, tol, valEntry = Entry(names), Entry(lbs), Entry(
         ubs), Entry(tols), Entry(currValues)
     nameEntry.insert(0, _name)
     lb.insert(0, _lb)
     ub.insert(0, _ub)
     tol.insert(0, _tol)
     valEntry.insert(0, _val)
     self.NameEntriesList.append(nameEntry)
     self.LB_EntriesList.append(lb)
     self.UB_EntriesList.append(ub)
     self.TolEntriesList.append(tol)
     self.ValueEntriesList.append(valEntry)
     nameEntry.pack(side='top')
     lb.pack(side='top')
     ub.pack(side='top')
     tol.pack(side='top')
     valEntry.pack(side='top')
Esempio n. 9
0
class ClsFrmKeyValue(Frame):
    """
    Класс обеспечивает работу с парой ключ:значение.
    """
    def __init__(self, root=None, key='Key', value='None'):
        """
        Конструтирует пару ключ:значение.
        :param root:
        :param key:
        :param value:
        :return:
        """
        self.__root = root
        Frame.__init__(self, master=root, border=2, relief='ridge')
        self.pack(fill='x', side='top')

        self.lbl_key = Label(self, text=key, border=1, relief='ridge', width=14)
        self.lbl_key.pack(side='left', fill='x', expand=1)

        self.ent_val = Entry(self, border=1, relief='groove')
        self.ent_val.pack(side='left', fill='x', expand=1)
        self.ent_val.delete(0, 'end')
        self.ent_val.insert(0, value)

    def get_val(self):
        """
        Возвращает значение ключа из пары ключ:значение.
        :return:
        """
        return self.ent_val.get()
Esempio n. 10
0
 def __init__(self, root, gui):
     Frame.__init__(self, root)
     self.gui = gui
     self.root = root
     
     #self.config(background="blue")
     #background_image = "images/rosemaling.gif"
     #self.image = PhotoImage(file=background_image)
     self.config(background="gainsboro")
     
     Label(self, text="BoothTool.py\nVersion A.01", background="gainsboro", height=20, width=root.winfo_width()).pack(side=TOP)
     Label(self, text="Username:"******"gainsboro", font=("Times", "20")).pack()
     
     text1 = Entry(self, font=("Times", "16"), background="gainsboro")
     text1.pack()
     
     Label(self, text="Password:"******"gainsboro", font=("Times", "20")).pack()
     
     text2 = Entry(self, show="*", font=("Times", "16"), background="gainsboro")
     text2.pack()
     
     Button(self, text="Login...", font=("Times", "20"), background="gainsboro", command=lambda: self.loginCommand(text1.get(), text2.get())).pack()
     self.root.bind("<Return>", lambda event: self.loginCommand(text1.get(), text2.get()))
     # make sure the frame has focus so the binding will work
     self.root.focus_set()
class App:
	def __init__(self,parent):
		# Create frame, buttons, etc
		self.f = Frame(parent)
		self.f.pack(padx=15,pady=15)
    
   		self.entry = Entry(self.f,text="Enter the search term")
		self.entry.pack(side= TOP,padx=10,pady=12)
		self.entry.bind("<Key>", self.key)
		self.entry.focus_set()
		
		self.exit = Button(self.f, text="Exit", command=self.f.quit)
		self.exit.pack(side=BOTTOM,padx=10,pady=10)

		self.button = Button(self.f, text="Search",command=self.search)
		self.button.pack(side=BOTTOM,padx=10,pady=10)

	def key(self, event):
		# If ENTER was pressed, search
		if event.char == '\r':
			self.search()

	def search(self):
		# If there's something to search, search!
		if self.entry.get() != '':
			self.button.config(text='Searching...', state=DISABLED)

			th = SearchThread(self, self.entry.get())
			th.start()
		else:
			tkMessageBox.showinfo('Hey', 'You should type something in the search. That\'s the point, really...')
Esempio n. 12
0
class Input(Frame):
    def __init__(self, master=None, text='', textvariable=None, is_big=False):
        Frame.__init__(self, master)
        self.text = text
        self.is_big = is_big
        self.textvariable = textvariable
        self.create_widget()

    def create_widget(self):
        self.create_text(self.text)
        self.create_entry(self.textvariable)
        self.pack_all()

    def create_text(self, text):
        self.text_label = Label(self, text=text)
        self.text_label['width'] = 16
        self.text_label['anchor'] = 'e'

    def create_entry(self, textvariable):
        self.entry = Entry(self, textvariable=textvariable)
        if self.is_big:
            self.entry['width'] = 60

    def pack_all(self):
        self.text_label.pack(side=Tkinter.LEFT)
        self.entry.pack()
Esempio n. 13
0
class LabelEntry(LabelBase):
    def __init__(self,
                 parent_frame,
                 label_text,
                 entry_text='',
                 on_input_callable=None):
        super(LabelEntry, self).__init__(parent_frame, label_text)
        self._on_input_callback = on_input_callable

        self._entry_var = StringVar(value=entry_text)
        self._entry = Entry(self._label_frame,
                            bd=3,
                            textvariable=self._entry_var)
        self._entry.bind('<Return>', self._entry_input)
        self._entry.pack(side=RIGHT)

    def _entry_input(self, event):
        #print 'Label [%s] text entered: %s' % (self.label_text, self.entry_text)
        #self.clear_entry()
        #self.label_text = self.entry_text
        if self._on_input_callback:
            self._on_input_callback()

    def clear_entry(self):
        self.entry_text = ''

    def set_entry_text(self, text):
        self._entry_var.set(text)

    def get_entry_text(self):
        return self._entry_var.get()

    entry_text = property(fget=get_entry_text, fset=set_entry_text)
Esempio n. 14
0
 def __init__(self, container, img=None, p=None):
     root = Tk()
     root.attributes('-topmost', 1)
     hint = '(Enter - submit, Esc - abort)'
     if img is None:
         root.wm_title('Address')
         hint = 'Please enter your Bitcoin address.\n' + hint
     else:
         root.wm_title('Captcha {0:g}'.format(p))
         img = ImageTk.PhotoImage(img)
         root.img_reference = img
     image = Label(root, image=img, text=hint, compound='top')
     image.pack()
     entry = Entry(root)
     entry.bind('<Escape>', lambda _: root.destroy())
     entry.bind(
         '<Return>', lambda _:
         (container.setdefault(0, (entry.get())), root.destroy()))
     entry.pack()
     entry.focus_set()
     root.update_idletasks()
     xp = (root.winfo_screenwidth() / 2) - (root.winfo_width() / 2) - 8
     yp = (root.winfo_screenheight() / 2) - (root.winfo_height() / 2) - 20
     root.geometry('+%d+%d' % (xp, yp))
     root.mainloop()
    def CreateWidgets(self):
        self.name = StringVar(self)
        self.fontSize = StringVar(self)
        self.frameMain = Frame(self, borderwidth=2, relief=SUNKEN)
        self.messageInfo = Label(self.frameMain, text=self.message)
        entryName = Entry(self.frameMain, textvariable=self.name, width=30)
        frameButtons = Frame(self)
        self.buttonOk = Button(frameButtons, text='Ok', command=self.Ok)
        self.buttonCancel = Button(frameButtons, text='Cancel',
                command=self.Cancel)

        entryName.focus_set()

        self.frameMain.pack(side=TOP, expand=True, fill=BOTH)
        self.messageInfo.pack(padx=5, pady=5)
        entryName.pack(padx=5, pady=5)
        frameButtons.pack(side=BOTTOM, fill=X)
        self.buttonOk.pack(padx=1, pady=5, side=RIGHT)
        self.buttonCancel.pack(pady=5, padx=5, side=RIGHT)

        if TTK:
            self.messageInfo['padding'] = 5
            frameButtons['style'] = 'RootColor.TFrame'
        else:
            self.messageInfo.configure(padx=5, pady=5)
Esempio n. 16
0
    def createfileentry(self, parent_frame, fi_text, _def_fi_, f_ex=None):
        ''' Quite self explanatoy...
            creates a row in which is possible to search for a file'''
        file_row = Frame(parent_frame)
        if f_ex == None:
            f_ex = ((fi_text, '.' + _def_fi_.split('.')[-1]), )

        _f_labels = format_dec([file_row, fi_text], _pack_=False)

        Efile = Entry(file_row, width=13)
        Efile.insert('end', _def_fi_)

        Efile.bind("<Key>", lambda e: "break")  # Magic

        Efile.xview_moveto(1)
        Bsearch = Button(file_row,
                         image=self.im_file,
                         command=(lambda El=Efile: self.browsefile(El, f_ex)))

        # Just packing
        format_dec(_f_labels, _create_=False)

        Efile.pack(side='left', expand='yes', fill='x')

        Bsearch.pack(side='right', padx=0, pady=0)
        file_row.pack(side='top', fill='x', pady=3)

        # For tracing purposes list appending
        return Efile
def create_file_entry(_master_, ups_frame, fi_text, _default_file):
    ''' Quite self explanatoy...
        creates a row in which is possible to search for a file'''
    file_row = Frame(ups_frame)
    f_ex = ((fi_text, '.' + _default_file.split('.')[-1]), )

    _f_labels = format_dec([file_row, fi_text], _pack_=False)

    Efile = Entry(file_row, width=13)
    Efile.insert(END, _default_file)
    Efile.xview_moveto(1)
    Bsearch = Button(file_row,
                     image=get_file_img(),
                     command=(lambda El=Efile: _master_.browsefile(El, f_ex)))

    # Just packing
    format_dec(_f_labels, _create_=False)

    Efile.pack(side='left', expand='yes', fill=X)

    Bsearch.pack(side='right', padx=0, pady=0)
    file_row.pack(side='top', fill=X, pady=3)

    # For tracing purposes list appending
    return Efile
Esempio n. 18
0
class InterpretHEXDialog(tkSimpleDialog.Dialog):
    """
    A simple dialog that allows the user to
    enter 3 byte hex codes that represent
    ektapro commands and converts them to human
    readable strings.
    """

    def body(self, master):
        self.title("Interpret Ektapro HEX Command Sequence")

        self.description = Label(master, text="Please enter 3 Byte HEX Code (for example: 03 1C 00):")
        self.description.pack(side=TOP, anchor=W)

        self.hexcommand = Entry(master, width=10)
        self.hexcommand.pack(side=TOP, anchor=W)

        return self.hexcommand

    def apply(self):
        inputString = self.hexcommand.get().replace(" ", "")

        if not len(inputString) == 6:
            tkMessageBox.showerror("Error", "Please enter exactly 3 Bytes (6 Characters)!")

        else:
            b1 = int(inputString[0:2], 16)
            b2 = int(inputString[2:4], 16)
            b3 = int(inputString[4:6], 16)
            message = str(EktaproCommand(b1, b2, b3))
            tkMessageBox.showinfo("Command Result", "Interpreted Command: " + message)
Esempio n. 19
0
class searchDialog(Toplevel):
        def __init__(self, parent, title):
                self.top = Toplevel(parent)
                self.top.wm_title(title)
                self.top.wm_minsize(width=300, height=400)
                self.top.bind("<Return>", self.searchThreader)
                self.top.bind("<Escape>", self.close)

                self.searchy = Text(self.top)
                self.searchy.config(wrap=WORD)
                self.search_entry = Entry(self.top)
                self.close = Button(self.top, text="Close", command=self.close)
                self.search_button = Button(self.top,
                                            text="Search",
                                            command=self.searchThreader)
                self.scrollbar = Scrollbar(self.top)

                self.scrollbar.pack(side=RIGHT, fill=Y, expand=0)
                self.searchy.config(yscrollcommand=self.scrollbar.set,
                                    state=DISABLED)
                self.searchy.pack(side=TOP, fill=BOTH, expand=1)
                self.search_entry.pack(side=LEFT, fill=X, expand=1)
                self.close.pack(side=RIGHT, fill=BOTH, expand=0)
                self.search_button.pack(side=RIGHT, fill=BOTH, expand=0)

                self.linker = HyperlinkManager(self.searchy)

        def close(self, event=None):
                global SEARCH
                SEARCH = None
                self.top.destroy()

        def putText(self, text):
                updateDisplay(text, self.searchy, self.linker)

        def clearSearch(self):
                self.searchy.config(state=NORMAL)
                self.searchy.delete(1.0, END)
                self.searchy.config(state=DISABLED)

        def searchThreader(self, event=None, text=None):
                self.sear = upThread(6, 'search', (self, text))
                self.sear.start()

        def search(self, toSearch=None):
                if toSearch is None:
                        keyword = self.search_entry.get()
                        self.search_entry.delete(0, END)
                else:
                        keyword = toSearch
                self.clearSearch()
                self.top.wm_title("Search - " + keyword)
                if keyword.split('@')[0] == '':
                        self.putText(
                            API.GetUserTimeline(
                                screen_name=keyword.split('@')[1]
                            )
                        )
                else:
                        self.putText(API.GetSearch(term=keyword))
Esempio n. 20
0
class InterpretHEXDialog(tkSimpleDialog.Dialog):
    """
    A simple dialog that allows the user to
    enter 3 byte hex codes that represent
    ektapro commands and converts them to human
    readable strings.
    """

    def body(self, master):
        self.title("Interpret Ektapro HEX Command Sequence")

        self.description = Label(master, \
                                 text="Please enter 3 Byte HEX Code (for example: 03 1C 00):")
        self.description.pack(side=TOP, anchor=W)

        self.hexcommand = Entry(master, width=10)
        self.hexcommand.pack(side=TOP, anchor=W)

        return self.hexcommand

    def apply(self):
        inputString = self.hexcommand.get().replace(' ', '')
        
        if not len(inputString) == 6:
            tkMessageBox.showerror("Error", "Please enter exactly 3 Bytes (6 Characters)!")
            
        else:            
            b1 = int(inputString[0:2], 16)
            b2 = int(inputString[2:4], 16)
            b3 = int(inputString[4:6], 16)
            message = str(EktaproCommand(b1, b2, b3))
            tkMessageBox.showinfo("Command Result", \
                                   "Interpreted Command: " + message)
Esempio n. 21
0
def _tabbed_pages(parent):
    # test dialog
    root = Tk()
    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
    root.geometry("+%d+%d" % (x, y + 175))
    root.title("Test tabbed pages")
    tabPage = TabbedPageSet(
        root,
        page_names=['Foobar', 'Baz'],
        n_rows=0,
        expand_tabs=False,
    )
    tabPage.pack(side=TOP, expand=TRUE, fill=BOTH)
    Label(tabPage.pages['Foobar'].frame, text='Foo', pady=20).pack()
    Label(tabPage.pages['Foobar'].frame, text='Bar', pady=20).pack()
    Label(tabPage.pages['Baz'].frame, text='Baz').pack()
    entryPgName = Entry(root)
    buttonAdd = Button(root,
                       text='Add Page',
                       command=lambda: tabPage.add_page(entryPgName.get()))
    buttonRemove = Button(
        root,
        text='Remove Page',
        command=lambda: tabPage.remove_page(entryPgName.get()))
    labelPgName = Label(root, text='name of page to add/remove:')
    buttonAdd.pack(padx=5, pady=5)
    buttonRemove.pack(padx=5, pady=5)
    labelPgName.pack(padx=5)
    entryPgName.pack(padx=5)
    root.mainloop()
Esempio n. 22
0
class LintGui:
    """Build and control a window to interact with pylint"""
    
    def __init__(self, root=None):
        self.root = root or Tk()
        self.root.title('Pylint')
        top_frame = Frame(self.root)
        res_frame = Frame(self.root)
        btn_frame = Frame(self.root)
        top_frame.pack(side=TOP, fill=X)
        res_frame.pack(side=TOP, fill=BOTH, expand=True)
        btn_frame.pack(side=TOP, fill=X)
        
        Label(top_frame, text='Module or package').pack(side=LEFT)
        self.txtModule = Entry(top_frame, background='white')
        self.txtModule.bind('<Return>', self.run_lint)
        self.txtModule.pack(side=LEFT, expand=True, fill=X)
        Button(top_frame, text='Run', command=self.run_lint).pack(side=LEFT)

        scrl = Scrollbar(res_frame)
        self.results = Listbox(res_frame,
                               background='white',
                               font='fixedsys',
                               selectmode='browse',
                               yscrollcommand=scrl.set)
        scrl.configure(command=self.results.yview)
        self.results.pack(side=LEFT, expand=True, fill=BOTH)
        scrl.pack(side=RIGHT, fill=Y)
        
        Button(btn_frame, text='Quit', command=self.quit).pack(side=BOTTOM)
        #self.root.bind('<ctrl-q>', self.quit)
        self.txtModule.focus_set()
        
    def mainloop(self):
        """lauch the mainloop of the application"""
        self.root.mainloop()

    def quit(self, _=None):
        """quit the application"""
        self.root.quit()

    def run_lint(self, _=None):
        """lauches pylint"""
        colors = {'W:':'red1', 'E:': 'red4',
                  'W:': 'red3', '**': 'navy'}
        
        self.root.configure(cursor='watch')
        self.results.focus_set()
        self.results.delete(0, END)
        self.results.update()
        module = self.txtModule.get()
        pout = os.popen('%s %s' % (PYLINT, module), 'r')
        for line in  pout.xreadlines():
            line = line.rstrip()
            self.results.insert(END, line)
            fg_color = colors.get(line[:2], 'black')
            self.results.itemconfigure(END, fg=fg_color)
            self.results.update()
        self.root.configure(cursor='')
class LintGui:
    """Build and control a window to interact with pylint"""
    
    def __init__(self, root=None):
        self.root = root or Tk()
        self.root.title('Pylint')
        top_frame = Frame(self.root)
        res_frame = Frame(self.root)
        btn_frame = Frame(self.root)
        top_frame.pack(side=TOP, fill=X)
        res_frame.pack(side=TOP, fill=BOTH, expand=True)
        btn_frame.pack(side=TOP, fill=X)
        
        Label(top_frame, text='Module or package').pack(side=LEFT)
        self.txtModule = Entry(top_frame, background='white')
        self.txtModule.bind('<Return>', self.run_lint)
        self.txtModule.pack(side=LEFT, expand=True, fill=X)
        Button(top_frame, text='Run', command=self.run_lint).pack(side=LEFT)

        scrl = Scrollbar(res_frame)
        self.results = Listbox(res_frame,
                               background='white',
                               font='fixedsys',
                               selectmode='browse',
                               yscrollcommand=scrl.set)
        scrl.configure(command=self.results.yview)
        self.results.pack(side=LEFT, expand=True, fill=BOTH)
        scrl.pack(side=RIGHT, fill=Y)
        
        Button(btn_frame, text='Quit', command=self.quit).pack(side=BOTTOM)
        #self.root.bind('<ctrl-q>', self.quit)
        self.txtModule.focus_set()
        
    def mainloop(self):
        """launch the mainloop of the application"""
        self.root.mainloop()

    def quit(self, _=None):
        """quit the application"""
        self.root.quit()

    def run_lint(self, _=None):
        """launches pylint"""
        colors = {'W:':'red1', 'E:': 'red4',
                  'W:': 'red3', '**': 'navy'}
        
        self.root.configure(cursor='watch')
        self.results.focus_set()
        self.results.delete(0, END)
        self.results.update()
        module = self.txtModule.get()
        pout = os.popen('%s %s' % (PYLINT, module), 'r')
        for line in  pout.xreadlines():
            line = line.rstrip()
            self.results.insert(END, line)
            fg_color = colors.get(line[:2], 'black')
            self.results.itemconfigure(END, fg=fg_color)
            self.results.update()
        self.root.configure(cursor='')
Esempio n. 24
0
 def add_entries(self,vl):
     for el in vl:
         if not hasattr(self.ea,el['name']):
             raise TypeError('you try to set up an entry for a name which is no attribute of the chosen EA')
         fr=Frame(self.f_actn); fr.pack()
         lab=Label(fr,text=el['name']); lab.pack()
         e = Entry(fr); e.pack(); e.insert(0,str(el['inival']))        # number of generations
         el['Entry']=e
class UsernameOverlay(Overlay):
    def __init__(self, *args, **kwargs):
        Overlay.__init__(self, *args, **kwargs)
        self.label = ""
        self.field = ""
        self.button = ""
        self.user = ""
        self.logger = JPYLogger(self)
        self.config(
            background="gold",
            cursor="arrow"
        )

        self.renderLabel()
        self.renderField()
        self.renderButton()

    def renderLabel(self):
        self.label = Label(self)
        self.label.config(
            text="CHANGE PLAYERNAME",
            font=Fonts.MONEY_BIG,
            background="gold"
        )
        self.label.pack()

    def renderField(self):
        self.field = Entry(self)
        self.field.config(
            relief="solid",
            bd=2,
            highlightcolor="black",
            font=Fonts.USER_LABEL_NAME_BIG
        )
        self.field.pack()

    def renderButton(self):
        Label(self, text='\n', background="gold").pack()
        self.button = Button(self)
        self.button.config(
            text="OK",
            relief="solid",
            background="black",
            foreground="gold",
            font=Fonts.MONEY_MEDIUM,
            command=self.save
        )
        self.button.pack()

    def save(self):
        self.logger.prompt("User " + str(self.user.id) + " changed name from '" + self.user.name.get() + "' to '" + self.field.get() + "'")
        self.user.name.set(self.field.get())
        self.hide(self)
        self.root.root.inputController.blockBuzzer = False

    def insert(self, user):
        self.field.delete(0, END)
        self.field.insert(0, user.name.get())
Esempio n. 26
0
class Header(Vue):
    """
    """

    def __init__(self, fenetre):
        """
        Initialiser la classe
        fenetre = fenetre parente ou seront collé les éléments
        """
        # La frame principale
        super(Header, self).__init__()
        self.frame = Frame(fenetre, borderwidth=1, relief="groove", width=40)
        self.titre = Label(self.frame, text=GT_("Entêtes"), font=(20))
        self.titre.pack()
        self.creer_zone_de_saisie()
        self.creer_liste()

    def visible(self):
        """
        Override the parent method for config element visibility
        """
        super(Header, self).visible(fill="both", side="right", pady=0)

    def creer_zone_de_saisie(self):
        """
        Générer la zone de saisie des parametres
        """
        # Créer la zone de saisie
        self.frame_saisie = Frame(self.frame, relief="groove", width=35, borderwidth=1)
        self.frame_saisie.pack(pady=10, padx=10, fill="both", side="top")
        self.label_nom = Label(self.frame_saisie, text="Nom")
        self.label_nom.pack()
        self.nom = Entry(self.frame_saisie)
        self.nom.pack(fill="both")
        self.label_valeur = Label(self.frame_saisie, text=GT_("Valeur"))
        self.label_valeur.pack()
        self.valeur = Entry(self.frame_saisie)
        self.valeur.pack(fill="both")
        self.btn_ajouter = Button(self.frame_saisie, text=GT_("Ajouter"))
        self.btn_ajouter.pack(side="top")

    def creer_liste(self):
        """
        Creer les elements affichant la liste de parametres
        """
        self.lsparam = TkListboxMulticolumn(self.frame, ((GT_("Nom"), 20), (GT_("Valeur"), 20)), relief="groove")
        self.lsparam.pack(expand="yes", fill="both")
        self.btn_delete = Button(self.frame, text=GT_("Supprimer"))
        self.btn_delete.pack(side="bottom")

    def set_liste(self, liste):
        """
        Update parameters list
        """
        self.lsparam.delete(0, "end")
        for key, value in liste.items():
            self.lsparam.insert("end", (key, value))
Esempio n. 27
0
class CoursePickWindow(Frame):
    def __init__(self, parent, courses):
        Frame.__init__(self, parent)

        self.parent = parent

        self.initUI()

        self._courses = courses

    def initUI(self):
        #make frame fill the rot window
        self.parent.title("Simple")
        self.pack(fill=BOTH, expand=1)

        #add text box to get course number
        self.entry_text = Entry(self)
        self.entry_text.pack()

        #add a button that will create a graph
        create_graph_button = Button(self,
                                     text="Create PNG Graph",
                                     command=self.create_PNG_graph)
        create_graph_button.pack()

        create_graph_button = Button(self,
                                     text="Create SVG Graph",
                                     command=self.create_SVG_graph)
        create_graph_button.pack()

    def create_graph(self):
        try:
            course_num = self.entry_text.get().strip()
        except ValueError:
            tkMessageBox.showerror(
                "not a valid num",
                "Please enter a valid " + "number with no letters")
            return

        if course_num not in self._courses:
            tkMessageBox.showerror("course not in database")
            return

        return course_num

    def create_PNG_graph(self):
        course_num = self.create_graph()
        #collect nodes and edges
        if course_num:
            self._courses[course_num].write_nexts_to_png(get_dot_exec())

    def create_SVG_graph(self):
        course_num = self.create_graph()
        #collect nodes and edges
        if course_num:
            self._courses[course_num].write_nexts_to_svg(get_dot_exec())
Esempio n. 28
0
class TkList(List):
	def __init__(self, file, tk):
		List.__init__(self, file)

		# Create the frame with list items
		self.frame = Frame(tk, padx = 0, pady = 10, bd = 0)
		self.frame.pack()

		# Create the field to input new list items
		self.input = Entry(tk, width = 32, bd = 1, insertborderwidth = 1, relief = FLAT)
		self.input.pack(anchor = N, pady = 4, side = LEFT, fill = X)
		self.input.focus_set()
		self.input.bind('<Return>', lambda l: self.add_item(self.input.get()))

		# Create an add button to the input field
		Button(tk, text = "+", relief = FLAT, command = lambda: self.add_item(self.input.get())).pack(anchor = N, side = RIGHT)

		# Update the list frame
		self.update()
		
	def add_item(self, text):
		List.add_item(self, text)

		# Clear input field
		self.input.delete(0, END)

		# Update the list frame
		self.update()

	def remove_item(self, text):
		List.remove_item(self, text)

		# Update the list frame
		self.update()

	def checkbox(self, text):

		# Return a button that will remove the list item
		return Button(self.frame, text = "-", relief = FLAT, command = lambda: self.remove_item(text))

	def update(self):

		# Remove previous list items
		for child in self.frame.winfo_children():
			child.destroy()

		# Draw each item in the list
		i = 0
		for item in self.list:
			self.checkbox(item).grid(row = i)
			Label(self.frame, text = item).grid(row = i, column = 1)
			i = i + 1

		# Save the list
		List.save_list(self)
Esempio n. 29
0
    def __init__(self, parent, callback, componentname, node, methodname, methodinfo):
        # TODO:
        # * Clean up (ownerships etc)
        # * parsing of args and interaction with them (export etc)
        super(TkRPCArgDialog, self).__init__()

        argspec = methodinfo['args']
        doc = methodinfo['doc']

        title = "%s@%s:%s" % (componentname, node, methodname)
        self.window.title(title)

        self.argspec = argspec
        self.callback = callback
        self.node = node
        self.componentname = componentname
        self.methodname = methodname

        self._methFrame = Frame(self.window)
        self._methLabel = Label(self._methFrame, text=title)
        self._methLabel.pack(fill='x', expand='yes', side='top')
        self._methDoc = Label(self._methFrame, text=doc)
        self._methDoc.pack(fill='x', expand='yes', side='bottom')
        self._methFrame.pack(fill='x', expand='yes', side='top')

        self.argEntries = {}
        self.argDocs = {}
        self._argsFrame = Frame(self.window)

        for arg in argspec:
            argFrame = Frame(self._argsFrame)
            argDocFrame = Frame(argFrame)
            argDoc = Label(argDocFrame, text=argspec[arg][1], height=3)
            argDoc.pack(fill='x', side="left")
            argDocFrame.pack(fill="x", expand="yes")

            argEntry = Entry(argFrame)
            #argEntry._textbox.config(height=1)
            argEntry.pack(fill='x', expand="yes", side="right")
            argLabel = Label(argFrame, text="%s (%s)" % (arg, argspec[arg][0].__name__))
            argLabel.pack(side='left')
            argFrame.pack(fill='x', expand='yes')

            self.argEntries[arg] = {'Frame': argFrame, 'Entry': argEntry, 'Doc': argDoc}

        self._argsFrame.pack(expand='yes', fill='both', side="top")

        self._buttonFrame = Frame(self.window)

        self._submitButton = Button(self._buttonFrame, text='Submit', command=self.transmit)
        self._closeButton = Button(self._buttonFrame, text='Close', command=self.close)
        self._submitButton.pack(side="left")
        self._closeButton.pack(side="right")

        self._buttonFrame.pack(side="bottom", fill="x", expand="yes")
Esempio n. 30
0
class GUI(Frame):
	def __init__(self,parent):
		Frame.__init__(self,parent)
		self.parent = parent
		
		self.ledON = '1'
		self.ledOFF = '0'
		self.initGUI()

	def initGUI(self):
		self.parent.title("Spark Core control")
		self.pack()

		# Initialize Entry widget for device_id and access_token
		self.frmDeviceId = Frame(self)
		self.frmDeviceId.pack()
		self.lblDeviceId = Label(self.frmDeviceId, text="Device ID")
		self.lblDeviceId.pack(side=LEFT)
		self.DeviceId = StringVar()
		self.entryDeviceId = Entry(self.frmDeviceId, textvariable=self.DeviceId)
		self.DeviceId.set("53ff70066678505553201467")
		self.entryDeviceId.pack()

		self.frmAccessToken = Frame(self)
		self.frmAccessToken.pack()
		self.lblDeviceId = Label(self.frmAccessToken, text="Access Token")
		self.lblDeviceId.pack(side=LEFT)
		self.AccessToken = StringVar()
		self.entryAccessToken = Entry(self.frmAccessToken, textvariable=self.AccessToken)
		self.AccessToken.set("f107f8f0fd642b56a2cdf0e88b3bf597761de556")
		self.entryAccessToken.pack()


		self.btnTurnOnLed = Button(self, text="LED ON", command=self.turnLedOn)
		self.btnTurnOnLed.pack()
		self.btnTurnOffLed = Button(self, text="LED OFF", command=self.turnLedOff)
		self.btnTurnOffLed.pack()


	def turnLedOn(self):
		self.path = "https://api.spark.io/v1/devices/" + self.DeviceId.get() + "/control"
		self.access_token = self.AccessToken.get()
		self.command = [('access_token',self.access_token),('args','1')]
		command_encode = urllib.urlencode(self.command)
		request = urllib2.Request(self.path,command_encode)
		urllib2.urlopen(request)


	def turnLedOff(self):
		self.path = "https://api.spark.io/v1/devices/" + self.DeviceId.get() + "/control"
		self.access_token = self.AccessToken.get()
		self.command = [('access_token',self.access_token),('args','0')]
		command_encode = urllib.urlencode(self.command)
		request = urllib2.Request(self.path,command_encode)
		urllib2.urlopen(request)
Esempio n. 31
0
def saisie_1matrice(window, canvas, saiz):
    canvas.create_text(400, 20, text="n ", font="/font/myfont 10 bold", fill="black")
    ligne = Entry(window, relief="groove", width=3, bg="#eee")
    ligne.pack()

    bouton_ok = Button(window, text="Ok", relief="groove", font="/font/myfont 6 bold",
                       command=lambda: saiz(window, canvas, ligne.get(), bouton_ok),
                       bg="#eee", fg="black", activebackground="#dcc", width=2)
    canvas.create_window(425, 20, window=ligne)
    canvas.create_window(480, 20, window=bouton_ok)
    canvas.pack()
Esempio n. 32
0
def create_entry(_main_row_, _desc_txt, _def_txt_, t_len, ckbc=None, fn=None):
    ''' creates a tkinter entry '''
    _row_ = Frame(_main_row_)

    if ckbc <> None and fn <> None:
        label0 = Label(_row_, width=3, text="  ", anchor='w')
        cvar = IntVar()
        label1 = Checkbutton(_row_,
                             width=0,
                             variable=cvar,
                             command=fn,
                             anchor='w')
        label2 = Label(_row_, width=t_len, text=_desc_txt + "  ", anchor='w')

        ckbc.append([cvar, label1])

    else:
        label0 = Label(_row_, width=3, text=" >", anchor='w')
        label1 = Label(_row_, width=t_len, text=_desc_txt, anchor='w')
        label2 = Label(_row_, width=2, text=" :", anchor='w')

    if type(_def_txt_) == str:
        Ent_It = Entry(_row_)  #, width=13)
        Ent_It.insert('end', _def_txt_)

    elif type(_def_txt_) in [list, tuple]:

        Ent_It = StringVar()
        aux_ddl = Drop_Down_List(
            _row_,
            textvariable=Ent_It,
            values=tuple(_def_txt_[1]),
            #state = "readonly"
        )
        aux_ddl.bind("<Key>", lambda e: "break")  # Magic
        Ent_It.set(_def_txt_[0])

    finalspace = Label(_row_, width=5, text=" ", anchor='w')

    # Just packing
    label0.pack(side='left', padx=1)
    label1.pack(side='left', padx=6)
    label2.pack(side='left', padx=0)

    if type(_def_txt_) == str:
        Ent_It.pack(side='left', expand=True, fill=X)
    elif type(_def_txt_) in [list, tuple]:
        aux_ddl.pack(side='left', expand=True, fill=X)

    finalspace.pack(side='right', padx=0)
    _row_.pack(side='top', fill=X, pady=3)

    # For tracing purposes list appending
    return Ent_It
Esempio n. 33
0
class Application(Frame):
    def chodir(self, gb, key):
        gb.dirs[key] = askdirectory(initialdir="/", parent=root)
        # normalized version of directory path
        # @see http://docs.python.org/2/library/os.path.html#os.path.normpath
        dirnormpath = path.normpath(gb.dirs[key])
        if key == "source":
            self.srctxt['text'] = dirnormpath
        if key == "destination":
            self.dsttxt['text'] = dirnormpath
    def createWidgets(self):
        gb = GalleryBatch()

        self.src = Button(self)
        self.src["text"] = "Find images (subdirectories included)"
        self.src["command"] = lambda: self.chodir(gb, "source")
        self.src.pack({"fill":"x"})

        self.srctxt = Label(self)
        self.srctxt['text'] = "Select source directory"
        self.srctxt.pack({"fill":"x"})

        self.dst = Button(self)
        self.dst["text"] = "Create symlink gallery to"
        self.dst["command"] = lambda: self.chodir(gb, "destination")
        self.dst.pack({"fill":"x"})

        self.dsttxt = Label(self)
        self.dsttxt['text'] = "Select destination directory"
        self.dsttxt.pack({"fill":"x"})

        self.runop = Button(self)
        self.runop["text"] = "Run"
        self.runop["bg"]   = "#008000"
        self.runop["fg"]   = "white"
        self.runop["command"] = lambda: gb.run(self.skip_mb.get())
        self.runop.pack({"side":"right"})

        self.QUIT = Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"]   = "red"
        self.QUIT["command"] =  self.quit
        self.QUIT.pack({"side":"left"})

        self.skip_mb_label = Label(self, text="Ignore file larger than (MB)")
        self.skip_mb_label.pack()
        self.skip_mb = Entry()
        self.skip_mb.insert(0, gb.skip_limit_mb)
        self.skip_mb.pack()
        
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()
Esempio n. 34
0
class Login(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")

        self.name = "None"

        self.proc = Popen(["python", os.path.dirname(os.path.abspath(sys.argv[0]))+ "/" + "discovery.py", self.name], stdout=PIPE, stderr=STDOUT)

        self.parent = parent
        self.parent.title("Centered window")
        self.entrythingy = Entry()
        self.entrythingy.pack()
        self.contents = StringVar()
        self.entrythingy["textvariable"] = self.contents
        self.entrythingy.bind('<Key-Return>',
                              self.print_contents)
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()

    def print_contents(self, event):
        name = self.contents.get()
        if(name):
            self.name = name

            q = Queue()
            t = Thread(target=self.reader_thread, args=[q]).start()
            # Start network discovery
            # subprocess.call([os.path.dirname(os.path.abspath(sys.argv[0]))+ "/" + "discovery.sh", name])
            # process = Popen("python discovery.py", stdout=PIPE)
            # stdout, stderr = process.communicate()
            # # Starts network broadcast
            # process1 = Popen("python server.py " + name, stdout=PIPE)
            # stdout, stderr = process1.communicate()
            self.parent.destroy()

    def reader_thread(self, q):
        """Read subprocess output and put it into the queue."""
        for line in iter(self.proc.stdout.readline, b''):
            print(line)
        print('done reading')

    def centerWindow(self):

        w = 290
        h = 150

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()

        x = (sw - w)/2
        y = (sh - h)/2
        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
Esempio n. 35
0
 def create_and_add_file_field(self, parent, title, pad, is_save):
     title_label = Label(parent, text=title)
     title_label.pack(side=Tkinter.TOP, padx=pad)
     container_frame = Frame(parent)
     container_frame.pack(side=Tkinter.TOP, padx=pad, pady=(0, pad))
     filename_entry = Entry(container_frame)
     filename_entry.pack(side=Tkinter.LEFT)
     browse_button = \
         Button(container_frame, text="Browse...",
                command=lambda: self.select_file(filename_entry, is_save))
     browse_button.pack(side=Tkinter.RIGHT)
     return filename_entry
Esempio n. 36
0
class GUI:
    def __init__(self, root):
        frame1 = Frame(root)
        frame1.pack(ipadx=20, pady=20)
        self.labUser = Label(frame1, text="Google Account:")
        self.labUser.pack(side="left", padx=10)
        self.enyUser = Entry(frame1)
        self.enyUser.pack(side="left")
        self.labPwd = Label(frame1, text="Password:"******"left", padx=10)
        self.enyPwd = Entry(frame1)
        self.enyPwd['show'] = '*'
        self.enyPwd.pack(side="left")
Esempio n. 37
0
def regist():
    global registPanel
    global entry
    
    
    registPanel = Frame(root)
    label = Label(registPanel,text="请输入用户名:")
    entry =Entry(registPanel)
    confirm_btn = Tkinter.Button(registPanel,text="确认",fg="Blue",command=go_main)
    registPanel.pack()
    label.pack();
    entry.pack(side=LEFT)
    confirm_btn.pack(side = RIGHT)
class GUI:
    def __init__(self, root):
        frame1 = Frame(root)
        frame1.pack(ipadx=20, pady=20)
        self.labUser = Label(frame1, text="Google Account:")
        self.labUser.pack(side="left", padx=10)
        self.enyUser = Entry(frame1)
        self.enyUser.pack(side="left")
        self.labPwd = Label(frame1, text="Password:"******"left", padx=10)
        self.enyPwd = Entry(frame1)
        self.enyPwd['show'] = '*'
        self.enyPwd.pack(side="left")
Esempio n. 39
0
class closing_comment():
    def __init__(self, master):
        self._master = master
        self.interior = Frame(master, class_="closing")

        instruction_label_frame = Frame(self.interior, class_="closing")
        instruction_label_frame.pack(fill=X)

        self.title_font = tkfont.Font(family='Helvetica',
                                      size=18,
                                      weight="bold",
                                      slant="italic")
        self.content_font = tkfont.Font(family='Helvetica', size=14)
        self._label_instruction = Label(
            instruction_label_frame,
            text="Please give your overall comment to the system.",
            font=self.title_font)
        self._label_instruction.pack()

        # entry form
        self.var_entry = StringVar()
        entry_frame = Frame(self.interior, class_="entry")
        entry_frame.pack(fill=X)

        self._entry_comment = Entry(entry_frame,
                                    width=70,
                                    textvariable=self.var_entry)
        self._entry_comment.pack(side=LEFT, fill='both', expand=True)

        #button
        button_frame = Frame(self.interior, class_="Submit")
        button_frame.pack(fill=X)

        self._button_next = Button(button_frame,
                                   text="Submit",
                                   command=self.close_window,
                                   width=50,
                                   font=self.content_font)
        self._button_next.pack()
        self._button_next.bind("<Button-1>", self._on_button_submit)
        self._button_next.focus()

    def close_window(self):
        self._master.destroy()

    def _on_button_submit(self, event):
        # get the input from user
        print("var_entry:", self.var_entry.get())

        _log = open("log.txt", "a")
        _log.write("\nClosing comment: %s" % self.var_entry.get())
Esempio n. 40
0
def login_gui(username, password):
    def get_login(evt=None):
        temp_username = username_holder.get()
        temp_password = password_holder.get()
        if remember_login_holder.get():
            logon_file = open("dep.dat", "w")
            logon_file.write(encodestring(temp_username+" "+temp_password))
            logon_file.close()
        elif os.path.isfile("dep.dat"):
            os.remove("dep.dat")
        login_tk.destroy()
        wrap.login(temp_username, temp_password)
        overview_gui()
        return

    def on_checkbox_flip():
        if remember_login_holder.get():
            logon_file = open("dep.dat", "w")
            logon_file.write(encodestring(username_holder.get()+" "+password_holder.get()))
            logon_file.close()
        else:
            if os.path.isfile("dep.dat"):
                os.remove("dep.dat")
        return

    login_tk = Tk()
    login_tk.title("Login Window")
    Label(login_tk, text="Login to GradeSpeed").pack(padx=50, pady=(10, 5))
    Label(login_tk, text="Username:"******"<Key-Return>", get_login)
    Label(login_tk, text="Password:"******"*")
    password_field.pack(padx=50, pady=(0, 5))
    password_field.bind("<Key-Return>", get_login)

    remember_login_holder = BooleanVar()
    remember_login_holder.set(len(username) > 0)
    login_frame = Frame(login_tk)
    Checkbutton(login_frame, text="Remember Logon", var=remember_login_holder, command=on_checkbox_flip).pack()
    login_frame.pack(pady=5)

    Button(text="Login", command=get_login).pack(padx=50, pady=(5, 10))
    center_gui(login_tk)

    login_tk.mainloop()
Esempio n. 41
0
 def add_entries(self, vl):
     for el in vl:
         if not hasattr(self.ea, el['name']):
             raise TypeError(
                 'you try to set up an entry for a name which is no attribute of the chosen EA'
             )
         fr = Frame(self.f_actn)
         fr.pack()
         lab = Label(fr, text=el['name'])
         lab.pack()
         e = Entry(fr)
         e.pack()
         e.insert(0, str(el['inival']))  # number of generations
         el['Entry'] = e
Esempio n. 42
0
    def ask_title_and_create_window(self):
        toplevel = Toplevel()
        
        label = Label(toplevel, text="Title:")
        label.pack(anchor=W)

        entry = Entry(toplevel, width=15)
        entry.pack(anchor=W, fill=X)
        
        entry.bind("<Return>", lambda event: (self.new_window(entry.get()), toplevel.destroy()))
        
        entry.focus()
        
        return "break"
Esempio n. 43
0
    def create_entry_ck(self, _row2use_, _i_=None, container=[]):
        ''' creates a too custom check row so it aparts here'''
        _row_ = Frame(_row2use_)

        if _i_ == None:
            _group_, _def_ids_, _def_fcoord_, _res_ens_ = container

        else:
            _group_ = self._entries_[_i_]
            _def_fcoord_ = self._defvals_[_i_]
            _def_ids_ = self.range_ids[_i_]
            _res_ens_ = self.range_ens[_i_]

        label0 = Label(_row_, width=1, text=" ", anchor='w')
        # first check button
        cvar = IntVar()
        label1 = Checkbutton(_row_,
                             width=0,
                             variable=cvar,
                             command=self.checkbuttonstuff,
                             anchor='w')
        self.ckb_c.append([cvar, label1])
        # group description
        label2 = Label(_row_, width=6, text='Group ', anchor='w')
        Ent_gr = Entry(_row_, width=8)
        Ent_gr.insert('end', _group_)

        label2_2 = Label(_row_, width=5, text="  ids", anchor='w')
        # group ids
        Ent_ids = Entry(_row_, width=10)
        Ent_ids.insert('end', _def_ids_)

        label3 = Label(_row_, width=7, text="  K:xyz ", anchor='w')
        Ent_it = Entry(_row_, width=6)
        Ent_it.insert('end', _def_fcoord_)

        label4 = Label(_row_, width=5, text=" In run", anchor='w')
        Ent_ens = Entry(_row_, width=6)
        Ent_ens.insert('end', _res_ens_)

        finalspace = Label(_row_, width=5, text=" ", anchor='w')

        # Just packing
        label0.pack(side='left', padx=0)
        label1.pack(side='left', padx=2)
        label2.pack(side='left', padx=0)
        Ent_gr.pack(side='left', expand=True, fill=X)
        label2_2.pack(side='left', padx=0)
        Ent_ids.pack(side='left', expand=True, fill=X)

        label3.pack(side='left', padx=0)
        Ent_it.pack(side='left', expand=True, fill=X)

        label4.pack(side='left', padx=0)
        Ent_ens.pack(side='left', expand=True, fill=X)
        finalspace.pack(side='right', padx=0)
        _row_.pack(side='top', fill=X, pady=3)

        # For tracing purposes list appending
        self.ent_c.append([Ent_gr, Ent_ids, Ent_it, Ent_ens])
Esempio n. 44
0
class popupWindow(object):
    def __init__(self, master, manager):
        self.master = master
        self.manager = manager
        top = self.top = Toplevel(master)
        Label(top, text="Début du pas (min:sec)").pack()
        self.pas_d = Entry(top)
        self.pas_d.pack()
        Label(top, text="Fin du pas (min:sec)").pack()
        self.pas_f = Entry(top)
        self.pas_f.pack()
        Label(top, text="Début du trot (min:sec)").pack()
        self.trot_d = Entry(top)
        self.trot_d.pack()
        Label(top, text="Fin du trot (min:sec)").pack()
        self.trot_f = Entry(top)
        self.trot_f.pack()
        b1 = Button(top, text='Séparer', command=self.split_data_file)
        b1.pack()

    def split_data_file(self):
        ftypes = [('All files', '*')]
        dlg = tkFileDialog.Open(self.master, filetypes=ftypes)
        fl = dlg.show()
        if fl != '':
            self.manager.split_data_file(fl, self.pas_d.get(),
                                         self.pas_f.get(), self.trot_d.get(),
                                         self.trot_f.get())
        self.top.destroy()
Esempio n. 45
0
    def create_player(self):
        player = Frame(self.root)
        player.pack(fill=X, expand=1)
        # left
        left_frame = Frame(player)
        left_frame.pack(side=LEFT)
        left_team_name = Entry(left_frame, bg='pink', fg='black')
        left_team_name.insert(0, 'A队')
        left_team_name.pack()
        for i in range(1, 7):
            e = Entry(left_frame, bg='red', fg='white')
            name = 'Player' + str(i)
            e.insert(0, name)
            e.pack()
        # right
        right_frame = Frame(player)
        right_frame.pack(side=RIGHT)
        right_team_name = Entry(right_frame, bg='lightBlue', fg='black')
        right_team_name.insert(0, 'B队')
        right_team_name.pack()
        for i in range(7, 13):
            e = Entry(right_frame, bg='blue', fg='white')
            name = 'Player' + str(i)
            e.insert(0, name)
            e.pack()

        self.left_frame = left_frame
        self.right_frame = right_frame
Esempio n. 46
0
class tester(tk.Frame):
    def __init__(self, parent):
        self.parent = parent
        self.frame = tk.Frame(self.parent)

        self.canvas = tk.Canvas(parent, width=100, height=100)
        self.canvas.pack()

        self.key_dict = {}
        self.game_over = False
        #keep track of keypress
        self.c = 0

        self.input_box(parent)

        B = tk.Button(parent, text="playback states", command=self.start)
        B.pack()

    def start(self):
        try:
            # Bind entry to any keypress
            self.entry.bind("<Key>", self.click)

            # while self.c<5:
            # 	if time.time()-start >=2:
            #  		print('start thread')
            # 	 	inp = Process(target = self.input_box)
            # 	 	inp.start()
            # 	 	inp.join() #dont make killed process a zombie
            # 	 	inp.terminate()
            # 	 	start = time.time()
            # 	 	self.c+=1

        except:
            print("Error: unable to start thread")

    def input_box(self, parent):
        self.entry = Entry()
        self.entry.focus_set()
        self.entry.pack()

    def click(self, key):
        # print the key that was pressed
        print(key.char)
        self.clear_entry()

    def clear_entry(self):
        self.entry.delete(0, "end")
        root.update()
Esempio n. 47
0
    def __init__(self, master):
        self.master = master
        master.title("Saturation Flows Calculator")

        vcmd = master.register(self.validate)  # we have to wrap the command
        vcmd_fp = master.register(
            self.validate_inputFolder)  # we have to wrap the command

        self.fp_dis = StringVar()
        e = Entry(master,
                  textvariable=self.fp_dis,
                  validate="key",
                  validatecommand=(vcmd_fp, '%P'))
        b = Button(master,
                   text="Browse",
                   command=lambda: self.fp_dis.set(filedialog.askdirectory()))
        e.pack()
        b.pack()

        self.vehsIgnored = StringVar()
        self.satFlowHead = StringVar()
        self.minVehsPerMeas = StringVar()
        self.minValidCycles = StringVar()

        self.params = [
            self.vehsIgnored, self.satFlowHead, self.minVehsPerMeas,
            self.minValidCycles
        ]

        i = 0
        for p in self.params:
            row = Frame(master)
            lab = Label(row, width=22, text=fields[i] + ": ", anchor='w')
            self.ent = Entry(row,
                             textvariable=p,
                             validate="key",
                             validatecommand=(vcmd, '%P'))
            self.ent.insert(0, '0')
            row.pack(side=TOP, fill=X, padx=5, pady=5)
            lab.pack(side=LEFT)
            self.ent.pack(side=RIGHT, expand=YES, fill=X)
            p.trace("w", self.check_params)
            i += 1

        self.run_button = Button(master,
                                 text='Calculate Saturation Flow',
                                 state=DISABLED,
                                 command=lambda: self.Main(self.params))
        self.run_button.pack(padx=5, pady=5, expand=YES, fill=X)
Esempio n. 48
0
def quickentry(labels, callback, title='', defaults=None):
    "Simple dialog from grabbing parameters from the user."

    if defaults is None:
        defaults = {}

    root = Tk()

    root.title(title)
    root['padx'] = 20
    root['pady'] = 10

    widgets = {}
    for label in labels:

        # Create a text frame to hold the text Label and the Entry widget
        f = Frame(root)

        #Create a Label in textFrame
        l = Label(f)
        l['text'] = label
        l['width'] = 10
        l.pack(side=LEFT)

        w = Entry(f)
        w['width'] = 20
        w.pack(side=LEFT)

        w.insert(0, defaults.get(label, ''))

        widgets[label] = w

        f.pack()

    def cb():
        callback({label: widgets[label].get().strip() for label in labels})

    Button(root, text="Quit", command=lambda root=root: root.destroy()).pack(side=RIGHT)
    Button(root, text='Submit', command=cb).pack(side=RIGHT)


    root.protocol("WM_DELETE_WINDOW", lambda root=root: root.destroy())

    print '[quickentry] running'
    root.bind("<Return>", lambda e: cb())
    root.bind("<Escape>", lambda e: root.destroy())
    root.mainloop()
    print '[quickentry] done'
    return root
Esempio n. 49
0
def quickentry(labels, callback, title='', defaults=None):
    "Simple dialog from grabbing parameters from the user."

    if defaults is None:
        defaults = {}

    root = Tk()

    root.title(title)
    root['padx'] = 20
    root['pady'] = 10

    widgets = {}
    for label in labels:

        # Create a text frame to hold the text Label and the Entry widget
        f = Frame(root)

        #Create a Label in textFrame
        l = Label(f)
        l['text'] = label
        l['width'] = 10
        l.pack(side=LEFT)

        w = Entry(f)
        w['width'] = 20
        w.pack(side=LEFT)

        w.insert(0, defaults.get(label, ''))

        widgets[label] = w

        f.pack()

    def cb():
        callback({label: widgets[label].get().strip() for label in labels})

    Button(root, text="Quit",
           command=lambda root=root: root.destroy()).pack(side=RIGHT)
    Button(root, text='Submit', command=cb).pack(side=RIGHT)

    root.protocol("WM_DELETE_WINDOW", lambda root=root: root.destroy())

    print '[quickentry] running'
    root.bind("<Return>", lambda e: cb())
    root.bind("<Escape>", lambda e: root.destroy())
    root.mainloop()
    print '[quickentry] done'
    return root
Esempio n. 50
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack(fill=BOTH)
        global textPath
        opt=Frame(self, bd = 1)
        textPath = StringVar()

        lb1=Label(opt,text="Path ? ")
        entre = Entry(opt,textvariable=textPath)

        lb1.pack(side="left")
        entre.pack()
        opt.bouton_Valider = Button(self, text="Valider", command = affiche_recap)
        opt.bouton_Valider.pack(side = "bottom")
        opt.pack(side="top")
Esempio n. 51
0
class Panle:
    def __init__(self, master):
        
        self.frame = Frame(master)
        self.frame.pack(side=TOP)
        self.label = Tkinter.Label(self.frame, text='wordEcho')
        self.label.pack()
        self.input = Entry(self.frame, width=45)
        self.input.pack(side=LEFT)
        self.button = Button(self.frame, text='翻译')
        self.button.pack(side=RIGHT)
        self.frame2 = Scrollbar(master)
        self.frame2.pack(side=TOP)
        self.ms = Message(self.frame2,  anchor='w', width=150)
        self.ms.pack()
Esempio n. 52
0
class popupWindow(object):
    def __init__(self,master, title):
        self.top=Toplevel(master)
        self.value = ''
        self.top.geometry("+300+300")
        self.l=Label(self.top,text=title)
        self.l.pack()
        self.e=Entry(self.top)
        self.e.pack()
        self.b=Button(self.top,text='Ok',command=self.cleanup)
        self.b.pack()
        self.e.focus()
    def cleanup(self):
        self.value=self.e.get()
        self.top.destroy()
Esempio n. 53
0
class Window(object):
    def __init__(self, master):

        self.master = master
        self.master.wm_title('PEP8 checker')
        self.master.resizable(False, True)

        self.frame = Frame(master)
        self.frame.pack(fill=BOTH, expand=1)

        home_dir = expanduser("~")
        self.directory = StringVar(value=home_dir)

        directory_frame = Frame(self.frame)
        directory_frame.grid()
        self.frame.grid_rowconfigure(2, weight=1)

        self.entry_directory = Entry(directory_frame, textvariable=self.directory)
        self.entry_directory.pack(anchor=W, side=LEFT)

        self.select_directory = Button(directory_frame, text="Select directory to scan", command=self.select_directory)
        self.select_directory.pack(anchor=E, side=RIGHT)

        self.run_button = Button(self.frame, text='Run PEP8!', command=self.run_pep)
        self.run_button.grid(sticky=W + E)

        self.errors_list = Listbox(self.frame)
        self.errors_list.grid(sticky=W + E)

        self.status_label = Label(self.frame)

    def select_directory(self):
        directory = askdirectory(initialdir=self.directory.get())
        if directory:
            self.directory.set(directory)

    def run_pep(self):
        self.errors_list.delete(0, END)
        process = Popen('$(which pep8) {}'.format(self.directory.get()), shell=True, stderr=PIPE, stdout=PIPE)
        output = process.communicate()[0]
        selected_dir = ''.join((self.directory.get(), '/'))
        if output:
            self.errors_list.configure(background='red')
            for i, error in enumerate(output.split('\n')):
                self.errors_list.insert(i, error.replace(selected_dir, ''))
        else:
            self.errors_list.configure(background='green')
            self.errors_list.insert(0, 'Directory is OK!')
Esempio n. 54
0
    def ask_title_and_create_window(self):
        toplevel = Toplevel()

        label = Label(toplevel, text="Title:")
        label.pack(anchor=W)

        entry = Entry(toplevel, width=15)
        entry.pack(anchor=W, fill=X)

        entry.bind(
            "<Return>", lambda event:
            (self.new_window(entry.get()), toplevel.destroy()))

        entry.focus()

        return "break"
Esempio n. 55
0
    def create_type_widgets(self):
        frm = self._wm['frmType']
        self._type_chk = StringVar()
        chkType = Checkbutton(frm,
                              text='',
                              onvalue=1,
                              offvalue=0,
                              state=NORMAL,
                              variable=self._type_chk,
                              command=self.on_chk_type_click)
        self._type_chk.set(0)
        chkType.pack(side=LEFT, padx=8)
        lbType = Label(frm, text='%s' % LANG_MAP[self._lang]['Type'])
        lbType.pack(side=LEFT)
        self._type_var = StringVar()
        cmbType = ttk.Combobox(frm, width=8, textvariable=self._type_var)
        cmbType.pack(side=LEFT, padx=4)
        cmbType['value'] = LANG_MAP[self._lang]['TypeList']
        lbStart = Label(frm, text='%s:' % LANG_MAP[self._lang]['Start'])
        lbStart.pack(side=LEFT, padx=4)
        self._type_start = StringVar()
        enStart = Entry(frm, width=8, textvariable=self._type_start)
        enStart.pack(side=LEFT)
        lbEnd = Label(frm, text='%s:' % LANG_MAP[self._lang]['End'])
        lbEnd.pack(side=LEFT, padx=4)
        self._type_end = StringVar()
        enEnd = Entry(frm, width=8, textvariable=self._type_end)
        enEnd.pack(side=LEFT)
        bnType = Button(frm,
                        text='%s' % LANG_MAP[self._lang]['OK'],
                        width=4,
                        command=self.on_bn_type_click)
        bnType.pack(side=LEFT, padx=36)

        cmbType['state'] = DISABLED
        enStart['state'] = DISABLED
        enEnd['state'] = DISABLED
        bnType['state'] = DISABLED

        self._wm['chkType'] = chkType
        self._wm['lbType'] = lbType
        self._wm['lbStart'] = lbStart
        self._wm['lbEnd'] = lbEnd
        self._wm['cmbType'] = cmbType
        self._wm['enStart'] = enStart
        self._wm['enEnd'] = enEnd
        self._wm['bnType'] = bnType
Esempio n. 56
-1
class Recherche(Vue):
    """
    Vue principal
    """
    def __init__(self, fenetre):
        """
        Constructeur de la fenetre
        """
        self.parent = fenetre
        self.frame = Frame(self.parent, borderwidth=1, relief='groove', width=100)
        self.frame.pack_configure(side='top', fill='both')
        self.frame.pack()
        self.titre = Label(self.frame, text=GT_('Url'), font=(20))
        self.titre.pack()
        self.img = PhotoImage(file="%slogo.gif" % RESSOURCES_PATH)
        self.logo = Label(self.frame, image=self.img)
        self.logo.pack(pady=(0, 20), side="left")
        self.brand = Label(self.frame, text=GT_('WebForge %s' % VERSION), font=(20))
        self.brand.pack(pady=(10, 20), padx=(0, 20), side="left")
        self.txt_recherche = Entry(self.frame, font=(22))
        self.txt_recherche.pack(pady=(0, 20), expand='yes', fill='both', side='left')
        self.btn_go = Button(self.frame, text="GO")
        self.btn_go.pack(pady=(0, 20), side='right')
        self.btn_erase = Button(self.frame, text="X")
        self.btn_erase.pack(pady=(0, 20), side='right')

    def set_url(self, url):
        """
        Set a new url value to the field
        """
        self.txt_recherche.insert(0, url)