Example #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 HostBox(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        
        self.labelHost = Label(self, text = "Host: http://")
        self.entryHost = Entry(self, width = 20)
        self.labelUrl = Label(self, text = "Url:")
        self.entryUrl = Entry(self, width = 20)
        self.labelPort = Label(self, text = "Port:")
        self.port = StringVar()
        self.port.set("80")
        self.entryPort = Entry(self, width = 8, textvariable = self.port)
        self.__boxComponents()
    
    def __boxComponents(self):
        self.labelHost.grid(row = 0, column = 0)
        self.entryHost.grid(row = 0, column = 1)
        self.labelUrl.grid(row = 1, column = 0)
        self.entryUrl.grid(row = 1, column = 1)
        self.labelPort.grid(row = 0, column = 2)
        self.entryPort.grid(row = 0, column = 3)
        
    def getHost(self):
        return self.entryHost.get()
    
    def getPort(self):
        return self.port.get()
    
    def getUrl(self):
        return self.entryUrl.get()
Example #3
0
def birthday():
    root3 = Tk()
    root3.title('Birthday')
    name = Label(root3, text='Enter the name : ', font='bold')
    name.pack()
    e1 = Entry(root3)
    e1.pack()
    n1 = e1.get()
    date = Label(root3, text='Enter the date (yyyy-mm-dd) : ', font='bold')
    date.pack()
    e2 = Entry(root3)
    e2.pack()
    d1 = e2.get()
    mail = Label(root3, text='Enter the Mail Id : ', font='bold')
    mail.pack()
    e3 = Entry(root3)
    e3.pack()
    m1 = e3.get()
    f1 = open("b1.txt", 'a')
    f1.write(n1)
    f1.write(",")
    f1.write(d1)
    f1.write(",")
    f1.write(m1)
    f1.write("\n")
    b = Button(root3, text='Add birthday', font='bold', command=homepage)
    b.pack()
    #p = Label(root4,"\nBirthday added sucessfully..!!")
    #p.pack()
    root3.mainloop()
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...')
class ParamItem(Frame):
    
    def __init__(self, master, itemList, deleteCount):
        Frame.__init__(self, master)
        self.labelKey = Label(self, text = "Key:")
        self.labelValue = Label(self, text = "Value:")
        self.entryKey = Entry(self, width = 8)
        self.entryValue = Entry(self, width = 20)
        self.deleteCount = deleteCount
        self.itemList = itemList
        self.btnDelete = Button(self, text = "delete", \
            command = self.__internalDelete, padx = 5)
        self.__boxComponents()
    
    def __boxComponents(self):
        self.labelKey.grid(row = 0, column = 0)
        self.entryKey.grid(row = 0, column = 1)
        self.labelValue.grid(row = 0, column = 2)
        self.entryValue.grid(row = 0, column = 3)
        self.btnDelete.grid(row = 0, column = 4)
    
    def __internalDelete(self):
        self.deleteCount.set(self.deleteCount.get() + 1)
        self.itemList.remove(self)
        self.destroy()
    def getKey(self):
        return self.entryKey.get()
    
    def getValue(self):
        return self.entryValue.get()
Example #6
0
 def setupView(self, title="Test Auth Page", user='', pwd_ori=''):
     userVar = StringVar()
     pwdVar = StringVar()
     userInput = Entry(self,
                       textvariable=userVar,
                       width="30").grid(row=0,
                                        columnspan=2,
                                        sticky="WE")
     pwdInput = Entry(self,
                      textvariable=pwdVar,
                      show="*",
                      width="30").grid(row=1,
                                       columnspan=2,
                                       sticky="WE")
     userVar.set(user)
     pwdVar.set(pwd_ori)
     self.ok = Button(self,
                      text='Next',
                      command=lambda: self.
                      controller.setAuth(self,
                                         userInput.get(),
                                         pwdInput.get()))
     self.ok.grid(row=2, column=1, sticky="W")
     self.cancel = Button(self,
                          text='Cancel',
                          command=lambda: self.controller.quit())
     self.cancel.grid(row=2, column=0, sticky="E")
Example #7
0
class Interface(Frame):
    """界面操作"""

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        """构建界面"""
        self.radio_value = IntVar()

        Label(self, text="网络安全").grid(row=0, column=2, pady=10)
        # 生成label
        Label(self, text="用户名").grid(row=3, column=1, pady=10)
        Label(self, text="密码").grid(row=4, column=1)
        # 生成用户名和密码输入框
        self.name_input = Entry(self)
        self.name_input.grid(row=3, column=2)
        self.password = Entry(self)
        self.password['show'] = '*'
        self.password.grid(row=4, column=2)

        self.radio = Radiobutton(self, text="rsa", variable=self.radio_value, padx=20, value=1)
        self.radio.grid(row=5, column=1)

        self.radio1 = Radiobutton(self, text="des", variable=self.radio_value, padx=20, value=2)
        self.radio1.grid(row=6, column=1)

        self.alert_button = Button(self, text='提交', command=self.submit)
        self.alert_button.grid(row=7, column=1)

    def submit(self):
        """提交处理"""
        name = self.name_input.get() or 'username'
        password = self.password.get() or "password"
        cryption = self.radio_value.get() or "1"
        # 构造传输的数据
        data = name + ',' + password

        cryption = Crypt()
        my_socket = Mysocket()
        # 判断使用des还是rsa
        if cryption == 2:
            data = "des" + data
            need = 8 - (len(data) % 8)
            while need > 0:
                data += " "
                need -= 1
            result = cryption.des_encrypt(data)
            result = "des" + result
        else:
            result = cryption.rsa_encrypt(data)
            result = "rsa" + result
        result = my_socket.make_connect(result)

        if result >= 0:
            tkMessageBox.showinfo('Message', '%s' % '合法用户')
        else:
            tkMessageBox.showinfo('Message', '%s' % '非法用户')
Example #8
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()
Example #9
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()
Example #10
0
            class LoginDialog(tkSimpleDialog.Dialog):

                def body(self, login_frame):
                    Label(login_frame,
                          text='Sie sind noch nicht auf \
                          http://www.sleeptracker.net eingeloggt!'
                          ).grid(row=0, column=0, columnspan=2, sticky=W + E)
                    Label(login_frame,
                          text='Bitte loggen Sie sich ein.'
                          ).grid(row=1, column=0, columnspan=2, sticky=W + E)
                    Label(login_frame, text='').grid(row=2, column=0)
                    Label(login_frame,
                          text='Benutzername (eMail):'
                          ).grid(row=3, column=0, sticky=W)
                    Label(login_frame,
                          text='Passwort:').grid(row=4, column=0, sticky=W)
                    Label(login_frame, text='').grid(row=5, column=0)

                    self.user = Entry(login_frame)
                    self.user.insert(0, 'Benutzername')
                    self.pwd = Entry(login_frame, show='*')
                    self.pwd.insert(0, '')

                    self.user.grid(row=3, column=1)
                    self.pwd.grid(row=4, column=1)

                    # initial focus
                    return self.user

                def apply(self):
                    username = str(self.user.get())
                    password = str(self.pwd.get())

                    self.result = username, password
Example #11
0
class HostBox(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)

        self.labelHost = Label(self, text="Host: http://")
        self.entryHost = Entry(self, width=20)
        self.labelUrl = Label(self, text="Url:")
        self.entryUrl = Entry(self, width=20)
        self.labelPort = Label(self, text="Port:")
        self.port = StringVar()
        self.port.set("80")
        self.entryPort = Entry(self, width=8, textvariable=self.port)
        self.__boxComponents()

    def __boxComponents(self):
        self.labelHost.grid(row=0, column=0)
        self.entryHost.grid(row=0, column=1)
        self.labelUrl.grid(row=1, column=0)
        self.entryUrl.grid(row=1, column=1)
        self.labelPort.grid(row=0, column=2)
        self.entryPort.grid(row=0, column=3)

    def getHost(self):
        return self.entryHost.get()

    def getPort(self):
        return self.port.get()

    def getUrl(self):
        return self.entryUrl.get()
Example #12
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()
Example #13
0
class ParamItem(Frame):
    def __init__(self, master, itemList, deleteCount):
        Frame.__init__(self, master)
        self.labelKey = Label(self, text="Key:")
        self.labelValue = Label(self, text="Value:")
        self.entryKey = Entry(self, width=8)
        self.entryValue = Entry(self, width=20)
        self.deleteCount = deleteCount
        self.itemList = itemList
        self.btnDelete = Button(self, text = "delete", \
            command = self.__internalDelete, padx = 5)
        self.__boxComponents()

    def __boxComponents(self):
        self.labelKey.grid(row=0, column=0)
        self.entryKey.grid(row=0, column=1)
        self.labelValue.grid(row=0, column=2)
        self.entryValue.grid(row=0, column=3)
        self.btnDelete.grid(row=0, column=4)

    def __internalDelete(self):
        self.deleteCount.set(self.deleteCount.get() + 1)
        self.itemList.remove(self)
        self.destroy()

    def getKey(self):
        return self.entryKey.get()

    def getValue(self):
        return self.entryValue.get()
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()
Example #15
0
class ReadOnlyEntryDemo(Frame):
    def __init__(self, master):
        self.master = master
        Frame.__init__(self, master)

        self.entryFrame = LabelFrame(self, text="Enter Text and press Button : ")
        self.entryFrame.grid(row=0, column=0, pady=10)
        self.userInputEntry = Entry(self.entryFrame, width=50)
        self.userInputEntry.grid(row=0, column=0)
        self.setButton = Button(self.entryFrame, text="Set Text", command=self.setText)
        self.setButton.grid(row=1, column=0)

        self.withFocusFrame = LabelFrame(self, text="Readonly Widget: With Focus example (Try typing in this widget)")
        self.withFocusFrame.grid(row=1, column=0, pady=10)
        self.readOnlyFocus = ReadOnlyEntry(self.withFocusFrame, withFocus=True)
        self.readOnlyFocus.grid(row=0, column=0)

        self.withoutFocusFrame = LabelFrame(self, text="Readonly Widget: Without Focus example (Try typing in this widget)")
        self.withoutFocusFrame.grid(row=2, column=0, pady=10)
        self.readOnlyNoFocus = ReadOnlyEntry(self.withoutFocusFrame, withFocus=False)
        self.readOnlyNoFocus.grid(row=0, column=0)


    def setText(self):
        self.readOnlyFocus.set(self.userInputEntry.get())
        self.readOnlyNoFocus.set(self.userInputEntry.get())
Example #16
0
class readInputParams:
    def __init__(self, master):
        self.master = master
        master.title("Enter Filter Criteria:")

        self.label_CANSLIMParams = Label(master,
                                         text="CANSLIM EPS Parameters:")
        self.label_latestYear = Label(master, text="Latest Year")
        self.label_prevYear = Label(master, text="Previous Year")
        self.label_prevprevYear = Label(master, text="2nd Prev Year")
        self.label_currentQtr = Label(master, text="current Qtr")
        self.label_QtrEPSAlone = Label(master, text="Quater EPS Growth alone")
        self.filter_button = Button(master,
                                    text="Filter",
                                    command=lambda: self.runFilter())
        self.entry_EPSY1 = Entry(master)
        self.entry_EPSY2 = Entry(master)
        self.entry_EPSY3 = Entry(master)
        self.entry_EPSCurrQtr = Entry(master)
        self.entry_EPSQtrAlone = Entry(master)

        #layout
        #first row
        self.label_latestYear.grid(row=1, column=2)
        self.label_prevYear.grid(row=1, column=3)
        self.label_prevprevYear.grid(row=1, column=4)
        self.label_currentQtr.grid(row=1, column=5)

        #second row
        self.label_CANSLIMParams.grid(row=2, column=1)
        self.entry_EPSY1.grid(row=2, column=2)
        self.entry_EPSY2.grid(row=2, column=3)
        self.entry_EPSY3.grid(row=2, column=4)
        self.entry_EPSCurrQtr.grid(row=2, column=5)

        #third row
        self.label_QtrEPSAlone.grid(row=3, column=1)
        self.entry_EPSQtrAlone.grid(row=3, column=2)

        #fourth row
        self.filter_button.grid(row=4, column=1)

        #set default values
        self.entry_EPSY1.insert(0, 10)
        self.entry_EPSY2.insert(0, 8)
        self.entry_EPSY3.insert(0, 0)
        self.entry_EPSCurrQtr.insert(0, 15)
        self.entry_EPSQtrAlone.insert(0, 10)

    def runFilter(self):
        EPSY1 = self.entry_EPSY1.get()
        EPSY2 = self.entry_EPSY2.get()
        EPSY3 = self.entry_EPSY3.get()
        EPSCurrQtr = self.entry_EPSCurrQtr.get()
        EPSQtrAlone = self.entry_EPSQtrAlone.get()
        print("in filter Y1 %s Y2 %s Y3 %s Curren %s QtrAlone %s" %
              (EPSY1, EPSY2, EPSY3, EPSCurrQtr, EPSQtrAlone))
        getCompleteReport(EPSY1, EPSY2, EPSY3, EPSCurrQtr, EPSQtrAlone)
        print("CompleteReport Done..\n")
Example #17
0
class SphereDialog(tkSimpleDialog.Dialog):
    def __init__(self,
                 master,
                 data_a=10,
                 data_x=0,
                 data_y=0,
                 data_z=0,
                 data_mat='m0'):
        self.data_x = data_x
        self.data_y = data_y
        self.data_z = data_z
        self.data_a = data_a
        self.data_mat = data_mat
        tkSimpleDialog.Dialog.__init__(self, master)

    def body(self, master):
        Label(master, text='Radius: ').grid(row=0)
        Label(master, text='X: ').grid(row=1)
        Label(master, text='Y: ').grid(row=2)
        Label(master, text='Z: ').grid(row=3)
        Label(master, text='Material: ').grid(row=4)

        self.eR = Entry(master)
        self.eX = Entry(master)
        self.eY = Entry(master)
        self.eZ = Entry(master)
        self.emat = ttk.Combobox(master, values=materials.keys())

        self.eR.insert(0, self.data_a)
        self.eX.insert(0, self.data_x)
        self.eY.insert(0, self.data_y)
        self.eZ.insert(0, self.data_z)
        self.emat.insert(0, self.data_mat)

        self.eR.grid(row=0, column=1)
        self.eX.grid(row=1, column=1)
        self.eY.grid(row=2, column=1)
        self.eZ.grid(row=3, column=1)
        self.emat.grid(row=4, column=1)
        return self.eR  # initial focus

    def validate(self):
        try:
            X = float(self.eX.get())
            Y = float(self.eY.get())
            Z = float(self.eZ.get())
            R = float(self.eR.get())
            mat_key = self.emat.get()
            assert mat_key in materials
            self.result = R, X, Y, Z, mat_key
            return True
        except ValueError as err:
            tkMessageBox.showerror('Error', str(err))
            return False

    def apply(self):
        pass
Example #18
0
class SSHFSApplication(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.fld_user = self.fld_host = self.fld_pawd = None
        self.lbl_user = self.lbl_host = self.lbl_pawd = None
        self.btn_quit = self.btn_mount = None
        self.create_widgets()

    def create_widgets(self):
        """ Creates labels and text fields for username, hostname, and password.
            The password field replaces the visible entry with *'s
        """
        # Labels
        self.lbl_user = Label(self, text="Username:"******"Hostname:")
        self.lbl_pawd = Label(self, text="Password:"******"Quit",
                               command=self.quit,
                               takefocus=0)
        self.btn_mount = Button(self,
                                text="Mount",
                                command=self.mount_drive,
                                takefocus=1)

        # Arrange
        self.lbl_user.grid(column=0, row=0)
        self.lbl_host.grid(column=0, row=1)
        self.lbl_pawd.grid(column=0, row=2)
        self.fld_user.grid(column=1, row=0)
        self.fld_host.grid(column=1, row=1)
        self.fld_pawd.grid(column=1, row=2)
        self.btn_quit.grid(column=0, row=3)
        self.btn_mount.grid(column=1, row=3)

    def mount_drive(self):
        """ The function assigned to the "Mount" button. Retrieves user entries
            as strings and plugs them into sshfs.mount(user, host, password).
        """
        user = self.fld_user.get()
        host = self.fld_host.get()
        pawd = self.fld_pawd.get()
        if mount(user, host, pawd) == 0:
            del (self.fld_pawd, pawd)
            exit()
        else:
            return
Example #19
0
    def readFile(self, filename,wel):
        #lblFile= Label(self, text=filename+" has successfully added", width=6)
        #lblFile.pack(side=LEFT, anchor=N, padx=5, pady=5)
        wel.pack_forget()
        f = open(filename, "r")
        text = f.read()
        
        L1 = Label(self, text="Size of property")
        L1.place( x=20,y=30)
        E1 = Entry(self, bd =5)
        E1.place( x=150,y=30)

        L2 = Label(self, text="Swimming pool")
        L2.place( x=20,y=60)
        E2 = Entry(self, bd =5)
        E2.place( x=150,y=60)

        L3 = Label(self, text="type")
        L3.place( x=20,y=90)
        E3 = Entry(self, bd =5)
        E3.place( x=150,y=90)

        L4 = Label(self, text="Interior")
        L4.place( x=20,y=120)
        E4 = Entry(self, bd =5)
        E4.place( x=150,y=120)

        L5 = Label(self, text="Lawn")
        L5.place( x=20,y=150)
        E5 = Entry(self, bd =5)
        E5.place( x=150,y=150)

        L6 = Label(self, text="View")
        L6.place( x=20,y=180)
        E6 = Entry(self, bd =5)
        E6.place( x=150,y=180)


        L7 = Label(self, text="Locality")
        L7.place( x=20,y=210)
        E7 = Entry(self, bd =5)
        E7.place( x=150,y=210)

        L8 = Label(self, text="Bathrooms")
        L8.place( x=20,y=240)
        E8 = Entry(self, bd =5)
        E8.place( x=150,y=240)

        L9 = Label(self, text="Parking")
        L9.place( x=20,y=270)
        E9 = Entry(self, bd =5)
        E9.place( x=150,y=270)

        cal=Button(self, text="Calculate", command=lambda:self.cal(filename,E1.get(),E2.get(),E3.get(),E4.get(),E5.get(),E6.get(),E7.get(),E8.get(),E9.get()))
        cal.place( x=100,y=300)
Example #20
0
class readInputParams:
    def __init__(self, master):
        self.master = master
        master.title("Enter Filter Criteria:")

        self.label_CANSLIMParams = Label(master, text="CANSLIM EPS Parameters:")
        self.label_latestYear = Label(master, text="Latest Year")
        self.label_prevYear = Label(master, text="Previous Year")
        self.label_prevprevYear = Label(master, text="2nd Prev Year")
        self.label_currentQtr = Label(master, text="current Qtr")
        self.label_QtrEPSAlone = Label(master, text="Quater EPS Growth alone")
        self.filter_button = Button(master, text="Filter", command=lambda: self.runFilter())
        self.entry_EPSY1 = Entry(master)
        self.entry_EPSY2 = Entry(master)
        self.entry_EPSY3 = Entry(master)
        self.entry_EPSCurrQtr = Entry(master)
        self.entry_EPSQtrAlone = Entry(master)

        #layout
        #first row
        self.label_latestYear.grid(row=1, column=2)
        self.label_prevYear.grid(row=1, column=3)
        self.label_prevprevYear.grid(row=1, column=4)
        self.label_currentQtr.grid(row=1, column=5)

        #second row
        self.label_CANSLIMParams.grid(row=2, column=1)
        self.entry_EPSY1.grid(row=2, column=2)
        self.entry_EPSY2.grid(row=2, column=3)
        self.entry_EPSY3.grid(row=2, column=4)
        self.entry_EPSCurrQtr.grid(row=2, column=5)

        #third row
        self.label_QtrEPSAlone.grid(row=3, column=1)
        self.entry_EPSQtrAlone.grid(row=3, column=2)

        #fourth row
        self.filter_button.grid(row=4, column=1)

        #set default values
        self.entry_EPSY1.insert(0, 10)
        self.entry_EPSY2.insert(0, 8)
        self.entry_EPSY3.insert(0, 0)
        self.entry_EPSCurrQtr.insert(0, 15)
        self.entry_EPSQtrAlone.insert(0, 10)

    def runFilter(self):
        EPSY1 = self.entry_EPSY1.get()
        EPSY2 = self.entry_EPSY2.get()
        EPSY3 = self.entry_EPSY3.get()
        EPSCurrQtr = self.entry_EPSCurrQtr.get()
        EPSQtrAlone = self.entry_EPSQtrAlone.get()
        print("in filter Y1 %s Y2 %s Y3 %s Curren %s QtrAlone %s" %(EPSY1, EPSY2, EPSY3, EPSCurrQtr, EPSQtrAlone))
        getCompleteReport(EPSY1, EPSY2, EPSY3, EPSCurrQtr, EPSQtrAlone)
        print("CompleteReport Done..\n")
Example #21
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)
class PanelInformation(Frame):
    def __init__(self,parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()
        
    def initUI(self):
        self.frame = Frame(self.parent, relief=RAISED,borderwidth=1)
        self.xL = StringVar()
        self.xLE = StringVar()
        self.positionXL = Label(self.frame, textvariable=self.xL)
        self.positionXL.grid(row=0,column=0)
        self.positionXE = Entry(self.frame, textvariable=self.xLE)
        self.positionXE.grid(row=0,column=1)
        self.xLE.set(0)
        self.yL = StringVar()
        self.yLE = StringVar()
        self.positionYL = Label(self.frame, textvariable=self.yL)
        self.positionYL.grid(row=1,column=0)
        self.positionYE = Entry(self.frame, textvariable=self.yLE)
        self.positionYE.grid(row=1,column=1)
        self.yLE.set(0)
        self.thetaL = StringVar()
        self.thetaLE = StringVar()
        self.positionThetaL = Label(self.frame, textvariable=self.thetaL)
        self.positionThetaL.grid(row=2,column=0)
        self.positionThetaE = Entry(self.frame, textvariable=self.thetaLE)
        self.positionThetaE.grid(row=2,column=1)
        self.thetaLE.set(0)
    
    def getInfo(self):
        return (self.positionXE.get(),self.positionYE.get(),self.positionThetaE.get())
    
    def setInfo(self,x,y,theta):
        self.xLE.set(x)
        self.yLE.set(y)
        self.thetaLE.set(theta)
       
    def getFrame(self):
        return self.frame 
    
    def setDisableEntry(self):
        self.positionXE.config(state=DISABLED)
        self.positionYE.config(state=DISABLED)
        self.positionThetaE.config(state=DISABLED)
        
    def setLabelXLabel(self,text):
        self.xL.set(text)
        
    def setLabelYLabel(self,text):
        self.yL.set(text)
        
    def setLabelThetaLabel(self,text):
        self.thetaL.set(text)
Example #23
0
    def readFile(self, filename, wel):
        #lblFile= Label(self, text=filename+" has successfully added", width=6)
        #lblFile.pack(side=LEFT, anchor=N, padx=5, pady=5)
        wel.pack_forget()
        f = open(filename, "r")
        text = f.read()

        L1 = Label(self, text="Size of property")
        L1.place(x=20, y=30)
        E1 = Entry(self, bd=5)
        E1.place(x=150, y=30)

        L2 = Label(self, text="Swimming pool")
        L2.place(x=20, y=60)
        E2 = Entry(self, bd=5)
        E2.place(x=150, y=60)

        L3 = Label(self, text="type")
        L3.place(x=20, y=90)
        E3 = Entry(self, bd=5)
        E3.place(x=150, y=90)

        L4 = Label(self, text="Interior")
        L4.place(x=20, y=120)
        E4 = Entry(self, bd=5)
        E4.place(x=150, y=120)

        L5 = Label(self, text="Lawn")
        L5.place(x=20, y=150)
        E5 = Entry(self, bd=5)
        E5.place(x=150, y=150)

        L6 = Label(self, text="View")
        L6.place(x=20, y=180)
        E6 = Entry(self, bd=5)
        E6.place(x=150, y=180)

        L7 = Label(self, text="Locality")
        L7.place(x=20, y=210)
        E7 = Entry(self, bd=5)
        E7.place(x=150, y=210)

        L8 = Label(self, text="Bathrooms")
        L8.place(x=20, y=240)
        E8 = Entry(self, bd=5)
        E8.place(x=150, y=240)

        L9 = Label(self, text="Parking")
        L9.place(x=20, y=270)
        E9 = Entry(self, bd=5)
        E9.place(x=150, y=270)

        cal = Button(
            self,
            text="Calculate",
            command=lambda: self.cal(filename, E1.get(), E2.get(), E3.get(
            ), E4.get(), E5.get(), E6.get(), E7.get(), E8.get(), E9.get()))
        cal.place(x=100, y=300)
Example #24
0
class SSHFSApplication(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.fld_user = self.fld_host = self.fld_pawd = None
        self.lbl_user = self.lbl_host = self.lbl_pawd = None
        self.btn_quit = self.btn_mount = None
        self.create_widgets()

    def create_widgets(self):
        """ Creates labels and text fields for username, hostname, and password.
            The password field replaces the visible entry with *'s
        """
        # Labels
        self.lbl_user = Label(self, text="Username:"******"Hostname:")
        self.lbl_pawd = Label(self, text="Password:"******"Quit", command=self.quit,
                               takefocus=0)
        self.btn_mount = Button(self, text="Mount", command=self.mount_drive,
                                takefocus=1)

        # Arrange
        self.lbl_user.grid(column=0, row=0)
        self.lbl_host.grid(column=0, row=1)
        self.lbl_pawd.grid(column=0, row=2)
        self.fld_user.grid(column=1, row=0)
        self.fld_host.grid(column=1, row=1)
        self.fld_pawd.grid(column=1, row=2)
        self.btn_quit.grid(column=0, row=3)
        self.btn_mount.grid(column=1, row=3)

    def mount_drive(self):
        """ The function assigned to the "Mount" button. Retrieves user entries
            as strings and plugs them into sshfs.mount(user, host, password).
        """
        user = self.fld_user.get()
        host = self.fld_host.get()
        pawd = self.fld_pawd.get()
        if mount(user, host, pawd) == 0:
            del (self.fld_pawd, pawd)
            exit()
        else:
            return
Example #25
0
class GenerateSpheresDialog(tkSimpleDialog.Dialog):
    def __init__(self,
                 master,
                 data_N=0,
                 data_a=10,
                 data_d=5,
                 materials=['m0']):
        self.data_N = data_N
        self.data_a = data_a
        self.data_d = data_d
        self.materials = materials
        tkSimpleDialog.Dialog.__init__(self, master)

    def body(self, master):
        Label(master, text='Number of spheres:').grid(row=1)
        Label(master, text='Spheres radius:').grid(row=2)
        Label(master, text='Gap between spheres:').grid(row=3)
        Label(master, text='Material ID:').grid(row=4)

        self.eN = Entry(master)
        self.eN.insert(0, self.data_N)
        self.ea = Entry(master)
        self.ea.insert(0, self.data_a)
        self.ed = Entry(master)
        self.ed.insert(0, self.data_d)
        self.cbmat = ttk.Combobox(master, values=self.materials)
        self.cbmat.insert(0, self.materials[-1])

        self.eN.grid(row=1, column=1)
        self.ea.grid(row=2, column=1)
        self.ed.grid(row=3, column=1)
        self.cbmat.grid(row=4, column=1)
        return self.eN  # initial focus

    def validate(self):
        try:
            N = int(self.eN.get())
            a = float(self.ea.get())
            d = float(self.ed.get())
            mat_key = self.cbmat.get()
            assert mat_key in materials
            self.result = N, a, d, mat_key
            return True
        except ValueError as err:
            tkMessageBox.showerror('Error', str(err))
            return False

    def apply(self):
        pass
class IssueDialog(tkSimpleDialog.Dialog):
    

    def body(self, top):

        self.title("Issue Number")
        Label(top, text="Enter issue number: ").grid(row=0, sticky=W)
        
        Label(top, text="Chapter number to start with: ").grid(row=1, sticky=W)
        
        Label(top, text="Enter password for " + user + ": ").grid(row=2, sticky=W)
        
        
        self.e1 = Entry(top)
        self.e1.insert(0, "000")
        self.e1.grid(row=0, column=1)
        
        self.e3 = Entry(top)
        self.e3.insert(0, "2")
        self.e3.grid(row=1, column=1)
        
        self.e2 = Entry(top, show="*")
        self.e2.grid(row=2, column=1)
        
        self.var = IntVar()
        self.b = Checkbutton(top, text="Debug?", variable= self.var, onvalue = 1, offvalue = 0)
        self.b.grid(row=3, columnspan=2, sticky=W)
        
        #def callConvert():
            #essa_clipboardDateConvert.convert()

        
        #self.convertButton = Button(top, text="Convert clipboard date", command=callConvert)
        #self.convertButton.grid(row=4, columnspan=2, sticky=W)



    def apply(self):
        global issue
        issue = self.e1.get()
        
        global chapNum
        chapNum = int(self.e3.get())
        
        global password
        password = self.e2.get()

        global debug
        debug = self.var.get()
Example #27
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()
Example #28
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)
Example #29
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)
Example #30
0
class PasswordDialog(Dialog):

    def __init__(self, title, prompt, parent):
        self.prompt = prompt
        Dialog.__init__(self, parent, title)

    def body(self, master):
        from Tkinter import Label
        from Tkinter import Entry
        from Tkinter import Checkbutton
        from Tkinter import IntVar
        from Tkinter import W

        self.checkVar = IntVar()

        Label(master, text=self.prompt).grid(row=0, sticky=W)

        self.e1 = Entry(master)

        self.e1.grid(row=0, column=1)

        self.cb = Checkbutton(master, text="Save to keychain", variable=self.checkVar)
        self.cb.pack()
        self.cb.grid(row=1, columnspan=2, sticky=W)
        self.configure(show='*')

    def apply(self):
        self.result = (self.e1.get(), self.checkVar.get() == 1)
Example #31
0
class PasswordDialog(Dialog):

    def __init__(self, title, prompt, parent):
        self.prompt = prompt
        Dialog.__init__(self, parent, title)

    def body(self, master):
        from Tkinter import Label
        from Tkinter import Entry
        from Tkinter import Checkbutton
        from Tkinter import IntVar
        from Tkinter import W

        self.checkVar = IntVar()

        Label(master, text=self.prompt).grid(row=0, sticky=W)

        self.e1 = Entry(master)

        self.e1.grid(row=0, column=1)

        self.cb = Checkbutton(master, text="Save to keychain", variable=self.checkVar)
        self.cb.pack()
        self.cb.grid(row=1, columnspan=2, sticky=W)
        self.e1.configure(show='*')

    def apply(self):
        self.result = (self.e1.get(), self.checkVar.get() == 1)
Example #32
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))
Example #33
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)
Example #34
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()
Example #35
0
class FInput:
    """ Class created to manipulate files for output """
    def __init__(self, master, label=""):

        self.label = Label(master, text=label)
        self.entry = Entry(master)
        self.button = Button(master, text="Open", command=self.getLoadName)
        self.options = {}

    def __call__(self):
        return self.entry.get()

    def set(self, value):
        self.entry.delete(0, END)
        self.entry.insert(0, value)

    def setOptions(self, options):
        """ Getting the options """
        self.options = options

    def getLoadName(self):
        """ The method that takes the filename """
        filename = tkFileDialog.askopenfilename(**self.options)
        self.entry.delete(0, END)
        self.entry.insert(0, filename)

    def enable(self):
        self.label.config(state=NORMAL)
        self.entry.config(state=NORMAL)
        self.button.config(state=NORMAL)

    def disable(self):
        self.label.config(state=DISABLED)
        self.entry.config(state=DISABLED)
        self.button.config(state=DISABLED)
class Input:
    def __init__(self,
                 master,
                 label,
                 default,
                 row_n,
                 column_n=0,
                 pad_y=5,
                 width_n=15,
                 secondary_label=None):
        Label(master, text=label).grid(row=row_n,
                                       column=column_n,
                                       padx=10,
                                       pady=pad_y,
                                       sticky='e')
        f = tk.Frame(master)
        f.grid(row=row_n, column=column_n + 1, sticky='w')
        self.input = Entry(f, width=width_n)
        self.input.grid(row=row_n, column=0, pady=pad_y, sticky='w')
        self.input.insert(tk.END, default)
        if not secondary_label == None:
            Label(f, text=secondary_label).grid(row=row_n,
                                                column=1,
                                                pady=pad_y,
                                                sticky='w')

    def get(self):
        return self.input.get()
Example #37
0
class IndexWidget:

    def __init__(self, parser, prompt, url):
        self.query_url = string.joinfields(string.split(url), '')
        formatter = parser.formatter
        viewer = parser.viewer
        self.context = viewer.context
        self.w = Entry(viewer.text,
                       highlightbackground=viewer.text["background"])
        self.w.bind('<Return>', self.submit)
        formatter.add_hor_rule()
        formatter.add_flowing_data(prompt)
        formatter.add_literal_data('  ')
        parser.add_subwindow(self.w)
        formatter.add_line_break()
        formatter.add_hor_rule()

    def submit(self, event):
        data = self.w.get()
        url = self.query_url or self.context.get_baseurl()
        i = string.find(url, '?')
        if i >= 0:
            url = url[:i]
        url = url + '?' + quote(data)
        self.context.load(url)
Example #38
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='')
Example #39
0
class ReadOnlyEntry(Frame):
    def __init__(self, master, withFocus = True):
        '''
        withFocus -> enabled
            User can set the widget to focus, but the widget will not update
            while it has user focus (even programatically it cannot be updated)

        withFocus -> disabled
            User cannot set focus on the Entry widget. The moment it gets focus,
            focus is shifted to a dummy Frame.
            Widget can be updated programatically anytime.

        Note: in both cases the widget is readonly
        '''
        Frame.__init__(self, master)
        self.master = master
        self.withFocus = withFocus

        self.hasFocus = False
        vcmd = (self.master.register(self.onValidate),
                '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')
        self.readOnlyEntry = Entry(self, justify=CENTER, validate="all", validatecommand=vcmd, width=50)
        self.readOnlyEntry.grid(row=0, column=0)
        self.dummyFrame = Frame(self)
        self.dummyFrame.grid(row=0, column=1)

    def onValidate(self, d, i, P, s, S, v, V, W):
        """
        If withFocus is True, then do not accept keyboard inputs
        If withFocus is False, set focus to the dummy Frame that is not visible
        """
        if self.withFocus == True:
            if V == "focusin":
                self.hasFocus = True
            elif V == "focusout":
                self.hasFocus = False

            if self.hasFocus == False and V == "key":
                    return True
            else:
                return False
        else:
            if V == "focusin":
                self.dummyFrame.focus_set()
            return True


    def configure(self, **kwargs):
        self.readOnlyEntry.configure(**kwargs)

    def config(self, **kwargs):
        self.configure(**kwargs)

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

    def set(self, text):
        self.readOnlyEntry.delete(0, END)
        self.readOnlyEntry.insert(0, text)
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='')
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())
Example #42
0
class OptionsDialog(tkSimpleDialog.Dialog):

    def __init__(self, parent, options_file, title=None, ):
        # instantiate the subclass attributes
        self.options_file=options_file

        # init the super class
        tkSimpleDialog.Dialog.__init__(self, parent, title)


    def body(self, master):
        self.result=False
        config=ConfigParser.ConfigParser()
        config.read(self.options_file)

        Label(master, text="").grid(row=20, sticky=W)
        Label(master, text="Pi Presents Data Home:").grid(row=21, sticky=W)
        self.e_home = Entry(master,width=80)
        self.e_home.grid(row=22)
        self.e_home.insert(0,config.get('config','home',0))

        Label(master, text="").grid(row=30, sticky=W)
        Label(master, text="Inital directory for media:").grid(row=31, sticky=W)
        self.e_media = Entry(master,width=80)
        self.e_media.grid(row=32)
        self.e_media.insert(0,config.get('config','media',0))

        Label(master, text="").grid(row=40, sticky=W)
        Label(master, text="Offset for Current Profiles:").grid(row=41, sticky=W)
        self.e_offset = Entry(master,width=80)
        self.e_offset.grid(row=42)
        self.e_offset.insert(0,config.get('config','offset',0))

        return None    # no initial focus

    def validate(self):
        if os.path.exists(self.e_home.get()) is  False:
            tkMessageBox.showwarning("Pi Presents Editor","Data Home not found")
            return 0
        if os.path.exists(self.e_media.get()) is  False:
            tkMessageBox.showwarning("Pi Presents Editor","Media Directory not found")
            return 0
        if os.path.exists(self.e_home.get()+os.sep+'pp_profiles'+self.e_offset.get()) is  False:
            tkMessageBox.showwarning("Pi Presents Editor","Current Profles directory not found")
            return 0
        return 1

    def apply(self):
        self.save_options()
        self.result=True

    def save_options(self):
        """ save the output of the options edit dialog to file"""
        config=ConfigParser.ConfigParser()
        config.add_section('config')
        config.set('config','home',self.e_home.get())
        config.set('config','media',self.e_media.get())
        config.set('config','offset',self.e_offset.get())
        with open(self.options_file, 'wb') as optionsfile:
            config.write(optionsfile)
Example #43
0
 def setupView(self, title="Test BuildId Page", buildId=''):
     buildIdInput = Entry(self, width="40").grid(row=1,
                                                 columnspan=2,
                                                 sticky="WE")
     self.ok = Button(self,
                      text='Next',
                      command=lambda: self.controller.setValue(
                          self, "BUILD_ID", buildIdInput.get()))
     self.ok.grid(row=2, column=1, sticky="W")
Example #44
0
class SelectGame(tkSimpleDialog.Dialog, object):
    """Server settings window class."""

    def __init__(self, *args, **kwargs):
        """Initiates SelectGame instance with additional attributes.

        :param args: positional arguments - positional arguments passed to parent __init__ method
        :param kwargs: keyword arguments - keyword arguments passed to parent __init__ method
        """
        self.select_game, self.num_players, self.num_turns = None, None, None
        super(SelectGame, self).__init__(*args, **kwargs)

    def body(self, master):
        """Creates select game window.

        :param master: instance - master widget instance
        :return: Entry instance
        """
        self.resizable(False, False)
        Label(master, text='Type in new game title or select existing one').grid(row=0, columnspan=2)
        Label(master, text='Select game:').grid(row=1, sticky='W')
        Label(master, text='Number of players:').grid(row=2, sticky='W')
        Label(master, text='Game duration:').grid(row=3, sticky='W')
        self.select_game = Combobox(master)
        self.select_game.bind('<Button-1>', self.refresh_games)
        self.select_game.grid(row=1, column=1, sticky='W')
        self.num_players = Entry(master)
        self.num_players.insert(END, self.parent.num_players if self.parent.num_players else '')
        self.num_players.grid(row=2, column=1, sticky='W')
        self.num_turns = Entry(master)
        self.num_turns.insert(END, self.parent.num_turns if self.parent.num_turns else '')
        self.num_turns.grid(row=3, column=1, sticky='W')
        return self.select_game

    def apply(self):
        """Assigns entered values to parent game and num_players attributes."""
        self.parent.game = self.select_game.get() if self.select_game.get() != '' else None
        if self.parent.game not in self.parent.available_games:
            self.parent.num_players = int(self.num_players.get()) if self.num_players.get().isdigit() else None
            self.parent.num_turns = int(self.num_turns.get()) if self.num_turns.get().isdigit() else None

    def refresh_games(self, _):
        """Refreshes games list."""
        self.select_game.configure(values=self.parent.available_games)
Example #45
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())
Example #46
0
 def __init__(self):
     self.dimx = 0
     self.dimy = 0
     self.popup_dim = Tk()
     self.popup_dim.title("Dimensions")
     center(self.popup_dim, 200, 120)
     self.popup_dim.resizable(False, False)
     canvas = Canvas(self.popup_dim, width=200, height=120, bg="#eff")
     dimx = Entry(self.popup_dim, width=5, relief="raised")
     dimy = Entry(self.popup_dim, width=5, relief="raised")
     ok = Button(self.popup_dim, text="OK",
                 command=lambda: self.setrootdimension(dimx.get(), dimy.get()),
                 width=1, font="../font/myfont 6 bold", fg="#eee")
     canvas.create_window(100, 30, window=dimx)
     canvas.create_text(65, 30, text="X=")
     canvas.create_window(100, 60, window=dimy)
     canvas.create_text(65, 60, text="Y=")
     canvas.create_window(100, 85, window=ok)
     canvas.pack()
Example #47
0
class SendGCode(LabelFrame):
	def __init__(self, root, prtr, settings, log, *arg):
		LabelFrame.__init__(self, root, *arg, text="Send gcode")
		self.app = root
		self.printer = prtr
		self.settings = settings
		self.log = log

		self.entry = Entry(self, width=50)
		self.entry.grid(row=1, column=1, columnspan=3, sticky=N+E+W)
		
		self.bSend = Button(self, text="Send", width=4, command=self.doSend, state=DISABLED)
		self.bSend.grid(row=1, column=4, padx=2)
		
		self.entry.delete(0, END)
		
		self.entry.bind('<Return>', self.hitEnter)
		self.gcv = StringVar(self)
		
		gclist = gcoderef.gcKeys()
		self.gcv.set(gclist[0])

		l = Label(self, text="G Code Reference:", justify=LEFT)
		l.grid(row=2, column=1, columnspan=2, sticky=W)

		self.gcm = Combobox(self, textvariable=self.gcv)
		self.gcm['values'] = gclist
		self.gcm.grid(row=2, column=3, padx=2)
		
		self.gcm.bind('<<ComboboxSelected>>', self.gcodeSel)
		
		#self.bInfo = Button(self, text="Info", width=9, command=self.doInfo)
		#self.bInfo.grid(row=2, column=4, padx=2)
		
	#def doInfo(self):
	def gcodeSel(self, *arg):
		verb = self.gcv.get()
		self.log.logMsg("%s: %s" % (verb, gcoderef.gcText(verb)))
		
	def activate(self, flag):
		if flag:
			self.bSend.config(state=NORMAL)
		else:
			self.bSend.config(state=DISABLED)
			
	def hitEnter(self, e):
		self.doSend()
		
	def doSend(self): 
		cmd = self.entry.get()
		verb = cmd.split()[0]
		
		if self.app.printerAvailable(cmd=verb):
			self.log.logMsg("Sending: %s" % cmd)
			self.printer.send_now(cmd)
Example #48
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()
Example #49
0
    def sun1():
        mass = float (Entry.get(massboxSun))
        vilosity = float (Entry.get(vilosityboxSun))
        distance = float (Entry.get(distanceboxSun))
        time = float (Entry.get (timeboxSun))
   
        radius = distance+695500 
        force = (mass*vilosity**2)/radius

        Gravity = 6.673*10**(0-11)*radius**2/mass**2
        l=(4*3.14**2)/Gravity*(5.97219*10**24)
        k=l/radius**3
        years=k**.5
        days=years/365
    
        F = (days*k)*time
        orbitcircum = 2*3.14*radius
        distancetraveled = orbitcircum*F
    
        force1 = "The net centrpital force is %.6f,\nthe orbital period is %.2f,\nand the satellite has travelled %.2f" % (force, days, distancetraveled)
        label = Label(top, text = force1) 
Example #50
0
class Login(tkSimpleDialog.Dialog):
    def body(self, master):
        Label(master, text="Username:"******"Password:"******"*")

        self.e1.grid(row=0, column=1)
        self.e2.grid(row=1, column=1)
        return self.e1  # initial focus

    def apply(self):
        username = self.e1.get()
        password = self.e2.get()
        if "csair.com" in username and "mr.yang" in password:
            root = tk.Toplevel()
            GUI_Employer.GUI_Employer(root)
        else:
            tkMessageBox.showwarning("Not Authorized",
                                     "You do not have a permission")
Example #51
0
class InputDialog(_TkDialog):
    def __init__(self, message, default='', hidden=False):
        _TkDialog.__init__(self, message, default, hidden=hidden)

    def _create_selector(self, parent, default, hidden):
        self._entry = Entry(parent, show='*' if hidden else '')
        self._entry.insert(0, default)
        self._entry.select_range(0, END)
        return self._entry

    def _get_value(self):
        return self._entry.get()
Example #52
0
class InputDialog(_TkDialog):
    def __init__(self, message, default=''):
        _TkDialog.__init__(self, message, default)

    def _create_selector(self, parent, default):
        self._entry = Entry(parent)
        self._entry.insert(0, default)
        self._entry.select_range(0, END)
        return self._entry

    def _get_value(self):
        return self._entry.get()
Example #53
0
  def initUI(self):
      self.parent.title("Calendar Entry")
      self.style = Style()
      self.style.theme_use("alt")
      self.pack(fill = BOTH, expand = 1)
      
      quitButton = Button(self, text = "Quit", command = self.quit)
      quitButton.place(x = 425, y = 475)
 # def googleLogin(self):
      entry = Entry(self)
      entry.place(x = 200, y = 70)
      username = entry.get()
Example #54
0
    def __init__(self, root, gui):
        Frame.__init__(self, root)
        self.gui = gui
        self.root = root

        self.config(background="gainsboro")
        Label(self,
              text="Create A New User",
              background="gainsboro",
              height=20,
              width=root.winfo_width()).pack(side=TOP)
        Label(self,
              text="First Name:",
              background="gainsboro",
              font=("Times", "20")).pack()
        text1 = Entry(self, font=("Times", "16"))
        text1.pack()
        Label(self,
              text="Last Name:",
              background="gainsboro",
              font=("Times", "20")).pack()
        text2 = Entry(self, font=("Times", "16"))
        text2.pack()
        Label(self,
              text="Username:"******"gainsboro",
              font=("Times", "20")).pack()
        text3 = Entry(self, font=("Times", "16"))
        text3.pack()
        Label(self,
              text="Password:"******"gainsboro",
              font=("Times", "20")).pack()
        text4 = Entry(self, show="*", font=("Times", "16"))
        text4.pack()
        Button(self,
               text="Create User",
               font=("Times", "20"),
               command=lambda: self.createUser(text3.get(), text4.get(
               ), text1.get(), text2.get())).pack()
Example #55
0
    def earth1():
        mass = float (Entry.get(massboxEarth))
        vilosity = float (Entry.get(vilosityboxEarth))
        distance = float (Entry.get(distanceboxEarth))
        time = float (Entry.get (timeboxEarth))
   
        radius = distance+6378.1
        force = (mass*vilosity**2)/radius
 
        Gravity = 6.673*10**(0-11)*radius**2/mass**2
        l=(4*3.14**2)/Gravity*(1.9891*10**30)
        k=l/radius**3
        years=k**.5
        days=years/365
 
        F = (days*k)*time
        orbitcircum = 2*3.14*radius
        distancetraveled = orbitcircum*F
 
        force1 = "The net centrpital force is %.6f (newtons),\nthe orbital period is %.2f (days),\nthe satellite has travelled %.2f (km)" % (force, days, distancetraveled)
    
        label = Label(top, text = force1).grid(row = 7)
Example #56
0
class InputDialog(_TkDialog):

    def __init__(self, message, default='', hidden=False):
        _TkDialog.__init__(self, message, default, hidden=hidden)

    def _create_selector(self, parent, default, hidden):
        self._entry = Entry(parent, show='*' if hidden else '')
        self._entry.insert(0, default)
        self._entry.select_range(0, END)
        return self._entry

    def _get_value(self):
        return self._entry.get()