Exemple #1
0
    def __init__(self, master):
        self.row = IntVar()
        self.row = None
        self.jmeno = StringVar()
        self.prijmeni = StringVar()
        self.rc = StringVar()
        self.ulice = StringVar()
        self.cp = StringVar()
        self.mesto = StringVar()
        self.psc = StringVar()

        self.mlb = table.MultiListbox(master, (('Jméno', 20), ('Příjmení', 20),
                                               ('Rodné číslo', 12)))
        for i in range(len(data)):
            self.mlb.insert(END, (data[i][0], data[i][1], data[i][2]))
        self.mlb.pack(expand=YES, fill=BOTH, padx=10, pady=10)
        self.mlb.subscribe(lambda row: self.edit(row))
Exemple #2
0
    def __init__(
        self,
        root,
        *args,
        **kwargs,
    ):
        # menu
        self.menu = Menu(root)

        self.filemenu = Menu(self.menu, tearoff=0)
        self.showmenu = Menu(self.menu, tearoff=0)
        self.settingmenu = Menu(self.menu, tearoff=0)
        self.helpmenu = Menu(self.menu, tearoff=0)
        self.menu.add_cascade(label="File", menu=self.filemenu)
        self.menu.add_cascade(label="Display", menu=self.showmenu)
        self.menu.add_cascade(label="Options", menu=self.settingmenu)
        self.menu.add_cascade(label="Help", menu=self.helpmenu)

        self.filemenu.add_command(label="Login")
        self.filemenu.add_command(label="New")
        self.filemenu.add_command(label="Open")
        self.filemenu.add_command(label="Import")
        self.filemenu.add_command(label="Export")
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Quit")

        self.showmenu.add_command(label="Full screen")
        self.showmenu.add_command(label="Edit")
        self.showmenu.add_command(label="Tools")
        self.showmenu.add_command(label="Navigation")

        self.settingmenu.add_command(label="Toolbars")
        self.settingmenu.add_separator()
        self.settingmenu.add_command(label="Server")

        self.helpmenu.add_command(label="Find Action")
        self.helpmenu.add_separator()
        self.helpmenu.add_command(label="About", command=self.about)

        root.config(menu=self.menu)

        #NOTEBOOK

        self.note = tix.NoteBook(root)
        self.note.add("page1", label="Main")
        self.note.add("page2", label="Výpis")
        self.note.add("page3", label="Pridať")

        self.p1 = self.note.subwidget_list["page1"]
        self.p2 = self.note.subwidget_list["page2"]
        self.p3 = self.note.subwidget_list["page3"]

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

        self.bigFrame = Frame(self.p1, bg="Black")
        self.bigFrame.pack(fill=BOTH, expand=1, side=TOP)

        #doubleFrame2
        self.doubleFrame2 = Frame(self.bigFrame)
        self.doubleFrame2.pack(padx=5, pady=5, fill=BOTH, expand=1, side=TOP)

        #page1
        self.profileF = LabelFrame(self.doubleFrame2, text="Profil")
        self.profileF.pack(padx=5, pady=5, fill=BOTH, expand=True, side=TOP)

        #Image
        self.image = Frame(self.profileF, bg="Gray", width=120,
                           height=140).grid(row=0,
                                            column=0,
                                            columnspan=1,
                                            rowspan=3,
                                            padx=15,
                                            pady=(20, 10))

        #ProfilePopis
        self.name = Label(self.profileF, text="Meno:", fg="red").grid(row=0,
                                                                      column=2,
                                                                      padx=8,
                                                                      pady=6,
                                                                      sticky=E)
        self.name = Label(self.profileF, text="Email:",
                          fg="red").grid(row=1,
                                         column=2,
                                         padx=8,
                                         pady=6,
                                         sticky=E)
        self.name = Label(self.profileF, text="Dátum Narodenia:",
                          fg="red").grid(row=2,
                                         column=2,
                                         padx=7,
                                         pady=6,
                                         sticky=E)
        self.name = Label(self.profileF, text="Pozícia:",
                          fg="red").grid(row=3,
                                         column=2,
                                         padx=7,
                                         pady=6,
                                         sticky=E)

        self.name = Label(self.profileF,
                          text="Jožko",
                          font=('Comic Sans MS', 11)).grid(row=0,
                                                           column=3,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)
        self.name = Label(self.profileF,
                          text="*****@*****.**",
                          font=('Comic Sans MS', 11)).grid(row=1,
                                                           column=3,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)
        self.name = Label(self.profileF,
                          text="12.apríla.1995",
                          font=('Comic Sans MS', 11)).grid(row=2,
                                                           column=3,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)
        self.name = Label(self.profileF,
                          text="Redaktor",
                          font=('Comic Sans MS', 11)).grid(row=3,
                                                           column=3,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)

        self.name = Label(self.profileF, text="Priezvisko:",
                          fg="red").grid(row=0,
                                         column=4,
                                         padx=8,
                                         pady=6,
                                         sticky=E)
        self.name = Label(self.profileF, text="Stav:", fg="red").grid(row=1,
                                                                      column=4,
                                                                      padx=8,
                                                                      pady=6,
                                                                      sticky=E)
        self.name = Label(self.profileF, text="Vedúci",
                          fg="red").grid(row=2,
                                         column=4,
                                         padx=7,
                                         pady=6,
                                         sticky=E)
        self.name = Label(self.profileF, text="Počet článkov:",
                          fg="red").grid(row=3,
                                         column=4,
                                         padx=7,
                                         pady=6,
                                         sticky=E)

        self.name = Label(self.profileF,
                          text="Mrkvička",
                          font=('Comic Sans MS', 11)).grid(row=0,
                                                           column=5,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)
        self.name = Label(self.profileF,
                          text="Online",
                          fg="green",
                          font=('Comic Sans MS', 11)).grid(row=1,
                                                           column=5,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)
        self.name = Label(self.profileF,
                          text="Milan Tichý",
                          font=('Comic Sans MS', 11)).grid(row=2,
                                                           column=5,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)
        self.name = Label(self.profileF,
                          text="122",
                          font=('Comic Sans MS', 11)).grid(row=3,
                                                           column=5,
                                                           padx=8,
                                                           pady=6,
                                                           sticky=W)

        self.infoF = LabelFrame(self.doubleFrame2, text="Info")
        self.infoF.pack(padx=5, pady=5, fill=BOTH, side=BOTTOM, expand=1)

        #info
        self.onlineF = LabelFrame(self.infoF, text="Online Admini")
        self.onlineF.pack(padx=5, pady=5, fill=BOTH, expand=1, side=LEFT)

        #resolution

        self.mlb1 = table.MultiListbox(self.onlineF, (
            ('Nick', 10),
            ('Mail', 20),
        ))
        for i in range(len(resolution)):
            self.mlb1.insert(END, (resolution[i][0], resolution[i][1]))
        self.mlb1.pack(expand=YES, fill=BOTH, padx=10, pady=10)

        self.prehladF = LabelFrame(self.infoF, text="Celkový Prehlad")
        self.prehladF.pack(padx=5, pady=5, fill=BOTH, expand=1, side=RIGHT)

        self.visitedTimes = Label(self.prehladF,
                                  text="Návštevy tento mesiac: ",
                                  fg="gray22").grid(row=0,
                                                    column=0,
                                                    sticky=E,
                                                    padx=8,
                                                    pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="Návštevy celkovo: ",
                                  fg="gray22").grid(row=1,
                                                    column=0,
                                                    sticky=E,
                                                    padx=8,
                                                    pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="Počet článkov celkovo: ",
                                  fg="gray22").grid(row=2,
                                                    column=0,
                                                    sticky=E,
                                                    padx=8,
                                                    pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="Počet likov celkovo: ",
                                  fg="gray22").grid(row=3,
                                                    column=0,
                                                    sticky=E,
                                                    padx=8,
                                                    pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="Počet dislike celkovo: ",
                                  fg="gray22").grid(row=4,
                                                    column=0,
                                                    sticky=E,
                                                    padx=8,
                                                    pady=6)

        self.visitedTimes = Label(self.prehladF,
                                  text="2358",
                                  font=('Comic Sans MS', 10)).grid(row=0,
                                                                   column=1,
                                                                   sticky=W,
                                                                   padx=8,
                                                                   pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="25 890",
                                  font=('Comic Sans MS', 10)).grid(row=1,
                                                                   column=1,
                                                                   sticky=W,
                                                                   padx=8,
                                                                   pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="149",
                                  font=('Comic Sans MS', 10)).grid(row=2,
                                                                   column=1,
                                                                   sticky=W,
                                                                   padx=8,
                                                                   pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="2222",
                                  font=('Comic Sans MS', 10)).grid(row=3,
                                                                   column=1,
                                                                   sticky=W,
                                                                   padx=8,
                                                                   pady=6)
        self.visitedTimes = Label(self.prehladF,
                                  text="411",
                                  font=('Comic Sans MS', 10)).grid(row=4,
                                                                   column=1,
                                                                   sticky=W,
                                                                   padx=8,
                                                                   pady=6)

        #-------------------------------------------------------------
        # page2
        self.bigFrame = Frame(self.p2, bg="Black")
        self.bigFrame.pack(fill=BOTH, expand=1, side=TOP)

        self.filterF = LabelFrame(self.bigFrame, text="Výpis článkov / Filter")
        self.filterF.pack(padx=5, pady=5, fill=BOTH, expand=True, side=TOP)

        self.row1 = Frame(self.filterF)
        self.row1.pack(side=TOP, anchor=E)

        self.podrobnosti = Button(self.row1,
                                  text="Zobraz Podrobnosti",
                                  font=('Comic Sans MS', 10),
                                  command=self.showProperties)
        self.podrobnosti.pack(side=RIGHT, padx=10)

        self.podrobnosti = Button(self.row1,
                                  text="Zmeniť stav",
                                  font=('Comic Sans MS', 10),
                                  command=self.changeState)
        self.podrobnosti.pack(side=RIGHT, padx=10)

        self.mlb1 = table.MultiListbox(self.filterF,
                                       (('Titulok', 40), ('Autor', 20),
                                        ('Dátum', 20), ('Stav', 10)))
        for i in range(len(resolution)):
            self.mlb1.insert(END, (articles[i][0], articles[i][1],
                                   articles[i][2], articles[i][3]))
        self.mlb1.pack(expand=YES, fill=BOTH, padx=10, pady=10)

        self.filter = Frame(self.filterF)
        self.filter.pack(fill=BOTH, side=BOTTOM, padx=10, pady=15)

        self.search = Entry(self.filter, width=30)
        self.search.pack(side=LEFT)

        self.autor = Button(self.filter,
                            text="Autor",
                            width=(12),
                            command=self.autor)
        self.autor.pack(side=LEFT, padx=(12, 0))

        self.autor = Button(self.filter,
                            text="Dátum",
                            width=12,
                            command=self.date)
        self.autor.pack(side=LEFT, padx=(12, 0))

        self.autor = Button(self.filter,
                            text="Stav",
                            width=12,
                            fg="green",
                            command=self.state)
        self.autor.pack(side=LEFT, padx=(12, 0))

        self.autor = Button(self.filter,
                            text="Vyhľadat",
                            width=12,
                            fg="red",
                            command=self.searchInputh)
        self.autor.pack(side=LEFT, padx=(12, 0))

        #page3
        self.bigFrame = Frame(self.p3, bg="Black")
        self.bigFrame.pack(fill=BOTH, expand=1, side=TOP)

        self.addF = LabelFrame(self.bigFrame, text="Pridaj článok")
        self.addF.pack(padx=5, pady=5, fill=BOTH, expand=True, side=TOP)

        self.row1 = Frame(self.addF)
        self.row1.pack(side=TOP, fill=X)

        self.title = Label(self.row1, text="Titulok: ")
        self.title.pack(side=LEFT, anchor=W)

        self.titleInput = Entry(self.row1)
        self.titleInput.pack(side=LEFT, expand=1, fill=BOTH, padx=15)

        self.row2 = Frame(self.addF)
        self.row2.pack(side=TOP, fill=X, pady=10)

        self.categorie = Label(self.row2, text="Kategórie: Nevybrané ")
        self.categorie.pack(anchor=W, side=LEFT, padx=10)

        self.categorie = Button(self.row2,
                                text="Vyber Kategórie",
                                command=self.category)
        self.categorie.pack(anchor=W, side=LEFT, padx=10)

        self.imgImport = Button(self.row2,
                                text="Import Image",
                                command=self.importImage)
        self.imgImport.pack(anchor=W, side=RIGHT, padx=10)

        self.categorie = Label(self.row2, text="/img/novýObrázok1 ")
        self.categorie.pack(anchor=W, side=RIGHT, padx=10)

        self.row3 = Frame(self.addF)
        self.row3.pack(side=TOP, fill=X, pady=10)

        self.textHeader = Label(self.row3, text="Text článku:")
        self.textHeader.pack(anchor=W, side=LEFT)

        self.textHeader = Button(self.row3,
                                 text="Moore",
                                 command=self.styleFonte)
        self.textHeader.pack(anchor=W, side=RIGHT, padx=(0, 5), pady=5)

        self.textHeader = Button(self.row3,
                                 text="Font",
                                 command=self.styleFonte)
        self.textHeader.pack(anchor=W, side=RIGHT, padx=(0, 5), pady=5)

        self.textHeader = Button(self.row3, text="U", command=self.styleFonte)
        self.textHeader.pack(anchor=W, side=RIGHT, padx=(0, 5), pady=5)

        self.textHeader = Button(self.row3, text="I", command=self.styleFonte)
        self.textHeader.pack(anchor=W, side=RIGHT, padx=(0, 5), pady=5)

        self.textHeader = Button(self.row3, text="B", command=self.styleFonte)
        self.textHeader.pack(anchor=W, side=RIGHT, padx=(0, 5), pady=5)

        self.text = Text(self.addF, height=10)
        self.text.pack(side=TOP, fill=X, padx=8, pady=8)

        self.row4 = Frame(self.addF)
        self.row4.pack(side=TOP, fill=X, pady=10)

        self.extraOptions = LabelFrame(self.row4, text="Extra Options")
        self.extraOptions.pack(padx=5,
                               pady=5,
                               fill=BOTH,
                               expand=True,
                               side=LEFT)

        self.var1 = IntVar()
        self.lab1 = Label(self.extraOptions, text="Ukáž autorov")
        self.c1 = Checkbutton(self.extraOptions, variable=self.var1)

        self.c1.pack(padx=5, pady=5, side=LEFT)
        self.lab1.pack(padx=5, pady=5, side=LEFT)

        self.var2 = IntVar()
        self.lab2 = Label(self.extraOptions, text="Povoľ Komentáre")
        self.c2 = Checkbutton(self.extraOptions, variable=self.var2)

        self.c2.pack(padx=5, pady=5, side=LEFT)
        self.lab2.pack(padx=5, pady=5, side=LEFT)

        self.extraOptions = Frame(self.row4)
        self.extraOptions.pack(padx=5,
                               pady=5,
                               fill=BOTH,
                               expand=True,
                               side=RIGHT)

        self.row1 = Frame(self.extraOptions)
        self.row1.pack(side=TOP)

        self.dateLabel = Label(self.row1, text="Publikovať: ")
        self.dateLabel.pack(side=LEFT)

        v = StringVar(root, value='dd/yy/mm ss/mm/hh')
        self.dd = Entry(self.row1, textvariable=v)
        self.dd.pack(side=LEFT, padx=15)

        self.row2 = Frame(self.extraOptions)
        self.row2.pack(side=TOP, anchor=SE)

        self.nahlad = Button(self.row2, text="Náhľad", command=self.nahlad)
        self.nahlad.pack(anchor=E, side=RIGHT, padx=(0, 15), pady=10)

        self.publikovat = Button(self.row2,
                                 text="Publikovať",
                                 command=self.public)
        self.publikovat.pack(anchor=E, side=RIGHT, padx=(0, 15), pady=10)
Exemple #3
0
	def __init__(self, netD, master=None):

		self.netD = netD

		self.alive = True

		self.color = "#111"
		self.color2 = "#1a1a1a"

		master.title("Trabalho 1 - Gerencia de redes")
		master.resizable(width=True, height=False)

		rrt = Frame.__init__(self, master, background=self.color)

		self.cab = Frame(self, rrt, bg="black")
		self.msg = Label(self.cab, text="Descoberta da Rede", background="black", fg="#2a3", font=('Verdana', '14', ''), pady="15").pack(fill='both')


		self.cab_online = Frame(self, rrt, bg=self.color)
		Label(self.cab_online, text="---------------------- HOSTS ONLINE ----------------------", fg="white", bg=self.color, pady="5").pack()
		self.frame_online = Frame(self, rrt, bg=self.color2)
		self.listbox = MultiListbox(self.frame_online, height=110, width=800, background=self.color2, bd=0, highlightthickness=0, font=('Trebuchet MS', '12', ''), fg='#aaa')
		self.listbox.config(columns=('Ip address','MAC address', 'Last Poll', 'Vendor', 'Latency'), selectbackground='black')

		self.cab_offline = Frame(self, rrt, bg=self.color)
		self.frame_offline = Frame(self, rrt, bg=self.color2)
		Label(self.cab_offline, text="---------------------- HOSTS OFFLINE ----------------------", fg="white", bg=self.color, pady="5").pack()
		self.listboxoff = MultiListbox(self.frame_offline, height=110, width=800, background=self.color2, bd=0, highlightthickness=0, font=('Trebuchet MS', '12', ''), fg='#aaa')
		self.listboxoff.config(columns=('Ip address','MAC address', 'Last Poll', 'Vendor', 'Latency'), selectbackground='black')

		self.cab_deprecated = Frame(self, rrt, bg=self.color)
		self.frame_deprecated = Frame(self, rrt, bg=self.color2, height=10)
		Label(self.cab_deprecated, text="---------------------- DEPRECATED ----------------------", fg="white", bg=self.color, pady="5").pack()
		self.listboxdep = MultiListbox(self.frame_deprecated, height=110, width=800, background=self.color2, bd=0, highlightthickness=0, font=('Trebuchet MS', '12', ''), fg='#aaa')
		self.listboxdep.config(columns=('Ip address','MAC address', 'Last Poll', 'Discovery time'), selectbackground='black')
		
		self.cab.pack(fill='both')
		self.cab_online.pack(fill='both')
		self.frame_online.pack(fill='both', expand=True)
		self.listbox.pack(side='left')

		self.yscroll = Scrollbar(self.frame_online, command=self.listbox.yview, orient=VERTICAL)
		self.yscroll.pack(side='right')
		self.listbox.configure(yscrollcommand=self.yscroll.set)

		Frame(self, rrt, bg="black", height=20).pack(fill='both')

		self.cab_offline.pack(fill='both')
		self.frame_offline.pack(fill='both', expand=True)
		self.listboxoff.pack(side='left')

		self.yscrolloff = Scrollbar(self.frame_offline, command=self.listboxoff.yview, orient=VERTICAL)
		self.yscrolloff.pack(side='right')
		self.listboxoff.configure(yscrollcommand=self.yscrolloff.set)

		Frame(self, rrt, bg="black", height=20).pack(fill='both')

		self.cab_deprecated.pack(fill='both')
		self.frame_deprecated.pack(fill='both', expand=True)
		self.listboxdep.pack(side='left')

		self.yscrolldep = Scrollbar(self.frame_deprecated, command=self.listboxdep.yview, orient=VERTICAL)
		self.yscrolldep.pack(side='right')
		self.listboxdep.configure(yscrollcommand=self.yscrolldep.set)

		self.rodape = Frame(self, rrt, bg="black", pady=10)#.pack(fill='both')
		self.textfield = Entry(self.rodape, width=21, font=('15'), borderwidth=0)
		self.textfield.grid(row=1, column=2)
		Label(self.rodape, text="Entre com o IP para forçar o poll...", bg='black', fg='white').grid(row=1,column=1)
		self.button = Button(self.rodape, text="Poll!", width=18, borderwidth=0, command=self.poll).grid(row=2, column=2, pady=5)
		self.return_poll = Label(self.rodape, text="Erro ao fazer o poll...", bg='black', fg='red')
		self.return_poll2 = Label(self.rodape, text="", bg='black', fg='red')
		self.return_poll.grid(row=1, column=3, padx=10)
		self.return_poll2.grid(row=1, column=4)
		self.return_poll.config(text="")

		self.rodape.pack(fill='both')
		self.pack(fill='both')

		self.tables = (self.listbox, self.listboxoff, self.listboxdep)
Exemple #4
0
    def __init__(
        self,
        root,
        *args,
        **kwargs,
    ):
        # menu
        self.menu = Menu(root)

        self.filemenu = Menu(self.menu, tearoff=0)
        self.showmenu = Menu(self.menu, tearoff=0)
        self.settingmenu = Menu(self.menu, tearoff=0)
        self.helpmenu = Menu(self.menu, tearoff=0)
        self.menu.add_cascade(label="File", menu=self.filemenu)
        self.menu.add_cascade(label="Display", menu=self.showmenu)
        self.menu.add_cascade(label="Options", menu=self.settingmenu)
        self.menu.add_cascade(label="Help", menu=self.helpmenu)

        self.filemenu.add_command(label="New")
        self.filemenu.add_command(label="Open")
        self.filemenu.add_command(label="Import")
        self.filemenu.add_command(label="Export")
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Quit")

        self.showmenu.add_command(label="Full screen")
        self.showmenu.add_command(label="Edit")
        self.showmenu.add_command(label="Tools")
        self.showmenu.add_command(label="Navigation")

        self.settingmenu.add_command(label="Toolbars")
        self.settingmenu.add_separator()
        self.settingmenu.add_command(label="Server")

        self.helpmenu.add_command(label="Find Action")
        self.helpmenu.add_separator()
        self.helpmenu.add_command(label="About")

        root.config(menu=self.menu)

        #NOTEBOOK

        self.note = tix.NoteBook(root)
        self.note.add("page1", label="Options")
        self.note.add("page2", label="Friends")
        self.note.add("page3", label="Game")

        self.p1 = self.note.subwidget_list["page1"]
        self.p2 = self.note.subwidget_list["page2"]
        self.p3 = self.note.subwidget_list["page3"]

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

        self.bigFrame = Frame(self.p1)
        self.bigFrame.pack(fill=BOTH, expand=1, side=TOP)

        #doubleFrame2
        self.doubleFrame2 = Frame(self.bigFrame)
        self.doubleFrame2.pack(padx=5, pady=5, fill=BOTH, expand=1, side=TOP)

        #page1
        self.screenF = LabelFrame(self.doubleFrame2, text="Screen")
        self.screenF.pack(padx=5, pady=5, fill=BOTH, expand=1, side=LEFT)

        self.resF = LabelFrame(self.doubleFrame2, text="Resolution")
        self.resF.pack(padx=5, pady=5, fill=BOTH, side=RIGHT, expand=1)

        #resolution

        self.mlb1 = table.MultiListbox(self.resF,
                                       (('Resolution', 20), ('Type', 20)))
        for i in range(len(resolution)):
            self.mlb1.insert(END, (resolution[i][0], resolution[i][1]))
        self.mlb1.pack(expand=YES, fill=BOTH, padx=10, pady=10)
        self.mlb1.subscribe(lambda row: self.edit(row))

        #screen
        self.AA = StringVar()

        self.AntiA = Label(self.screenF, text='Anti Aliasing :')
        self.AntiA.grid(row=0, column=0)

        self.x2 = Radiobutton(self.screenF,
                              text="2X",
                              variable=self.AA,
                              value="2X")
        self.x2.grid(row=1, column=0)

        self.x4 = Radiobutton(self.screenF,
                              text="4X",
                              variable=self.AA,
                              value="4X")
        self.x4.grid(row=1, column=1)

        self.x8 = Radiobutton(self.screenF,
                              text="8X",
                              variable=self.AA,
                              value="8X")
        self.x8.grid(row=1, column=2)

        self.x16 = Radiobutton(self.screenF,
                               text="16X",
                               variable=self.AA,
                               value="16X")
        self.x16.grid(row=1, column=3)

        self.tmp = IntVar()
        self.lab = Label(self.screenF, text="Volumetric Lightening")
        self.lab.grid(row=2, column=0)
        self.c = Checkbutton(self.screenF, variable=self.tmp)
        self.c.grid(row=2, column=2)

        self.tmp1 = IntVar()
        self.lab1 = Label(self.screenF, text="Dynamic Shadows")
        self.lab1.grid(row=3, column=0)
        self.c = Checkbutton(self.screenF, variable=self.tmp1)
        self.c.grid(row=3, column=2)

        self.lab2 = Label(self.screenF, text="Field of view")
        self.lab2.grid(row=4, column=0)
        self.w = Scale(self.screenF, from_=90, to=130, orient=HORIZONTAL)
        self.w.grid(row=4, column=2)

        #doubleframe
        self.doubleFrame = Frame(self.bigFrame)
        self.doubleFrame.pack(padx=5, pady=5, fill=BOTH, expand=1, side=BOTTOM)

        #movement
        self.frame4 = LabelFrame(self.doubleFrame, text="Movement")
        self.frame4.pack(padx=5, pady=5, fill=BOTH, expand=1, side=RIGHT)

        self.movef = Label(self.frame4, text='Move Forward :')
        self.movef.grid(row=0, column=0, padx=4, pady=4)
        self.movefE = Entry(self.frame4)
        self.movefE.grid(row=0, column=1, padx=4, pady=4)

        self.mover = Label(self.frame4, text='Move Right :')
        self.mover.grid(row=1, column=0, padx=4, pady=4)
        self.moverE = Entry(self.frame4)
        self.moverE.grid(row=1, column=1, padx=4, pady=4)

        self.movel = Label(self.frame4, text='Move Left :')
        self.movel.grid(row=2, column=0, padx=4, pady=4)
        self.movelE = Entry(self.frame4)
        self.movelE.grid(row=2, column=1, padx=4, pady=4)

        self.moveb = Label(self.frame4, text='Move Back :')
        self.moveb.grid(row=3, column=0, padx=4, pady=4)
        self.movebE = Entry(self.frame4)
        self.movebE.grid(row=3, column=1, padx=4, pady=4)

        self.jump = Label(self.frame4, text='Jump :')
        self.jump.grid(row=4, column=0, padx=4, pady=4)
        self.jumpE = Entry(self.frame4)
        self.jumpE.grid(row=4, column=1, padx=4, pady=4)

        self.crouch = Label(self.frame4, text='Crouch :')
        self.crouch.grid(row=4, column=0, padx=4, pady=4)
        self.crouchE = Entry(self.frame4)
        self.crouchE.grid(row=4, column=1, padx=4, pady=4)

        #abilities
        self.frame42 = LabelFrame(self.doubleFrame, text="Weapon Abilities")
        self.frame42.pack(padx=5, pady=5, fill=BOTH, expand=1, side=LEFT)

        self.tacAb = Label(self.frame42, text='Tactical Ability :')
        self.tacAb.grid(row=0, padx=4, pady=4)
        self.tacAbE = Entry(self.frame42)
        self.tacAbE.grid(row=0, column=1, padx=4, pady=4)

        self.ultAb = Label(self.frame42, text='Ultimate Ability :')
        self.ultAb.grid(row=1, column=0, padx=4, pady=4)
        self.ultAbE = Entry(self.frame42)
        self.ultAbE.grid(row=1, column=1, padx=4, pady=4)

        self.zoomb = Label(self.frame42, text='Zoom :')
        self.zoomb.grid(row=2, column=0, padx=4, pady=4)
        self.zoomE = Entry(self.frame42)
        self.zoomE.grid(row=2, column=1, padx=4, pady=4)

        self.shoot = Label(self.frame42, text='Shoot :')
        self.shoot.grid(row=3, column=0, padx=4, pady=4)
        self.shootE = Entry(self.frame42)
        self.shootE.grid(row=3, column=1, padx=4, pady=4)

        self.steady = Label(self.frame42, text='Steady :')
        self.steady.grid(row=4, column=0, padx=4, pady=4)
        self.steadyE = Entry(self.frame42)
        self.steadyE.grid(row=4, column=1, padx=4, pady=4)

        #save
        self.buttonFrame = Frame(self.p1)
        self.buttonFrame.pack(padx=5, pady=5, expand=1, fill=BOTH)

        self.buttonsframe = Frame(self.buttonFrame)
        self.buttonsframe.pack()
        self.cancelB = Button(self.buttonsframe,
                              text="Koniec",
                              command=self.exit)
        self.cancelB.grid(row=0, column=0)

        self.saveB = Button(self.buttonsframe,
                            text="Ulozit",
                            command=self.save)
        self.saveB.grid(row=0, column=2)

        #page2
        self.row = IntVar()
        self.row = None
        self.name = StringVar()
        self.level = StringVar()

        self.mlb = table.MultiListbox(self.p2, (('Nick', 20), ('Level', 20)))
        for i in range(len(data)):
            self.mlb.insert(END, (data[i][0], data[i][1]))
        self.mlb.pack(expand=YES, fill=BOTH, padx=10, pady=10)
        self.mlb.subscribe(lambda row: self.edit(row))

        self.nb = tix.NoteBook(self.p2)
        self.nb.add("page1", label="Pridať")
        self.nb.add("page2", label="Chat")
        self.p11 = self.nb.subwidget_list["page1"]
        self.p22 = self.nb.subwidget_list["page2"]
        self.nb.pack(fill="both", expand=1, padx=4, pady=4, ipadx=4, ipady=4)

        self.tab1 = Frame(self.p11)
        self.tab1.pack(fill="both", expand=1)

        self.nick = Label(self.tab1, text="Nick ")
        self.nick.grid(row=0)
        self.nicke = Entry(self.tab1)
        self.nicke.grid(row=0, column=1)

        #page2,2
        self.send = Button(self.p22, text="Send")
        self.send.grid(row=0, column=0, sticky=W + E)
        input_text_area = Text(self.p22)
        input_text_area.grid(row=1, column=0, sticky=W + E)
        input_text_area.configure(background='#4D4D4D')

        #save
        self.newBu = Button(self.tab1, text="Novy zaznam", command=self.new)
        self.newBu.grid(row=0, column=3)

        #page3
        self.page3Frame = Frame(self.p3)
        self.page3Frame.pack()

        self.startB = Button(self.page3Frame,
                             text="Start Game",
                             command=self.hello)
        self.startB.pack()
Exemple #5
0
class GUI(Frame):
	def __init__(self, netD, master=None):

		self.netD = netD

		self.alive = True

		self.color = "#111"
		self.color2 = "#1a1a1a"

		master.title("Trabalho 1 - Gerencia de redes")
		master.resizable(width=True, height=False)

		rrt = Frame.__init__(self, master, background=self.color)

		self.cab = Frame(self, rrt, bg="black")
		self.msg = Label(self.cab, text="Descoberta da Rede", background="black", fg="#2a3", font=('Verdana', '14', ''), pady="15").pack(fill='both')


		self.cab_online = Frame(self, rrt, bg=self.color)
		Label(self.cab_online, text="---------------------- HOSTS ONLINE ----------------------", fg="white", bg=self.color, pady="5").pack()
		self.frame_online = Frame(self, rrt, bg=self.color2)
		self.listbox = MultiListbox(self.frame_online, height=110, width=800, background=self.color2, bd=0, highlightthickness=0, font=('Trebuchet MS', '12', ''), fg='#aaa')
		self.listbox.config(columns=('Ip address','MAC address', 'Last Poll', 'Vendor', 'Latency'), selectbackground='black')

		self.cab_offline = Frame(self, rrt, bg=self.color)
		self.frame_offline = Frame(self, rrt, bg=self.color2)
		Label(self.cab_offline, text="---------------------- HOSTS OFFLINE ----------------------", fg="white", bg=self.color, pady="5").pack()
		self.listboxoff = MultiListbox(self.frame_offline, height=110, width=800, background=self.color2, bd=0, highlightthickness=0, font=('Trebuchet MS', '12', ''), fg='#aaa')
		self.listboxoff.config(columns=('Ip address','MAC address', 'Last Poll', 'Vendor', 'Latency'), selectbackground='black')

		self.cab_deprecated = Frame(self, rrt, bg=self.color)
		self.frame_deprecated = Frame(self, rrt, bg=self.color2, height=10)
		Label(self.cab_deprecated, text="---------------------- DEPRECATED ----------------------", fg="white", bg=self.color, pady="5").pack()
		self.listboxdep = MultiListbox(self.frame_deprecated, height=110, width=800, background=self.color2, bd=0, highlightthickness=0, font=('Trebuchet MS', '12', ''), fg='#aaa')
		self.listboxdep.config(columns=('Ip address','MAC address', 'Last Poll', 'Discovery time'), selectbackground='black')
		
		self.cab.pack(fill='both')
		self.cab_online.pack(fill='both')
		self.frame_online.pack(fill='both', expand=True)
		self.listbox.pack(side='left')

		self.yscroll = Scrollbar(self.frame_online, command=self.listbox.yview, orient=VERTICAL)
		self.yscroll.pack(side='right')
		self.listbox.configure(yscrollcommand=self.yscroll.set)

		Frame(self, rrt, bg="black", height=20).pack(fill='both')

		self.cab_offline.pack(fill='both')
		self.frame_offline.pack(fill='both', expand=True)
		self.listboxoff.pack(side='left')

		self.yscrolloff = Scrollbar(self.frame_offline, command=self.listboxoff.yview, orient=VERTICAL)
		self.yscrolloff.pack(side='right')
		self.listboxoff.configure(yscrollcommand=self.yscrolloff.set)

		Frame(self, rrt, bg="black", height=20).pack(fill='both')

		self.cab_deprecated.pack(fill='both')
		self.frame_deprecated.pack(fill='both', expand=True)
		self.listboxdep.pack(side='left')

		self.yscrolldep = Scrollbar(self.frame_deprecated, command=self.listboxdep.yview, orient=VERTICAL)
		self.yscrolldep.pack(side='right')
		self.listboxdep.configure(yscrollcommand=self.yscrolldep.set)

		self.rodape = Frame(self, rrt, bg="black", pady=10)#.pack(fill='both')
		self.textfield = Entry(self.rodape, width=21, font=('15'), borderwidth=0)
		self.textfield.grid(row=1, column=2)
		Label(self.rodape, text="Entre com o IP para forçar o poll...", bg='black', fg='white').grid(row=1,column=1)
		self.button = Button(self.rodape, text="Poll!", width=18, borderwidth=0, command=self.poll).grid(row=2, column=2, pady=5)
		self.return_poll = Label(self.rodape, text="Erro ao fazer o poll...", bg='black', fg='red')
		self.return_poll2 = Label(self.rodape, text="", bg='black', fg='red')
		self.return_poll.grid(row=1, column=3, padx=10)
		self.return_poll2.grid(row=1, column=4)
		self.return_poll.config(text="")

		self.rodape.pack(fill='both')
		self.pack(fill='both')

		self.tables = (self.listbox, self.listboxoff, self.listboxdep)
		
		

	def poll(self):
		#str(self.textfield.get())
		ip = str(self.textfield.get())
		self.return_poll.config(text="Submetendo poll ao ip '" + ip + "' .... ", fg='white')
		
		ups, downs, deps = self.netD.particular_poll(ip)
		if ups or downs or deps:
			self.update_tables(ups, downs, deps)
			self.return_poll2.config(text="Feito!!", fg='green')
		else:
			self.return_poll2.config(text="Erro!!", fg='red')

		#self.return_poll.config(text=self.textfield.get())



	def update_tables(self, ups, downs, deps):
		self.destroy_tables()

		for key in ups.keys():
			self.listbox.insert(END, str(key), str(ups[key][0]), str(ups[key][1]), str(ups[key][2]), str(ups[key][3]))

		for key in downs.keys():
			self.listboxoff.insert(END, str(key), str(downs[key][0]), str(downs[key][1]), str(downs[key][2]), str(downs[key][3]))

		for key in deps.keys():
			self.listboxdep.insert(END, str(key), str(deps[key][0]), str(deps[key][1]), str(deps[key][2]), str(deps[key][3]))

		#self.update()

	def upd(self):
		while True:
			self.update()

	def destroy_tables(self):
		for table in self.tables:
			table.delete(0,END)

	def quit(self):
		self.root.destroy()
		exit(0)
		#self.alive = False

	def is_alive(self):
		return self.alive
Exemple #6
0
    def __init__(self, master):
        root.title('Slovenská pošta')
        self.cena = 1.5
        self.menubar = Menu(master)
        self.filemenu = Menu(self.menubar, tearoff=0)
        self.filemenu.add_command(label="About", command=self.about)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Quit", command=master.quit)
        self.menubar.add_cascade(label="Súbor", menu=self.filemenu)
        self.editmenu = Menu(self.menubar, tearoff=0)
        self.editmenu.add_command(label="Zmeň veľkosť", command=self.about)
        self.menubar.add_cascade(label="Edit", menu=self.editmenu)
        master.title("Menu1")
        master.config(menu=self.menubar)

        self.menoV = StringVar()
        self.priezviskoV = StringVar()
        self.pscV = StringVar()
        self.ulicaV = StringVar()
        self.statV = StringVar()
        self.mestoV = StringVar()

        self.menoVP = StringVar()
        self.priezviskoVP = StringVar()
        self.pscVP = StringVar()
        self.ulicaVP = StringVar()
        self.statVP = StringVar()
        self.mestoVP = StringVar()

        self.nb = ttk.Notebook(master)
        self.mframe = Frame(self.nb)
        self.mframe2 = Frame(self.nb)
        self.nb.add(self.mframe, text="Odosieľateľ")
        self.nb.add(self.mframe2, text="Príjmateľ")
        self.nb.pack(expand=1, fill=BOTH)

        ##odosielateľ
        self.editframe = LabelFrame(self.mframe,
                                    text="Editácia údajov odosielateľa")
        self.editframe.pack(padx=5, pady=5, fill=BOTH, expand=1, side=LEFT)

        self.savedframe = LabelFrame(self.mframe,
                                     text="Uložené údaje odosielateľa")
        self.savedframe.pack(padx=5, pady=5, fill=BOTH, side=RIGHT, expand=1)

        self.meno = Label(self.editframe, text='Meno :')
        self.meno.grid(row=0, column=0, padx=4, pady=4)
        self.menoE = Entry(self.editframe)
        self.menoE.grid(row=0, column=1, padx=4, pady=4)

        self.priezvisko = Label(self.editframe, text='Priezvisko :')
        self.priezvisko.grid(row=2, column=0, padx=4, pady=4)
        self.priezviskoE = Entry(self.editframe)
        self.priezviskoE.grid(row=2, column=1, padx=4, pady=4)

        self.ulica = Label(self.editframe, text='Ulica :')
        self.ulica.grid(row=4, column=0, padx=4, pady=4)
        self.ulicaE = Entry(self.editframe)
        self.ulicaE.grid(row=4, column=1, padx=4, pady=4)

        self.psc = Label(self.editframe, text='PSČ :')
        self.psc.grid(row=4, column=3, padx=4, pady=4)
        self.pscE = Entry(self.editframe)
        self.pscE.grid(row=4, column=4, padx=4, pady=4)

        self.mesto = Label(self.editframe, text="Mesto :")
        self.mesto.grid(row=6, column=0, padx=4, pady=4)
        self.mestoE = Entry(self.editframe)
        self.mestoE.grid(row=6, column=1, padx=4, pady=4)

        self.stat = Label(self.editframe, text="Štát :")
        self.stat.grid(row=8, column=0, padx=4, pady=4)
        self.statE = Entry(self.editframe)
        self.statE.grid(row=8, column=1, padx=4, pady=4)

        self.saveB = Button(self.editframe, text="Uložiť: ", command=self.save)
        self.saveB.grid(row=10, column=0)

        self.meno2 = Label(self.savedframe, text='Meno :')
        self.meno2.grid(row=0, column=0, padx=4, pady=4)
        self.priezvisko2 = Label(self.savedframe, text='Priezvisko :')
        self.priezvisko2.grid(row=2, column=0, padx=4, pady=4)
        self.ulica2 = Label(self.savedframe, text='Ulica :')
        self.ulica2.grid(row=4, column=0, padx=4, pady=4)
        self.psc2 = Label(self.savedframe, text='PSČ :')
        self.psc2.grid(row=4, column=2, padx=4, pady=4)
        self.mesto2 = Label(self.savedframe, text='Mesto :')
        self.mesto2.grid(row=6, column=0, padx=4, pady=4)
        self.stat2 = Label(self.savedframe, text="Štát :")
        self.stat2.grid(row=8, column=0, padx=4, pady=4)

        ## frame2

        ##odosielateľ
        self.editframeP = LabelFrame(self.mframe2,
                                     text="Editácia údajov Príjmateľa")
        self.editframeP.pack(padx=5, pady=5, fill=BOTH, expand=1, side=LEFT)

        self.savedframeP = LabelFrame(self.mframe2,
                                      text="Uložené údaje Príjmateľa")
        self.savedframeP.pack(padx=5, pady=5, fill=BOTH, side=RIGHT, expand=1)

        self.menoP = Label(self.editframeP, text='Meno :')
        self.menoP.grid(row=0, column=0, padx=4, pady=4)
        self.menoEP = Entry(self.editframeP)
        self.menoEP.grid(row=0, column=1, padx=4, pady=4)

        self.priezviskoP = Label(self.editframeP, text='Priezvisko :')
        self.priezviskoP.grid(row=2, column=0, padx=4, pady=4)
        self.priezviskoEP = Entry(self.editframeP)
        self.priezviskoEP.grid(row=2, column=1, padx=4, pady=4)

        self.ulicaP = Label(self.editframeP, text='Ulica :')
        self.ulicaP.grid(row=4, column=0, padx=4, pady=4)
        self.ulicaEP = Entry(self.editframeP)
        self.ulicaEP.grid(row=4, column=1, padx=4, pady=4)

        self.pscP = Label(self.editframeP, text='PSČ :')
        self.pscP.grid(row=4, column=3, padx=4, pady=4)
        self.pscEP = Entry(self.editframeP)
        self.pscEP.grid(row=4, column=4, padx=4, pady=4)

        self.mestoP = Label(self.editframeP, text="Mesto :")
        self.mestoP.grid(row=6, column=0, padx=4, pady=4)
        self.mestoEP = Entry(self.editframeP)
        self.mestoEP.grid(row=6, column=1, padx=4, pady=4)

        self.statP = Label(self.editframeP, text="Štát :")
        self.statP.grid(row=8, column=0, padx=4, pady=4)
        self.statEP = Entry(self.editframeP)
        self.statEP.grid(row=8, column=1, padx=4, pady=4)

        self.saveBP = Button(self.editframeP,
                             text="Uložiť: ",
                             command=self.saveP)
        self.saveBP.grid(row=10, column=0)

        self.meno2P = Label(self.savedframeP, text='Meno :')
        self.meno2P.grid(row=0, column=0, padx=4, pady=4)
        self.priezvisko2P = Label(self.savedframeP, text='Priezvisko :')
        self.priezvisko2P.grid(row=2, column=0, padx=4, pady=4)
        self.ulica2P = Label(self.savedframeP, text='Ulica :')
        self.ulica2P.grid(row=4, column=0, padx=4, pady=4)
        self.psc2P = Label(self.savedframeP, text='PSČ :')
        self.psc2P.grid(row=4, column=2, padx=4, pady=4)
        self.mesto2P = Label(self.savedframeP, text='Mesto :')
        self.mesto2P.grid(row=6, column=0, padx=4, pady=4)
        self.stat2P = Label(self.savedframeP, text="Štát :")
        self.stat2P.grid(row=8, column=0, padx=4, pady=4)

        ##
        self.sluzby = LabelFrame(master, text="Dodatočné služby")
        self.sluzby.pack(padx=5, pady=5, fill=BOTH, expand=1, side=TOP)

        self.var1 = IntVar()
        self.lab1 = Label(self.sluzby, text="1. trieda").grid(row=0, column=0)
        self.c1 = Checkbutton(self.sluzby, variable=self.var1).grid(row=0,
                                                                    column=2)

        self.var2 = IntVar()
        self.lab2 = Label(self.sluzby, text="Doručenka").grid(row=2, column=0)
        self.c2 = Checkbutton(self.sluzby, variable=self.var2).grid(row=2,
                                                                    column=2)

        self.var3 = IntVar()
        self.lab3 = Label(self.sluzby, text="Nevrátiť").grid(row=4, column=0)
        self.c3 = Checkbutton(self.sluzby, variable=self.var3).grid(row=4,
                                                                    column=2)

        self.var4 = IntVar()
        self.lab4 = Label(self.sluzby, text="Nedoposielať").grid(row=6,
                                                                 column=0)
        self.c4 = Checkbutton(self.sluzby, variable=self.var4).grid(row=6,
                                                                    column=2)

        self.var5 = IntVar()
        self.lab5 = Label(self.sluzby, text="Neukladať")
        self.lab5.grid(row=8, column=0)
        self.c5 = Checkbutton(self.sluzby, variable=self.var5).grid(row=8,
                                                                    column=2)

        self.var6 = IntVar()
        self.lab6 = Label(self.sluzby, text="Do vlastných rúk").grid(row=0,
                                                                     column=4)
        self.c6 = Checkbutton(self.sluzby, variable=self.var6).grid(row=0,
                                                                    column=6)

        self.var7 = IntVar()
        self.lab7 = Label(self.sluzby, text="Slepecká zásielka").grid(row=2,
                                                                      column=4)
        self.c7 = Checkbutton(self.sluzby, variable=self.var7).grid(row=2,
                                                                    column=6)

        self.prepocitat = Button(self.sluzby,
                                 text="Prepočítať: ",
                                 command=self.price)
        self.prepocitat.grid(row=10, column=0)

        self.mlb1 = table.MultiListbox(master, (('Produkt', 20), ('kód', 20)))
        for i in range(len(balik)):
            self.mlb1.insert(END, (balik[i][0], balik[i][1]))
        self.mlb1.pack(expand=YES, fill=BOTH, padx=10, pady=10)
        self.mlb1.subscribe(lambda row: self.savechoice(row))

        self.finalframe = LabelFrame(master, text="Finálna suma za dobierku")
        self.finalframe.pack(padx=5, pady=5, fill=BOTH, expand=1, side=RIGHT)
        self.priceL = Label(self.finalframe,
                            text="Výsledná suma je: ").grid(row=2, column=0)
        self.aktualizuj = Button(self.finalframe,
                                 text="Zisti aktuálnu cenu",
                                 command=self.aktualizacia).grid(row=2,
                                                                 column=2)

        self.nb2 = ttk.Notebook(master)
        self.bframe = Frame(self.nb2)
        self.infoframe = Frame(self.nb2)
        self.dframe = Frame(self.nb2)
        self.nb2.add(self.bframe, text="Balík")
        self.nb2.add(self.dframe, text="Dobierka")
        self.nb2.add(self.infoframe, text="Poznámka")
        self.nb2.pack(expand=1, fill=BOTH)

        self.balab1 = Label(self.bframe, text="Hmotnosť:").grid(row=0,
                                                                column=0)
        self.balab2 = Label(self.bframe, text="Šírka:").grid(row=2, column=0)
        self.balab1 = Label(self.bframe, text="Výška:").grid(row=4, column=0)
        self.balab1 = Label(self.bframe, text="Dĺžka:").grid(row=6, column=0)
        self.lab1E = Entry(self.bframe).grid(row=0, column=1, padx=4, pady=4)
        self.lab2E = Entry(self.bframe).grid(row=2, column=1, padx=4, pady=4)
        self.lab3E = Entry(self.bframe).grid(row=4, column=1, padx=4, pady=4)
        self.lab4E = Entry(self.bframe).grid(row=6, column=1, padx=4, pady=4)
        self.jednotka1 = Label(self.bframe, text="kg").grid(row=0, column=2)
        self.jednotka2 = Label(self.bframe, text="cm").grid(row=2, column=2)
        self.jednotka3 = Label(self.bframe, text="cm").grid(row=4, column=2)
        self.jednotka4 = Label(self.bframe, text="cm").grid(row=6, column=2)

        self.AA = StringVar()
        self.x2 = Radiobutton(self.dframe,
                              text="Na adresu",
                              variable=self.AA,
                              value="Adresa").grid(row=0, column=0)
        self.x2 = Radiobutton(self.dframe,
                              text="Na účet",
                              variable=self.AA,
                              value="Ucet").grid(row=0, column=1)

        self.lab1D = Label(self.dframe, text="IBAN").grid(row=2, column=0)
        self.lab1D = Label(self.dframe,
                           text="Variabilný symbol").grid(row=4, column=0)
        self.lab1D = Label(self.dframe, text="Suma").grid(row=6, column=0)
        self.lab1D = Entry(self.dframe).grid(row=2, column=1, padx=4, pady=4)
        self.lab2D = Entry(self.dframe).grid(row=4, column=1, padx=4, pady=4)
        self.lab3D = Entry(self.dframe).grid(row=6, column=1, padx=4, pady=4)

        self.send = Button(self.infoframe, text="Send")
        self.send.grid(row=0, column=0)
        input_text_area = Text(self.infoframe)
        input_text_area.grid(row=1, column=0, sticky=W + E)
        input_text_area.configure(background='#00FFFF')
Exemple #7
0
 def _setScrolledWidget(self):
     self.listbox = MultiListbox.MultiListbox(self)
     return self.listbox
Exemple #8
0
    def __init__(self, master):
        self._row = IntVar()
        self._row = None
        self._jmeno = StringVar()
        self._surname = StringVar()
        self._birth_number = StringVar()
        self._street = StringVar()
        self._number = StringVar()
        self._city = StringVar()
        self._zip = StringVar()
        self._someText = StringVar()

        # menu - TODO

        self._menu = Menu(master)
        self._menu.add_command(label="Soubor", command=self.hello)
        self._menu.add_command(label="Nastavení", command=self.hello)
        self._menu.add_command(label="Nápověda", command=self.hello)

        master.config(menu=self._menu)

        self._menuRightClick = Menu(master)
        self._menuRightClick.add_command(label="Nový záznam",
                                         command=self._new)
        self._menuRightClick.add_command(label="Uložit záznam",
                                         command=self._save)
        self._menuRightClick.add_command(label="Konec",
                                         command=self._endProgram)

        def popup(event):
            self._menuRightClick.post(event.x_root, event.y_root)

        # -- New Button
        self._ImageButtonsFrame = Frame(master, relief=GROOVE)

        self._ImageButtonsFrame.bind("<Button-3>", popup)

        self._imageButtonNew = Button(self._ImageButtonsFrame,
                                      command=self._new)
        self._photoOne = PhotoImage(file="newfile.png")
        self._imageButtonNew.config(image=self._photoOne,
                                    width=100,
                                    height=100)
        self._imageButtonNew.pack(side=LEFT, padx=8, pady=1)

        # -- Save Button
        self._imageButtonSave = Button(self._ImageButtonsFrame,
                                       command=self._save,
                                       width=10,
                                       height=4)
        self._photoTwo = PhotoImage(file="savefile.png")
        self._imageButtonSave.config(image=self._photoTwo,
                                     width=100,
                                     height=100)
        self._imageButtonSave.pack(side=LEFT, padx=8, pady=1)

        self._ImageButtonsFrame.pack(fill=X, padx=8, pady=1)

        self._mlb = table.MultiListbox(master,
                                       (('Jméno', 20), ('Příjmení', 20),
                                        ('Rodné číslo', 12)))

        for i in range(len(data)):
            self._mlb.insert(END, (data[i][0], data[i][1], data[i][2]))
        self._mlb.pack(expand=YES, fill=BOTH, padx=10, pady=10)
        #self._mlb.subscribe( lambda row: self._edit( row ) )
        self._mlb.subscribe(self._edit)

        # form - TODO

        # -- Frame pro dalsi sekci
        self._frameAddNext = Frame(master, relief=GROOVE)
        self._frameAddNext.pack(fill=X, expand=1, padx=2, pady=2)

        # -- Frame pro pridani textu
        self._frameAddText = Frame(self._frameAddNext, relief=GROOVE)
        self._frameAddText.pack(fill=X, side=LEFT, expand=1, padx=2, pady=2)
        # -- Frame pro pridani inputu
        self._frameAddInput = Frame(self._frameAddNext, relief=GROOVE)
        self._frameAddInput.pack(fill=X, side=RIGHT, expand=1, padx=2, pady=2)

        # -- Frame pro jmeno
        self._frameAddInfo = Frame(self._frameAddText, relief=GROOVE)
        self._frameAddInfo.pack(side=RIGHT, padx=2, pady=2)
        # -- Text k jmenu
        self._labelName = Label(self._frameAddInfo, text="Jméno:")
        self._labelName.pack(padx=8, pady=1)
        # -- Text k prijmeni
        self._labelSurname = Label(self._frameAddInfo, text="Příjmeni:")
        self._labelSurname.pack(padx=8, pady=1)
        # -- Text k rodnemu cislu
        self._labelPIN = Label(self._frameAddInfo, text="Rodné číslo:")
        self._labelPIN.pack(padx=8, pady=1)

        # -- Frame pro jmeno
        self._frameAddData = Frame(self._frameAddInput, relief=GROOVE)
        self._frameAddData.pack(side=LEFT, padx=2, pady=2)
        # -- Misto k zapsani jmena
        self._inputName = Entry(self._frameAddData, width=14)
        self._inputName.pack(padx=8, pady=1)
        # -- Misto k zapsani prijmeni
        self._inputSurname = Entry(self._frameAddData, width=14)
        self._inputSurname.pack(padx=8, pady=1)
        # -- Misto k zapsani rodneho cisla
        self._inputPIN = Entry(self._frameAddData, width=14)
        self._inputPIN.pack(padx=8, pady=1)

        # tabs - TODO

        # -- Frame pro pridani inputu
        self._frameAddNoteBook = Frame(
            master,
            relief=GROOVE,
        )
        self._frameAddNoteBook.pack(fill=BOTH, expand=1, padx=2, pady=2)

        self.nb = tix.NoteBook(self._frameAddNoteBook)
        self.nb.add("page1", label="Adresa")
        self.nb.add("page2", label="Poznámka")
        self.p1 = self.nb.subwidget_list["page1"]
        self.p2 = self.nb.subwidget_list["page2"]
        self.nb.pack(expand=1, fill=BOTH)
        #A1
        self._adressFrame = Frame(self.p1, relief=GROOVE, borderwidth=2)
        # -- Frame pro prvni radek
        self._firstRow = Frame(self.p1, relief=GROOVE)
        self._addressLabel = Label(self._firstRow, text="Ulice:")
        self._addressLabel.pack(side=LEFT, padx=8, pady=1)
        self._addressInput = Entry(self._firstRow, width=14)
        self._addressInput.pack(side=LEFT, padx=8, pady=1)
        self._numberDescLabel = Label(self._firstRow, text="č.p.:")
        self._numberDescLabel.pack(expand=1, side=LEFT, padx=18, pady=1)
        self._numberDescInput = Entry(self._firstRow, width=14)
        self._numberDescInput.pack(expand=1, side=LEFT, padx=8, pady=1)
        self._firstRow.pack(fill=X, expand=1)
        # -- Frame pro druhy radek
        self._secondRow = Frame(self.p1, relief=GROOVE)
        self._cityLabel = Label(self._secondRow, text="Město:")
        self._cityLabel.pack(side=LEFT, padx=8, pady=1)
        self._cityInput = Entry(self._secondRow, width=14)
        self._cityInput.pack(side=LEFT, padx=8, pady=1)
        self._secondRow.pack(fill=X, expand=1)
        # -- Frame pro treti radek
        self._thirdRow = Frame(self.p1, relief=GROOVE)
        self._PSCLabel = Label(self._thirdRow, text="PSČ:")
        self._PSCLabel.pack(side=LEFT, padx=8, pady=1)
        self._PSCInput = Entry(self._thirdRow, width=14)
        self._PSCInput.pack(side=LEFT, padx=8, pady=1)
        self._thirdRow.pack(fill=X, expand=1)

        self._adressFrame.pack(fill=X, expand=1)
        #B1
        self._someTextFrame = Frame(self.p2, relief=GROOVE, borderwidth=2)
        self._someTextLabel = Label(self._someTextFrame, text="Poznámka")
        self._someTextLabel.pack(side=LEFT, padx=8, pady=1)
        self._someTextInput = Entry(self._someTextFrame, width=14)
        self._someTextInput.pack(side=LEFT, padx=8, pady=1)
        self._someTextFrame.pack(fill=BOTH, expand=1)

        # buttons - TODO

        self._buttonFrame = Frame(master, relief=GROOVE)
        self._ButtonEnd = Button(self._buttonFrame,
                                 text="Konec",
                                 command=self._endProgram,
                                 width=10,
                                 height=1)
        self._ButtonEnd.pack(side=LEFT, pady=2, padx=4)
        self._ButtonNew = Button(self._buttonFrame,
                                 text="Nový záznam",
                                 command=self._new,
                                 width=10,
                                 height=1)
        self._ButtonNew.pack(side=LEFT, pady=2, padx=4)
        self._ButtonSave = Button(self._buttonFrame,
                                  text="Uložit záznam",
                                  command=self._save,
                                  width=10,
                                  height=1)
        self._ButtonSave.pack(side=LEFT, pady=2, padx=4)
        self._buttonFrame.pack()

        self._fullNameLabel = Label(master, text="")
        self._fullNameLabel.pack(side=LEFT, padx=8, pady=1)
Exemple #9
0
    def __init__(self, master):
        self.master = master
        # Define variables
        self.row = IntVar()
        self.row = None
        self.jmeno = StringVar()
        self.prijmeni = StringVar()
        self.rc = StringVar()
        self.ulice = StringVar()
        self.cp = StringVar()
        self.mesto = StringVar()
        self.psc = StringVar()

        # Multi List Box
        self.multiListBox = table.MultiListbox(master, (('Jméno', 20),
                                                        ('Příjmení', 20),
                                                        ('Rodné číslo', 12)))
        # Insert data
        for i in range(len(data)):
            self.multiListBox.insert(END, (data[i][0], data[i][1], data[i][2]))

        self.multiListBox.pack(expand=YES, fill=BOTH, padx=10, pady=10)
        # Subscribe -> on click call edit on clicked row
        self.multiListBox.subscribe(lambda row: self.select(row))

        # Osobni udaje
        self.osobniUdajeFrame = Frame(master)
        self.osobniUdajeFrame.pack(padx=10, pady=20, side=TOP)
        # Jmeno
        self.jmenoLabel = Label(self.osobniUdajeFrame, text="Jméno:")
        self.jmenoLabel.grid(row=1, column=1)
        self.jmenoEntry = Entry(self.osobniUdajeFrame, width=20)
        self.jmenoEntry.grid(row=1, column=2)
        # Prijmeni
        self.prijmeniLabel = Label(self.osobniUdajeFrame, text="Příjmení:")
        self.prijmeniLabel.grid(row=2, column=1)
        self.prijmeniEntry = Entry(self.osobniUdajeFrame, width=20)
        self.prijmeniEntry.grid(row=2, column=2)
        # Rodne cislo
        self.rodneCisloLabel = Label(self.osobniUdajeFrame,
                                     text="Rodné číslo:")
        self.rodneCisloLabel.grid(row=3, column=1)
        self.rodneCisloEntry = Entry(self.osobniUdajeFrame, width=13)
        self.rodneCisloEntry.grid(row=3, column=2, sticky=W)

        # Note Book
        self.noteBook = tix.NoteBook(master)
        self.noteBook.add("adresaPage", label="Adresa")
        self.noteBook.add("poznamkaPage", label="Poznámka")
        # Adresa subwidgets
        self.adresaPage = self.noteBook.subwidget_list["adresaPage"]
        # Poznamka subwidgets
        self.poznamkaPage = self.noteBook.subwidget_list["poznamkaPage"]

        self.noteBook.pack(fill=BOTH, side=TOP)

        # ADRESA
        self.adresaLabelFrame = LabelFrame(self.adresaPage, text="Adresa")
        self.adresaLabelFrame.pack(fill=BOTH, side=TOP)

        self.adresaFrame = Frame(self.adresaLabelFrame, padx=10, pady=10)
        self.adresaFrame.pack(side=TOP, expand=1)

        self.uliceLabel = Label(self.adresaFrame,
                                text="Ulice: ",
                                padx=4,
                                pady=4)
        self.uliceLabel.grid(row=1, column=1)
        self.mestoLabel = Label(self.adresaFrame,
                                text="Město: ",
                                padx=4,
                                pady=4)
        self.mestoLabel.grid(row=2, column=1)
        self.pscLabel = Label(self.adresaFrame, text="PSČ: ", padx=4, pady=4)
        self.pscLabel.grid(row=3, column=1)
        self.cpLabel = Label(self.adresaFrame, text="č.p.", padx=10, pady=4)
        self.cpLabel.grid(row=1, column=3)

        self.uliceEntry = Entry(self.adresaFrame, width=15)
        self.uliceEntry.grid(row=1, column=2, sticky=W)
        self.mestoEntry = Entry(self.adresaFrame, width=20)
        self.mestoEntry.grid(row=2, column=2, sticky=W)
        self.pscEntry = Entry(self.adresaFrame, width=10)
        self.pscEntry.grid(row=3, column=2, sticky=W)
        self.cpEntry = Entry(self.adresaFrame, width=8)
        self.cpEntry.grid(row=1, column=4)

        # POZNAMKA
        self.poznamkaLabelFrame = LabelFrame(self.poznamkaPage,
                                             text="Poznámka")
        self.poznamkaLabelFrame.pack(fill=BOTH, expand=1, side=TOP)

        self.poznamkaEntry = Text(self.poznamkaLabelFrame, height=10)
        self.poznamkaEntry.pack()

        # Tlacitka
        self.buttonsFrame = Frame(master)
        self.buttonsFrame.pack(padx=10, pady=20)

        self.cancelButton = Button(self.buttonsFrame,
                                   text="Cancel",
                                   width=15,
                                   command=self.clear)
        self.cancelButton.pack(pady=10, side=LEFT)

        self.newRecordButton = Button(self.buttonsFrame,
                                      text="Nový záznam",
                                      width=15,
                                      command=self.newRecord)
        self.newRecordButton.pack(pady=10, side=LEFT)

        self.saveRecordButton = Button(self.buttonsFrame,
                                       text="Uložit záznam",
                                       width=15,
                                       command=self.saveRecord)
        self.saveRecordButton.pack(pady=10, side=LEFT)

        self.showDetailsButton = Button(self.buttonsFrame,
                                        text="Zobrazit detaily",
                                        width=15,
                                        command=self.showDetails)
        self.showDetailsButton.pack(pady=10, side=LEFT)
Exemple #10
0
    def __init__(self, master):

        self.master = master
        self.fLeft = Frame(master)
        self.fTop = Frame(master, borderwidth=5)
        self.fTop.config(bd=4, relief=GROOVE)
        self.fLeft.pack(side=LEFT, fill=Y)
        self.fTop.pack(fill=X)
        self.right = Frame(master)
        self.right.pack(fill=BOTH, expand=True)
        self.bottom = Frame(master).pack(side=BOTTOM, fill=BOTH, expand=True)
        self.fBotBut = Frame(self.right)
        book_image = PhotoImage(file=r"bookmark_208px.png").subsample(2)
        self.radio_button_1 = Button(self.fLeft, image=book_image, bg='white')
        self.radio_button_1.image = book_image
        user_image = PhotoImage(file="contacts_208px.png").subsample(2)
        self.radio_button_2 = Button(self.fLeft, image=user_image, bg='white')
        self.radio_button_2.image = user_image
        transfer_image = PhotoImage(file=r"transfer-208px.png").subsample(2)
        self.radio_button_3 = Button(self.fLeft,
                                     image=transfer_image,
                                     bg=self._from_rgb((191, 206, 26)))
        self.radio_button_3.image = transfer_image
        self.radio_button_1.pack(expand=True, fill='both')
        self.radio_button_2.pack(expand=True, fill='both')
        self.radio_button_3.pack(expand=True, fill='both')

        self.label = Label(self.fTop,
                           text="LIBRARY SYSTEM",
                           font="Verdana 20",
                           fg=self._from_rgb((42, 157, 143)))
        self.label.pack()

        home_image = PhotoImage(file=r"home_96px.png").subsample(3)
        self.photolabel = Button(self.fTop,
                                 image=home_image,
                                 command=self.go_home)

        self.photolabel.place(relx=1, rely=0.95, anchor="se")
        self.photolabel.image = home_image

        self._mlb = table.MultiListbox(self.bottom,
                                       (('ID-number', 8), ('Books', 15),
                                        ('Author', 15), ('Borrowed', 5),
                                        ('Borrower', 10),
                                        ('Borrowed until', 12), ('Status', 4)))
        self.refresh()
        self._mlb.subscribe(self._edit)
        self.loadimage = PhotoImage(file="button.png")

        self.roundedbutton = Button(self.right,
                                    image=self.loadimage,
                                    command=self.new_user)
        self.roundedbutton["border"] = "0"
        self.roundedbutton.pack(side="left", padx=(100, 0))
        self.newimage = PhotoImage(file="refresh_30px.png")
        self.refreshbutton = Button(self.right,
                                    image=self.newimage,
                                    command=self.refresh,
                                    bg=self._from_rgb((42, 157, 143)),
                                    fg='white').pack(side='left',
                                                     anchor=W,
                                                     padx=(30, 5))
        self.newimage2 = PhotoImage(file="search_32px.png")
        self.searchbutton = Button(self.right,
                                   image=self.newimage2,
                                   command=self.search,
                                   bg=self._from_rgb((42, 157, 143)),
                                   fg='white').pack(side='left',
                                                    anchor=W,
                                                    padx=5)
        self._mlb.pack(side="bottom", expand=True, fill=BOTH, padx=20)
Exemple #11
0
	def create_widgets(self):
		self.configure(background="#d3d3d3")
		self.CheckVars = []
		for i in range(self.sensor):
			self.CheckVars.append(IntVar())
			self.CheckVars[i].set(1)
		global tempera
		#tempera.start()
		self.canvas = FigureCanvasTkAgg(f, self)
		self.canvas.draw()
		self.canvas.get_tk_widget().grid(row=1, column=0, sticky=W, pady=5, padx=5)

		#self.canvas._tkcanvas.pack(side=tk.LEFT, expand=True)

		self.lbBoards = tk.Label(self, text = "SAED", font=("default", 20))
		self.lbBoards.grid(row=0, column=0, sticky=W)

		self.image = Image.open("files/conf.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.confPng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/exit.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.exitPng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/play.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.playPng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/pause.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.pausePng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/upload.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.uplPng = ImageTk.PhotoImage(self.image)
		#self.image = Image.open("files/logoUFFS.png")
		self.logoUFFSPng = tk.PhotoImage(file="files/logoUFFS.png")

		self.confs = tk.Button(self, command=self.configuracoes)
		self.confs.config(image=self.confPng)
		self.confs.image = self.confPng
		self.confs.grid(row=0, column=2, sticky=NE)

		self.upload = tk.Button(self, command=self.importFile)
		self.upload.config(image=self.uplPng)
		self.upload.image = self.uplPng
		self.upload.grid(row=0, column=1, sticky=NE)

		self.quit = tk.Button(self, command=root.destroy)
		self.quit.config(image=self.exitPng)
		self.quit.image = self.exitPng
		self.quit.grid(row=3, column=2, sticky=E)

		self.play = tk.Button(self, command=self.onClick)
		self.play.config(image=self.playPng)
		self.play.image = self.playPng
		self.play.grid(row=3, column=1, sticky=E)

		self.buttons = tk.Frame(self)
		self.buttons.grid(row=1, column=1, sticky="nsew")
		self.buttonSensors = []
		for i in range(self.sensor):
			self.buttonSensors.append(tk.Checkbutton(self.buttons, text="Sensor "+str(i), variable = self.CheckVars[i], onvalue = 1, offvalue = 0, height = 3, command=replotSensor))
			self.buttonSensors[i].pack(side="top")

		self.logo = tk.Label(self, image = self.logoUFFSPng) #, background='#00693e'
		self.logo.config(image=self.logoUFFSPng)
		self.logo.image = self.logoUFFSPng
		self.logo.grid(row=3, column=0, sticky=W)


		self.mlb = MultiListbox(self, (('DATA_HORA', 20), ('Sensor 0', 8), ('Sensor 1', 8), ('Sensor 2', 8), ('Sensor 3', 8), ('Sensor 4', 8), ('Sensor 5', 8)))
		[self.mlb.insert(END, (input[0], input[1], input[2], input[3], input[4], input[5], input[6])) for input in self.inputs]
		self.mlb.grid(row=2, column=0, pady=5)
Exemple #12
0
class Application(tk.Frame):
	tempTotal = []
	yTotal = []
	t = 0
	sensor = 5
	boards = 1
	intervalo = 6
	filesPath = "./"
	qtdLeituras = 10
	dt = datetime.now()
	tt = dt.timetuple()
	i = 0
	strDate = ""
	inputs = []
	fileImport = ""
	fileName = ""

	for it in tt:
		if(i < 4):
			strDate += str(it) + "_"
		if(i == 4):
			strDate += str(it)
		i += 1

	for kl in range(1, boards+1):
		Board = "B" + str(kl)
		fileName = "temperature_" + Board + "_" + strDate + ".csv"
		with open(fileName, 'a') as csvfile:
			pass

	def __init__(self, master=None):
		super().__init__(master)
		self.typeTemp = tk.StringVar()
		self.typeTemp.set("0")
		self.chargeConfFile()
		self.confs()
		self.pack()
		self.create_widgets()

	def confs(self):
		self.master.title("Software SAED")
		self.master.maxsize(1000, 800)
		self.master.minsize(1000, 800)
		self.master.configure(background="#d3d3d3")

	def onClick(self):
		global pause
		pause ^= True
		if not pause:
			self.play.config(image=self.pausePng)
			self.play.image = self.pausePng
		else:
			self.play.config(image=self.playPng)
			self.play.image = self.playPng

	def create_widgets(self):
		self.configure(background="#d3d3d3")
		self.CheckVars = []
		for i in range(self.sensor):
			self.CheckVars.append(IntVar())
			self.CheckVars[i].set(1)
		global tempera
		#tempera.start()
		self.canvas = FigureCanvasTkAgg(f, self)
		self.canvas.draw()
		self.canvas.get_tk_widget().grid(row=1, column=0, sticky=W, pady=5, padx=5)

		#self.canvas._tkcanvas.pack(side=tk.LEFT, expand=True)

		self.lbBoards = tk.Label(self, text = "SAED", font=("default", 20))
		self.lbBoards.grid(row=0, column=0, sticky=W)

		self.image = Image.open("files/conf.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.confPng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/exit.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.exitPng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/play.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.playPng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/pause.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.pausePng = ImageTk.PhotoImage(self.image)
		self.image = Image.open("files/upload.png")
		self.image = self.image.resize((32, 32), Image.ANTIALIAS)
		self.uplPng = ImageTk.PhotoImage(self.image)
		#self.image = Image.open("files/logoUFFS.png")
		self.logoUFFSPng = tk.PhotoImage(file="files/logoUFFS.png")

		self.confs = tk.Button(self, command=self.configuracoes)
		self.confs.config(image=self.confPng)
		self.confs.image = self.confPng
		self.confs.grid(row=0, column=2, sticky=NE)

		self.upload = tk.Button(self, command=self.importFile)
		self.upload.config(image=self.uplPng)
		self.upload.image = self.uplPng
		self.upload.grid(row=0, column=1, sticky=NE)

		self.quit = tk.Button(self, command=root.destroy)
		self.quit.config(image=self.exitPng)
		self.quit.image = self.exitPng
		self.quit.grid(row=3, column=2, sticky=E)

		self.play = tk.Button(self, command=self.onClick)
		self.play.config(image=self.playPng)
		self.play.image = self.playPng
		self.play.grid(row=3, column=1, sticky=E)

		self.buttons = tk.Frame(self)
		self.buttons.grid(row=1, column=1, sticky="nsew")
		self.buttonSensors = []
		for i in range(self.sensor):
			self.buttonSensors.append(tk.Checkbutton(self.buttons, text="Sensor "+str(i), variable = self.CheckVars[i], onvalue = 1, offvalue = 0, height = 3, command=replotSensor))
			self.buttonSensors[i].pack(side="top")

		self.logo = tk.Label(self, image = self.logoUFFSPng) #, background='#00693e'
		self.logo.config(image=self.logoUFFSPng)
		self.logo.image = self.logoUFFSPng
		self.logo.grid(row=3, column=0, sticky=W)


		self.mlb = MultiListbox(self, (('DATA_HORA', 20), ('Sensor 0', 8), ('Sensor 1', 8), ('Sensor 2', 8), ('Sensor 3', 8), ('Sensor 4', 8), ('Sensor 5', 8)))
		[self.mlb.insert(END, (input[0], input[1], input[2], input[3], input[4], input[5], input[6])) for input in self.inputs]
		self.mlb.grid(row=2, column=0, pady=5)

	def atualizaMultiList(self):
		self.mlb.delete(0, self.mlb.size())
		[self.mlb.insert(END, (input[0], input[1], input[2], input[3], input[4], input[5], input[6])) for input in self.inputs]

	def importFile(self):
		pack = filedialog.askopenfilename(initialdir = self.filesPath)
		result = "".join(str(x) for x in pack)
		result.replace("()", "")
		if(result != "()" and result != ""):
			self.fileImport = result
			print(self.fileImport)

	def configuracoes(self):
		x = self.winfo_x()
		y = self.winfo_y()
		self.toplevel = tk.Toplevel()
		self.toplevel.geometry("%dx%d+%d+%d" % (300, 200, x + 150, y + 150))
		#self.toplevel.maxsize(450, 350)
		self.toplevel.minsize(650, 450)

		self.infos = tk.Label(self.toplevel, text="Software SAED\n(SISTEMA DE AQUISICAO ELETRONICA DE DADOS EXPERIMENTAIS)").pack(padx=5, pady=10)

		self.lbBoards = tk.Label(self.toplevel, text = "Quantidade de placas (padrao 1):")
		self.lbBoards.pack(expand=1, pady=2)
		self.Boards = tk.Entry(self.toplevel)
		self.Boards.delete(0, END)
		self.Boards.insert(0, self.boards)
		self.Boards.pack(expand=1, pady=2)

		self.lbSens = tk.Label(self.toplevel, text = "Quantidade sensores por placa (padrao 6):")
		self.lbSens.pack(expand=1, pady=2)
		self.sensors = tk.Entry(self.toplevel, text = self.sensor)
		self.sensors.delete(0, END)
		self.sensors.insert(0, self.sensor)
		self.sensors.pack(expand=1, pady=2)

		self.lbInterval = tk.Label(self.toplevel, text = "Intervalo de aferimento de temperatura (em segundos - mínimo de 3):")
		self.lbInterval.pack(expand=1, pady=2)
		self.interv = tk.Entry(self.toplevel, text = self.intervalo)
		self.interv.delete(0, END)
		self.interv.insert(0, self.intervalo)
		self.interv.pack(expand=1, pady=2)

		self.lbPath = tk.Label(self.toplevel, text = "Local para salvar os dados:")
		self.lbPath.pack(expand=1, pady=2)
		self.paths = tk.Label(self.toplevel, text = self.filesPath)
		self.paths.pack(expand=1, pady=2)
		self.pathB = tk.Button(self.toplevel, text = "Selecionar", command=self.changePath)
		self.pathB.pack(expand=1, pady=2)

		self.getTemperature = tk.Button(self.toplevel, text="Confirmar", font = "Verdana 10 bold", command=self.saveConfs)
		self.getTemperature.pack()

		self.info2 = tk.Label(self.toplevel, text="Em caso de problemas contatar Prof. Pedro Borges").pack(padx=5, pady=10)

		self.wait_window(self.getTemperature)

	def changePath(self):
		self.filesPath = filedialog.askdirectory(initialdir = self.filesPath)
		self.paths['text'] = self.filesPath
		print(self.filesPath)

	def saveConfs(self):
		global ani
		try:
			self.boards = int(self.Boards.get())
			self.intervalo = int(self.interv.get())
			if(self.intervalo < 3):
				tkMessageBox.showinfo("Menor que 3 segundos", "Menor que 3 segundos, iremos colocar 3 segundos, como mínimo", parent = self.toplevel)
				self.intervalo = 3
			ani.event_source.interval = self.intervalo*1000
			if(self.sensor != int(self.sensors.get())):
					tkMessageBox.showinfo("Reiniciar", "Será necessário reiniciar a aplicação", parent = self.toplevel)
					self.sensor = int(self.sensors.get())
					self.saveConfFile()
					restart_program()
			tkMessageBox.showinfo("Salvo", "Salvo com sucesso", parent = self.toplevel)
			self.toplevel.destroy()
		except ValueError:
			tkMessageBox.showwarning("Tipo invalido", "As quantidades devem ser numeros inteiros", parent = self.toplevel)

	def getFile(self, fileName):
		with open(fileName, 'r') as csvfile:
			spamreader = csv.reader(csvfile, delimiter=';', quotechar='|')
			for row in reversed(spamreader):
				med = row.rstrip('\n').rstrip('=').split(';')
		return med

	def chargeConfFile(self):
		global globInter
		file = open('files/confs.con', 'r')
		lines = [line.rstrip('\n') for line in file]
		self.sensor = int(lines[0])
		self.boards = int(lines[1])
		self.intervalo = int(lines[2])
		globInter = int(lines[2])
		self.filesPath = lines[3]
		self.typeTemp.set(lines[4])
		self.qtdLeituras = int(lines[5])
		file.close()

	def saveConfFile(self):
		file = open('files/confs.con', 'w')
		file.write(str(self.sensor))
		file.write("\n")
		file.write(str(self.boards))
		file.write("\n")
		file.write(str(self.intervalo))
		file.write("\n")
		file.write(str(self.filesPath))
		file.write("\n")
		file.write(str(self.typeTemp.get()))
		file.write("\n")
		file.write(str(self.qtdLeituras))
		file.write("\n")
		file.close()
Exemple #13
0
class mainWindow:
	def toName(self,num):
		return {
			3 : "NAME",
			4:"FULLNAME",
			5:"NICKNAME",
			6:"PHOTO",
			7:"BDAY",
			8:"ADR",
			9:"LABEL",
			10:"TEL",
			11:"EMAIL",
			12:"GEO",
			13:"TITLE",
			14:"ORG",
			15:"NOTE",
			16:"UID",
			17:"URL",
			18:"OTHER"
		}.get(num,"OTHER")


	def toNum(self,name):
		return {
			"NAME":3,
			"FULLNAME":4,
			"NICKNAME":5,
			"PHOTO":6,
			"BDAY":7,
			"ADR":8,
			"LABEL":9,
			"TEL":10,
			"EMAIL":11,
			"GEO":12,
			"TITLE":13,
			"ORG":14,
			"NOTE":15,
			"UID":16,
			"URL":17,
			"OTHER":18
		}.get(name,18)

	def clearFVP(self):
		size = self.fileList.size()

		for i in range(0,size+1):
			self.fileList.delete(0)


	def clearCVP(self):
		size = self.propList.size()

		for i in range(0,size+1):
			self.propList.delete(0)

	


	def openingFile(self, theFile):
		status = Vcf.readFile(theFile)
		self.currentFile = theFile
		
		self.cardList = []
		
		if (status == "OK"):
			while(True):
				card = []
				status = Vcf.getCard(card)

				if (status == "OK"):
					self.cardList.append(card)
				else:
					break;
		
		else:
			self.addToLog("Error opening the file you selected")


		root.title(os.path.basename(theFile))
		
		#free the shared object now
		#there's a bug somewhere, files of size one segfault when being freed
		if len(self.cardList) > 1:
			Vcf.freeFile()

		#Enable menu items
		self.filemenu.entryconfig(1,state = NORMAL)
		self.filemenu.entryconfig(2,state = NORMAL)
		self.filemenu.entryconfig(3,state = NORMAL)
		self.orgmenu.entryconfig(0, state = NORMAL, command = self.sort)
		self.orgmenu.entryconfig(1, state = NORMAL, command = self.canon)
		self.orgmenu.entryconfig(2, state = NORMAL, command = self.select)

		self.datamenu.entryconfig(1, state = NORMAL)
		self.datamenu.entryconfig(0,state = NORMAL)
		self.datamenu.entryconfig(3, state = NORMAL)

		#clear FVP and CVP
		self.loadFVP()
		self.fileList.selection_set(0)
		event = Event()
		self.loadCVP(event)
		
		bashcommand = "./vcftool -info < " + self.currentFile + " | cat > info.txt"
		os.system(bashcommand)

		file = open("info.txt","r")
		self.addToLog(file.read())
		file.close()

	def appendingFile(self,theFile):

		
		status = Vcf.readFile(theFile)
			
			
		if (status == "OK"):
			while(True):
			
				card = []
				status = Vcf.getCard(card)

				if (status == "OK"):
					self.cardList.append(card)
				else:
					break;
			
		else:
			self.addToLog(self,"Error opening the file you selected")


		if len(self.cardList) > 1:
			Vcf.freeFile()

		#clear FVP and CVP
		self.loadFVP()

		self.fileList.selection_set(0)
		event = Event()
		self.loadCVP(event)

	
	def loadFVP(self):
		self.clearFVP()
		self.clearCVP()

		self.cardCount = 1
		for cardi in self.cardList:
			name = cardi[1][3]	
			adr = ""
			adrCount = 0
			telCount = 0
			first = False
			#Need to parse the address
			for prop in cardi:
				#Count the number of addresses
				if prop[0] == 8 and first == True:
					adrCount +=1
				if(prop[0] == 8 and first == False):
					adr = prop[3]
					adrCount += 1
					first = True

				if prop[0] == 10:
					telCount+=1


			#Extract the region and country from the address string
			if(len(adr) > 0):
				adrList = adr.split(";")
				if(len(adrList) > 6):
					country = adrList[6]
				else:
					country = ""
				
				region = adrList[4]

			else:
				country = ""
				region = ""


			#Determine the flags to be set

			uid = ""
			background = 'yellow'
			flags = ""

			for prop in cardi:
				if self.toName(prop[0]) == "UID":
					uid = prop[3]

			if len(uid) > 0:
				regex = re.compile(r'(@[NATG\\*-][NATG\\*-][NATG\\*-][NATG\\*-]@)')
				regList = (regex.findall(uid))
				if(len(regList) > 0):
					uid = regList[0]
					if uid.find('*') == -1:
						flags = flags + "C"
					if uid.find('*') != -1:
						flags = flags + "-"

				else:
					flags = flags + "-"

			else:
				flags = flags + "-"


			#If the flag hasn't been modified by now then we don't know whats happening
			if len(flags) == 0:
				flags = flags + "?"

			#Now check if there are multiples of mandatory entries
			nCount = 0
			fnCount = 0
			for prop in cardi:
				if self.toName(prop[0]) == "NAME":
					nCount +=1
				if self.toName(prop[0]) == "FULLNAME":
					fnCount +=1

			if nCount > 1 or fnCount > 1:
				flags = flags + "M"

			else:
				flags = flags + "-"


			#Check for photo, url and geo
			photo = False
			geo = False
			url = False
			for prop in cardi:
				if self.toName(prop[0]) == "PHOTO":
					photo = True
				if self.toName(prop[0]) == "GEO":
					geo = True
				if self.toName(prop[0]) == "URL":
					url = True


			if photo == True:
				flags = flags + "P"

			else:
				flags = flags +"-"

			if geo == True:
				flags = flags + "G"
			else:
				flags = flags +"-"
			if url == True:
				flags = flags + "U"
			else:
				flags = flags +"-"


			if flags.find('C') != -1:
				background = 'green'

			if flags.find('M') != -1:
				background = "red"

			self.fileList.insert(END,(self.cardCount,name,region,country,adrCount,telCount,flags))
			self.fileList.lists[6].itemconfig(END,{'bg':background})
			self.cardCount += 1


	def loadCVP(self, event):
		self.clearCVP()
		selection = self.fileList.curselection()

		if(len(selection) == 1):
			index = int(selection[0])
			card = self.cardList[index]

			for prop in card:
				name = self.toName(prop[0])
				if(prop[1] == None):
					partype = ""
				else:
					partype = prop[1]

				if(prop[2] == None):
					parval = ""
				else:
					parval = prop[2]

				if(prop[3] == None):
					value = ""
				else:
					value = prop[3]

				self.propList.insert(END,(name, partype, parval, value))


	def addToLog(self,log):
		self.box.text.config(state=NORMAL)
		self.box.text.insert(END,log + "\n")
		self.box.text.config(state=DISABLED)
		self.box.text.see(END)

	def exit(self):
		if(self.edited == False):
			killServers()
			self.db.close()
			sys.exit()


		self.exitWin = Toplevel()
		self.exitWin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		Label(self.exitWin,text="Save any changes before quitting?").pack(side=TOP)
		Button(self.exitWin,text="Save and quit",command = self.saveandquit).pack(side=TOP)
		Button(self.exitWin,text="Quit without Saving",command = self.close).pack(side=TOP)
		Button(self.exitWin,text="Cancel",command = self.exitWin.destroy).pack(side=TOP)
		self.exitWin.focus_set()
		self.exitWin.transient(root)
		self.exitWin.grab_set()

	def saveWin(self):
		self.saveWin = Toplevel()
		self.saveWin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		Label(self.saveWin,text="Save any changes?").pack(side=TOP)
		Button(self.saveWin,text="Ok",command = self.save).pack(side=TOP)
		Button(self.saveWin,text="Cancel",command = self.saveWin.destroy).pack(side=TOP)
		self.saveWin.focus_set()
		self.saveWin.transient(root)
		self.saveWin.grab_set()

	def saveandquit(self):
		if(self.currentFile == ""):
			self.addToLog("Please choose the Save As option")
		
		else:
			if self.currentFile == "Database":
				self.storeAll()
			else:
				#self.commit()
				Vcf.writeFile(self.currentFile,self.cardList)

		os.remove("temp.vcf")
		self.db.close()
		killServers()
		
		sys.exit()


	#File view functions
	def mapSelect(self):
		sel = self.fileList.curselection()

		if len(sel) == 0:
			self.addToLog("No cards selected")

		for selection in sel:
			card = self.cardList[int(selection)]


			#Get the geo property

			geo = ""
			for prop in card:
				if self.toName(prop[0]) == "GEO":
					geo = prop[3]
					break

			#Get the photo
			photo = ""
			photoCheck = ""
			for prop in card:
				if self.toName(prop[0]) == "PHOTO":
					photo = prop[3]
					photoCheck = prop[2]
					break


			#Get the photo
			adr = "No address"
			for prop in card:
				if self.toName(prop[0]) == "ADR":
					adr = prop[3]
					break



			if geo == "":
				self.addToLog("No GEO property")
				if photo != "" and photoCheck == "":
					os.webbrowser(photo)

				else:
					self.addToLog("Cannot display Photo")

			else:
				location = []
				geolist = geo.split(',')
				for item in geolist:
					location.append(float(item))

				self.gmap.center = location
				self.gmap.addPoint( location, photo, adr )
				length = len(self.gmap.points)
				self.gmap.addOverlay(length-1,1,0)



	
		self.gmap.serve( "public_html/index.html" );
		launchBrowser( "http://localhost:8080/" )
	

	def mapReset(self):
		self.gmap.points = []
		self.gmap.overlays = []

	def browseSelected(self):
		sel = self.fileList.curselection()

		for i in sel:
			curcard = self.cardList[int(i)]
			for prop in curcard:
				if(prop[0] == 17):
					url = prop[3]
					break;

			if len(url) > 0:
				webbrowser.open(url)


	def delSelected(self):
		
		sel = self.fileList.curselection()

		for i in reversed(sel):
			self.cardList.pop(int(i))

		self.loadFVP()
		self.edited = True;



	def addCard(self):
		card = []
		name = (3,None,None," ")
		fname = (4,None,None," ")

		card.append(name)
		card.append(fname)

		self.cardList.append(card)

		self.loadFVP()
		self.edited = True;
	

	#Card View functions
	def up(self):
		propselect = self.propList.curselection()

	

		if len(propselect) != 1:
			self.addToLog("No property selected")
			return 'break'
		
		index = int(propselect[0])

		if index == 1 or index == 2:
			return
		
		temp = self.propList.get(index)
		self.propList.delete(index)
		self.propList.insert(index-1,temp)
		
		self.propList.selection_set(index-1)
		self.changesMade = True

	def down(self):
		propselect = self.propList.curselection()

		if len(propselect) != 1:
			self.addToLog("No property selected")
			return 'break'
		
		index = int(propselect[0])

		if index == 1 or index == 0:
			return
		
		temp = self.propList.get(index)
		self.propList.delete(index)
		self.propList.insert(index+1,temp)

		self.propList.selection_set(index+1)
		self.changesMade = True

	def addProp(self):

		sel = self.fileList.curselection()

		if len(sel) != 1:
			self.addToLog("Could not add property")
			return 'break'
		
		self.addprop = Toplevel()
		self.addprop.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		
		options = ["NICKNAME",
					"PHOTO",
					"BDAY",
					"ADR",
					"LABEL",
					"TEL",
					"VCP_EMAIL",
					"GEO",
					"TITLE",
					"ORG",
					"NOTE",
					"UID",
					"URL",
					"OTHER"
		]

	
		self.variable = StringVar(self.addprop)
		self.variable.set(options[0])
		self.variable.trace('w', self.propToggle)
		Label(self.addprop,text="Property Name: ").grid(row = 0, column = 0)
		self.optmenu = OptionMenu(self.addprop, self.variable,*options)
		self.optmenu.grid(row = 0, column = 1)

		Label(self.addprop,text="Type Parameter: ").grid(row = 1, column = 0)
		self.partypeBox = Text(self.addprop, height = 1, width = 30)
		self.partypeBox.grid(row = 1, column = 1)

		Label(self.addprop,text="Val Parameter: ").grid(row = 2, column = 0)
		self.parvalBox = Text(self.addprop, height = 1, width = 30)
		self.parvalBox.grid(row = 2, column = 1)

		Label(self.addprop,text="Property Value: ").grid(row = 3, column = 0)
		self.valueBox = Text(self.addprop, height = 1, width = 30)
		self.valueBox.grid(row = 3, column = 1)

		Button(self.addprop,text = "OK", command = self.addtheProp).grid(row = 4, column = 0)
		Button(self.addprop,text = "Cancel", command = self.addprop.destroy).grid(row = 4, column = 1)

	
		self.addprop.focus_set()
		self.addprop.transient(root)
		self.addprop.grab_set()
		self.addprop.wait_window(self.addprop)


	def editProp(self):
		return
		
	def propToggle(self,*args):
		if(self.variable.get() == "OTHER"):
			self.partypeBox.delete("1.0",END)
			self.partypeBox.config(state=DISABLED)

			self.parvalBox.delete("1.0",END)
			self.parvalBox.config(state=DISABLED)
		else:
			self.partypeBox.config(state = NORMAL)

			self.parvalBox.config(state=NORMAL)

	def addtheProp(self):

		name = self.variable.get()
		partype = self.partypeBox.get("1.0",END)
		parval = self.parvalBox.get("1.0",END)
		value = self.valueBox.get("1.0",END)

		
		partype = partype[:-1]
		parval = parval[:-1]
		value = value[:-1]
		
		newProp = self.propList.insert(END,(name,partype,parval,value))
		self.addprop.destroy()
		self.changesMade = True;



	def delProp(self):


		cardselect = self.fileList.curselection()
		propselect = self.propList.curselection()

		if len(propselect) != 1:
			self.addToLog("No property selected")
			return 'break'
		
		propNum = int(propselect[0])
		self.propList.delete(propNum)
		self.changesMade = True
		
	

	def commit(self):
		cardselect = self.fileList.curselection()
		
		index = int(cardselect[0])

		#clear the card
		self.cardList[index] = []

		size = self.propList.size()

		newCard = []

		for i in range(0,size):

			prop = self.propList.get(i)
			name = self.toNum(prop[0])
			partype = prop[1]
			parval = prop[2]
			value = prop[3]
			newProp = (name,partype,parval,value)

			newCard.append(newProp)


		self.cardList[index] = newCard

		self.loadFVP()
		event = ""
		self.fileList.selection_set(cardselect)
		self.changesMade = False
		self.edited = True
		
		self.loadCVP(event)

		
		

	def revert(self):
		self.loadFVP()
		event = ""
		self.loadCVP(event)
		self.changesMade = False
		
		

	#file menu functions
	def open(self):
		self.openFile = tix.ExFileSelectDialog(root)
		self.openFile.fsbox["command"] = self.openingFile
		self.openFile.popup()


	def append(self):
		if len(self.cardList) == 0:
			self.addToLog("Cannot append to empty file")

		else:
			self.openFile = tix.ExFileSelectDialog(root)
			self.openFile.fsbox["command"] = self.appendingFile
			self.openFile.popup()

	
	def save(self):
		if(self.currentFile == ""):
			self.addToLog("Please choose the Save As option")
		
		else:
			#self.commit()
			Vcf.writeFile(self.currentFile,self.cardList)
			self.saveWin.destroy()
	

	def saveAs(self):
		self.saveFileFile = tix.ExFileSelectDialog(root)
		self.saveFileFile.fsbox["command"] = self.savingFile
		self.saveFileFile.popup()


	def savingFile(self,theFile):
		self.currentFile = theFile
		Vcf.writeFile(self.currentFile,self.cardList)

	def saveDisplay(self):
		
		self.saveWin = Toplevel()
		self.saveWin.title("Save")
		self.saveWin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		self.saveWin.geometry("300x100")
		Label(self.saveWin,text="Are you sure you want to save changes?").pack(side=TOP)
		Button(self.saveWin,text="OK", command = self.save).pack(side=TOP)
		Button(self.saveWin,text="Cancel", command = self.saveWin.destroy).pack(side=TOP)
		self.saveWin.focus_set()
		self.saveWin.transient(root)
		self.saveWin.grab_set()
		root.wait_window(self.saveWin)
	
	def sort(self):
		bashcommand = "./vcftool -sort < " + self.currentFile + " | cat > temp.vcf"
		os.system(bashcommand)

		#reload the file
		status = Vcf.readFile("temp.vcf")
		
		self.cardList = []
		
		if (status == "OK"):
			while(True):
		
				card = []
				status = Vcf.getCard(card)

				if (status == "OK"):
			
					self.cardList.append(card)
				else:
					break;
		
		else:
			self.addToLog("Error opening the file")


		#free the shared object now
		Vcf.freeFile()

		#clear FVP and CVP
		self.loadFVP()
		self.fileList.selection_set(0)
		
		self.loadCVP("")
		self.edited = True



	def canon(self):
		bashcommand = "./vcftool -canon < " + self.currentFile + " | cat > temp.vcf"
		os.system(bashcommand)

		#reload the file
		status = Vcf.readFile("temp.vcf")
		
		self.cardList = []
		
		if (status == "OK"):
			while(True):
		
				card = []
				status = Vcf.getCard(card)

				if (status == "OK"):
			
					self.cardList.append(card)
				else:
					break;
		
		else:
			self.addToLog("Error opening the file")


		#free the shared object now
		if len(self.cardList) > 1:
			Vcf.freeFile()

		#clear FVP and CVP
		self.loadFVP()
		self.fileList.selection_set(0)
		
		self.loadCVP("")
		mainWindow.addToLog(self,"canon")

	
	def select(self):
		self.selwin = Toplevel()
		self.selwin.title("Select")
		self.selwin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		self.selwin.geometry("300x120")
		
		self.photoChecked = IntVar()
		self.photobutton = Checkbutton(self.selwin,text="Photos", onvalue = 1, offvalue = 0, variable = self.photoChecked)
		self.photobutton.pack(side=TOP)
		
		self.geocheck = IntVar()
		self.geobutton = Checkbutton(self.selwin,text = "Geo", onvalue = 1, offvalue = 0, variable = self.geocheck)
		self.geobutton.pack(side=TOP)
		
		self.urlcheck = IntVar()
		self.urlbutton = Checkbutton(self.selwin, text = "URLS", onvalue = 1, offvalue = 0, variable = self.urlcheck)
		self.urlbutton.pack(side=TOP)
		
		
		Button(self.selwin,text="OK", command = self.getoptions).pack(side=TOP)
		Button(self.selwin,text="Cancel", command = self.selwin.destroy).pack(side=TOP)
		mainWindow.addToLog(self,"select")

		self.selwin.focus_set()
		self.selwin.transient(root)
		self.selwin.grab_set()
		root.wait_window(self.selwin)


	def getoptions(self):
		options = ""
		if self.photoChecked.get() == 1:
			options = options + "p"

		if self.geocheck.get() == 1:
			options = options + "g"

		if self.urlcheck.get() == 1:
			options = options + "u"
		
		bashcommand = "./vcftool -select " + options + " < " + self.currentFile + " | cat > temp.vcf"
		os.system(bashcommand)


		#Check if temp.vcf is empty
		check = os.stat("temp.vcf").st_size
		
		if check == 0:
			self.nope = Toplevel()
			self.nope.title("Warning")
			self.nope.bind("<Escape>", lambda e: self.destroyWin(e.widget))
			self.nope.geometry("300x100")
			Label(self.nope,text="Selection will not return any results").pack(side=TOP)
			
			Button(self.nope,text="OK", command = self.nope.destroy).pack(side=TOP)
			self.nope.focus_set()
			self.nope.transient(root)
			self.nope.grab_set()
			root.wait_window(self.nope)
			return "break"

		else:

			#reload the file

			status = Vcf.readFile("temp.vcf")
			
			self.cardList = []
			
			if (status == "OK"):
				while(True):
			
					card = []
					status = Vcf.getCard(card)

					if (status == "OK"):
				
						self.cardList.append(card)
					else:
						break;
			
			else:
				self.addToLog("Error opening the file")


			if len(self.cardList) > 1:
				Vcf.freeFile()

			#clear FVP and CVP
			self.loadFVP()
			self.fileList.selection_set(0)
			
			self.loadCVP("")

			self.selwin.destroy()

	def undo(self):
		mainWindow.addToLog(self,"undo")


	#Help menu
	def about(self):
		self.abwin = Toplevel()
		self.abwin.title("About")
		self.abwin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		self.abwin.geometry("300x100")
		Label(self.abwin,text="xvcf created by Salim Chabou").pack(side=TOP)
		Label(self.abwin,text="Compatible with Vcard version 3.0 only").pack(side=TOP)
		
		Button(self.abwin,text="OK", command = self.abwin.destroy).pack(side=TOP)
		self.abwin.focus_set()
		self.abwin.transient(root)
		self.abwin.grab_set()
		root.wait_window(self.abwin)


	def cards(self):
		self.cardwin = Toplevel()
		self.cardwin.title("About")
		self.cardwin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		#self.cardwin.geometry("300x100")
		Label(self.cardwin,text="C: Canonicalized, - if not, ? if unknown").pack(side=TOP)
		Label(self.cardwin,text="M: Multiple mandatory properties exist, - if not").pack(side=TOP)
		Label(self.cardwin,text="P,U,G: Photos, URLS, Geo present, - if not").pack(side=TOP)
		Label(self.cardwin,text="Green: Canonicalized").pack(side=TOP)
		Label(self.cardwin,text="Yellow: Not canonicalized").pack(side=TOP)
		Label(self.cardwin,text="Red: Card needs to be fixed, has multiple mandatories or is a duplicate card").pack(side=TOP)
		
		Button(self.cardwin,text="OK", command = self.cardwin.destroy).pack(side=TOP)
		self.cardwin.focus_set()
		self.cardwin.transient(root)
		self.cardwin.grab_set()
		root.wait_window(self.cardwin)

	def clear(self):
		self.box.text.config(state=NORMAL)
		self.box.text.delete("1.0", END)
		self.box.text.config(state=DISABLED)
		self.box.text.see(END)


	def openFromDB(self):
		#query the name database

		query = ("SELECT * FROM NAME")

		self.dbcursor.execute(query)
		results = self.dbcursor.fetchall()

		if(len(results) == 0):
			self.dbemptywin = Toplevel()
			self.dbemptywin.title("About")
			self.dbemptywin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
				#self.dbemptywin.geometry("300x100")
			Label(self.dbemptywin,text="Database is empty, could not open from it").pack(side=TOP)
			
			Button(self.dbemptywin,text="OK", command = self.dbemptywin.destroy).pack(side=TOP)
			self.dbemptywin.focus_set()
			self.dbemptywin.transient(root)
			self.dbemptywin.grab_set()
			root.wait_window(self.dbemptywin)
			return

		newCardList = []
		for(name_id, name) in results:
			card = []
			#Create name property
			propID = 3
			theName = name
			prop = (propID,None,None,theName)
			card.append(prop)

			#Query the database for its properties
			query = ("SELECT * "
					 "FROM PROPERTY "
					 "WHERE name_id = '%s'") % (name_id)

			try:
				self.dbcursor.execute(query)
			except:
				self.addToLog("Error with query")
				return

			propResults = self.dbcursor.fetchall()

			for props in propResults:
				propID = self.toNum(props[1])
				if props[3] == 'None':
					partype = None
				else:
					partype = props[3]

				if props[4] == 'None':
					parval = None
				else:
					parval = props[4]

				if props[5] == 'None':
					value = None
				else:
					value = props[5]

				newProp = (propID, partype, parval, value)
				if(propID == 4):
					card.insert(1,newProp)
				else:
					card.append(newProp)


			#Append new card to the cardList
			newCardList.append(card)

		#If we made it here then we're good to change the title and load up the new card list
		self.cardList = []
		self.cardList = newCardList
		root.title("Database")
		self.currentFile = "Database"

		#Enable menu items
		self.filemenu.entryconfig(1,state = NORMAL)
		self.filemenu.entryconfig(3,state = NORMAL)
		self.orgmenu.entryconfig(0, state = NORMAL, command = self.sort)
		self.orgmenu.entryconfig(1, state = NORMAL, command = self.canon)
		self.orgmenu.entryconfig(2, state = NORMAL, command = self.select)

		self.datamenu.entryconfig(1, state = NORMAL)
		self.datamenu.entryconfig(0,state = NORMAL)
		self.datamenu.entryconfig(3,state = NORMAL)

		#clear FVP and CVP
		self.loadFVP()
		self.fileList.selection_set(0)
		event = Event()
		self.loadCVP(event)


	def appendFromDB(self):
		query = ("SELECT * FROM NAME")

		self.dbcursor.execute(query)
		results = self.dbcursor.fetchall()


		if(results[0] is None):
			self.dbemptywin = Toplevel()
			self.dbemptywin.title("About")
			self.dbemptywin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
				#self.dbemptywin.geometry("300x100")
			Label(self.dbemptywin,text="Database is empty, could not open from it").pack(side=TOP)
			
			Button(self.dbemptywin,text="OK", command = self.dbemptywin.destroy).pack(side=TOP)
			self.dbemptywin.focus_set()
			self.dbemptywin.transient(root)
			self.dbemptywin.grab_set()
			root.wait_window(self.dbemptywin)
			return

		newCardList = self.cardList
		for(name_id, name) in results:
			card = []
			#Create name property
			propID = 3
			theName = name
			prop = (propID,None,None,theName)
			card.append(prop)

			#Query the database for its properties
			query = ("SELECT * "
					 "FROM PROPERTY "
					 "WHERE name_id = '%s'") % (name_id)

			try:
				self.dbcursor.execute(query)
			except:
				self.addToLog("Error with query")
				return

			propResults = self.dbcursor.fetchall()

			for props in propResults:
				propID = self.toNum(props[1])
				partype = props[3]
				parval = props[4]
				value = props[5]

				newProp = (propID, partype, parval, value)
				if(propID == 4):
					card.insert(1,newProp)
				else:
					card.append(newProp)


			#Append new card to the cardList
			newCardList.append(card)

		#If we made it here then we're good to change the title and load up the new card list
		self.cardList = newCardList
		root.title("Database")


		#clear FVP and CVP
		self.loadFVP()
		self.fileList.selection_set(0)
		event = Event()
		self.loadCVP(event)


	def storeAll(self):
		
		for card in self.cardList:
			
			name = str(card[0][3])


			#Query the NAME table to find matches

			query = "SELECT name FROM NAME"

			try:
				self.dbcursor.execute(query)
			except:
				addToLog("Error with query")


			results = self.dbcursor.fetchall()

			queryName = name.strip(";")

			match = False
			for matches in results:
				compare = matches[0].strip(";")
				if queryName == compare:
					match = True;


			if match == True:
				self.check = ""
				self.matchWindow(name,card)
				if(self.check == "Don't add"):
					continue

				if(self.check == "Cancel"):
					return

				if(self.check == "Merge"):
					self.mergeDB(name, card)
					continue

				if(self.check == "Replace"):
					self.replaceInDB(name,card)
			else:
				self.addToDB(name, card)

	def storeSelected(self):
		selection = self.fileList.curselection()

		for index in selection:
			card = self.cardList[int(index)]
			name = str(card[0][3])


			#Query the NAME table to find matches

			query = "SELECT name FROM NAME"

			try:
				self.dbcursor.execute(query)
			except:
				addToLog("Error with query")


			results = self.dbcursor.fetchall()

			queryName = name.strip(";")

			match = False
			for matches in results:
				compare = matches[0].strip(";")
				if queryName == compare:
					match = True;


			if match == True:
				self.check = ""
				self.matchWindow(name,card)
				if(self.check == "Don't add"):
					continue

				if(self.check == "Cancel"):
					return

				if(self.check == "Merge"):
					self.mergeDB(name,card)

				if(self.check == "Replace"):
					self.replaceInDB(name,card)

			else:
				self.addToDB(name, card)

			
	def addToDB(self, name, card):
			add_name = ("INSERT INTO NAME "
		               		"(name_id,name) "
		               		"VALUES (default,'%s')") % (name)


			try:
				self.dbcursor.execute(add_name)
				self.db.commit()
			except:
				self.db.rollback()
			

			name_id = self.dbcursor.lastrowid

			for prop in card[1:]:
				pname = self.toName(prop[0])

				#Query for the pinst
				query = ("SELECT MAX(PINST) "
						 "FROM PROPERTY "
						 "WHERE pname = '%s' AND name_id = '%s'") % (pname,name_id)
				try:
					self.dbcursor.execute(query)
				except:
					self.addToLog("Error with query")

				result = self.dbcursor.fetchone()
				pinst = result[0]

				if pinst == None:
					pinst = 1
				else:
					pinst = int(pinst) + 1

				partype = prop[1]
				parval = prop[2]
				value = prop[3]
		


				add_prop = ("INSERT INTO PROPERTY "
							"(name_id, pname, pinst, partype, parval,value) " 
							"VALUES (%s, %s, %s, %s, %s, %s)")


				data_prop = (name_id, pname, pinst, partype, parval, value)


				try:
					self.dbcursor.execute(add_prop, data_prop)
					self.db.commit()
				except:
					self.db.rollback()


	def replaceInDB(self,name, card):
		#First query the name_id associated with that name
		query = ("SELECT name_id "
				"FROM NAME "
				"WHERE name = '%s'") % (name)

		try:
			self.dbcursor.execute(query)
		except:
			self.addToLog("Error with query")
			return
		
		results = self.dbcursor.fetchone()

		name_id = results[0]

		del_command = ("DELETE FROM PROPERTY "
					   "WHERE name_id = '%s'") % (name_id)

		try:
			self.dbcursor.execute(del_command)
			self.db.commit()
		except:
			self.addToLog("Error with command")
			self.db.rollback()


		#Now that we've removed them add the new ones
		for prop in card[1:]:
				pname = self.toName(prop[0])

				#Query for the pinst
				query = ("SELECT MAX(PINST) "
						 "FROM PROPERTY "
						 "WHERE pname = '%s' AND name_id = '%s'") % (pname,name_id)
				try:
					self.dbcursor.execute(query)
				except:
					self.addToLog("Error with query")

				result = self.dbcursor.fetchone()
				pinst = result[0]

				if pinst == None:
					pinst = 1
				else:
					pinst = int(pinst) + 1

				partype = prop[1]
				parval = prop[2]
				value = prop[3]
		


				
				add_prop = ("INSERT INTO PROPERTY "
							"(name_id, pname, pinst, partype, parval,value) " 
							"VALUES (%s, %s, %s, %s, %s, %s)")


				data_prop = (name_id, pname, pinst, partype, parval, value)


				try:
					self.dbcursor.execute(add_prop, data_prop)
					self.db.commit()
				except:
					self.db.rollback()


				try:
					self.dbcursor.execute(add_prop)
					self.db.commit()
				except:
					self.db.rollback()


	def mergeDB(self, name, card):
		#First query the name_id associated with that name
		query = ("SELECT name_id "
				"FROM NAME "
				"WHERE name = '%s'") % (name)

		try:
			self.dbcursor.execute(query)
		except:
			self.addToLog("Error with query")
			return
		
		results = self.dbcursor.fetchone()

		name_id = results[0]

		for prop in card[1:]:
			#Grab the name from the property and then
			#pull from the database
			theName = self.toName(prop[0])

			query = ("SELECT * "
					"FROM PROPERTY "
					"WHERE pname = '%s' AND name_id = '%s'") % (theName,name_id)

			secondQuery = ("SELECT MAX(pinst)"
					"FROM PROPERTY "
					"WHERE pname = '%s' AND name_id = '%s'") % (theName,name_id)

			#Execute the queries and grab the info
			self.dbcursor.execute(query)
			results = self.dbcursor.fetchall()

			self.dbcursor.execute(secondQuery)
			pinstResults = self.dbcursor.fetchone()

			#Get the max instance of the property
			if pinstResults[0] is None:
				pinst = 1
			else:
				pinst = int(pinstResults[0]) + 1

			partype = prop[1]
			parval = prop[2]
			value = prop[3]

			match = False
			for things in results:
				#If there is an exact match then flag the boolean
				if things[5] == value and things[4] == parval and things[3] == partype:
					print(things)
					match = True


			#If match is still false after this no matches were found
			#Add this in
			if match == False:
				
				add_prop = ("INSERT INTO PROPERTY "
							"(name_id, pname, pinst, partype, parval,value) " 
							"VALUES (%s, %s, %s, %s, %s, %s)")


				data_prop = (name_id, pname, pinst, partype, parval, value)


				try:
					self.dbcursor.execute(add_prop, data_prop)
					self.db.commit()
				except:
					self.db.rollback()


				try:
					self.dbcursor.execute(add_prop)
					self.db.commit()
				except:
					self.db.rollback()



	def matchWindow(self, name, card):
		self.matchWin = Toplevel()

		
		self.matchWin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		#self.matchWin.protocol("WM_DELETE_WINDOW", self.hehe)

		check = Frame(self.matchWin)
		Label(check,text="Properties for %s" % (name)).pack(side=TOP)

		pList = MultiListbox2(check,(("Name", 10), ("Type Parameter", 20), ("Value Parameter", 20), ("Value", 22)))

		query = ("SELECT name_id "
				"FROM NAME "
				"WHERE name = '%s'") % (name)

		try:
			self.dbcursor.execute(query)
		except:
			self.addToLog("Error with query")
			return
		
		results = self.dbcursor.fetchone()

		name_id = results[0]

		query = ("SELECT * "
				"FROM PROPERTY "
				"WHERE name_id = '%s'") % (name_id)

		
		self.dbcursor.execute(query)
		results = self.dbcursor.fetchall()


		for prop in results:
			propname = prop[1]
			if(prop[3] == None):
				partype = ""
			else:
				partype = prop[3]

			if(prop[4] == None):
				parval = ""
			else:
				parval = prop[4]

			if(prop[5] == None):
				value = ""
			else:
				value = prop[5]

			pList.insert(END,(propname, partype, parval, value))

		pList.pack(side=TOP)
		check.pack(side=TOP)

		check2 = Frame(self.matchWin)
		Button(check2, text="Don't Add", command = self.noAdd).pack(side=LEFT)
		Button(check2, text="Replace", command = self.replace).pack(side=LEFT)
		Button(check2, text="Cancel", command = self.endAdd).pack(side=LEFT)
		Button(check2, text="Merge", command = self.merge).pack(side=LEFT)
		check2.pack(side=TOP)
				

		self.matchWin.focus_set()
		self.matchWin.transient(root)
		self.matchWin.grab_set()
		self.matchWin.wait_window(self.matchWin)

	def QueryWindow(self):
		self.queryWin = Toplevel()
		self.queryWin.title("Query")
		self.datamenu.entryconfig(4, state = DISABLED)

		self.queryWin.protocol("WM_DELETE_WINDOW", self.QueryExit)

		self.var = IntVar()
		self.strvar = StringVar()

		left = Frame(self.queryWin)
		left2 = Frame(left)
		Radiobutton(left2, text = "Display the properties of all cards with the name ___(wild card '%' permitted)?", variable = self.var, value = 1).grid(row=0)
		self.entryOne = Entry(left2,width =50)
		self.entryOne.grid(row=1)
		
		Radiobutton(left2, text = "How many cards are in ___ (country)?", variable = self.var, value = 2).grid(row=2)
		self.entryTwo = Entry(left2,width =50)
		self.entryTwo.grid(row=3)
		
		Radiobutton(left2, text = "Show me the website of ____(full name)", variable = self.var, value = 3).grid(row=5)
		self.entryThree = Entry(left2,width =50)
		self.entryThree.grid(row=6)

		Radiobutton(left2, text = "Get me everyone's ____ number.(WORK,HOME)", variable = self.var, value = 4).grid(row=7)
		self.entryFour = Entry(left2,width =50)
		self.entryFour.grid(row=8)

		Radiobutton(left2, text = "Custom", variable = self.var, value = 5).grid(row=9)
		self.entryFive = Entry(left2,width =50)
		self.entryFive.insert(0,"SELECT")
		self.entryFive.grid(row=10)
		

		left2.pack(side=TOP)
		left3 = Frame(left)
		Button(left3, text="Submit", command=self.QueryCheck).grid(row=0,column=0)
		Button(left3, text="Help", command=self.queryHelp).grid(row=0, column=1)
		left3.pack(side=BOTTOM)


		left.pack(side=TOP)

		right = Frame(self.queryWin)
		self.queryBox = tix.ScrolledText(right,width = 700, height = 300, scrollbar="auto")
		self.queryBox.text.config(bg = "black", fg = "white", state=DISABLED, wrap = "none")
		self.queryBox.pack(side=TOP, expand = 1, fill = BOTH)

		Button(right, text="Clear", command=self.clearQueryBox).pack(side=BOTTOM)
		
		right.pack(side=TOP)

	def QueryCheck(self):
		item = int(self.var.get())

		#Name query
		if item == 1:
			self.nameQuery(str(self.entryOne.get()))

		if item == 2:
			self.countryQuery(str(self.entryTwo.get()))

		if item == 3:
			self.webQuery(str(self.entryThree.get()))

		if item == 4:
			self.phoneQuery(str(self.entryFour.get()))

		if item == 5:
			self.customQuery(str(self.entryFive.get()))

	def nameQuery(self, entry):


		query = ("SELECT * FROM NAME, PROPERTY WHERE PROPERTY.name_id = NAME.name_id AND PROPERTY.name_id  "
			"IN (SELECT PROPERTY.name_id FROM PROPERTY WHERE pname='FULLNAME' AND value LIKE '%s')"
			"ORDER BY NAME.name,PROPERTY.pname") % (entry)


		try:
			self.dbcursor.execute(query)

		except:
			self.addToQueryBox("Error with your query")

		
		results = self.dbcursor.fetchall()
		string = "=" * 90 + "\n"
		string = string + "Name:".ljust(20) + "Pname:".ljust(10) + "Partype:".ljust(15)+ "Parval:".ljust(15) + "Value:".ljust(30) + "\n"
		string = string + "=" * 90 + "\n"

		for result in results:
			string = string + str(result[1]).ljust(20)+str(result[3]).ljust(10)+str(result[5]).ljust(15)+str(result[6]).ljust(15)+str(result[7]).ljust(30) + "\n"

		string = string + "-" * 90 + "\n"
		self.addToQueryBox(string)

	def countryQuery(self, entry):

		query = ("select count(distinct name_id) from PROPERTY where value like '%;%;%;%;%;%;" + entry + "'")

		try:
			self.dbcursor.execute(query)

		except:
			self.addToQueryBox("Error with your query")
	
		
		results = self.dbcursor.fetchone()
		string = "There are " + str(results[0]) + " cards with addresses in " + entry + "\n" + "-" * 90 + "\n"
		self.addToQueryBox(string)

	def webQuery(self, entry):

		query = ("select NAME.name,PROPERTY.value from NAME, PROPERTY where pname = 'URL' and NAME.name_id = PROPERTY.name_id and PROPERTY.name_id "
			    "= (SELECT PROPERTY.name_id FROM PROPERTY WHERE pname='FULLNAME' AND value = '%s')") % entry

		try:
			self.dbcursor.execute(query)

		except:
			self.addToQueryBox("Error with your query")
	
		
		results = self.dbcursor.fetchall()
		string = "=" * 90 + "\n"
		string = string + "Name:".ljust(20) + "Website:".ljust(20) + "\n"
		string = string + "=" * 90 + "\n"

		for result in results:
			string = string + str(result[0]).ljust(20)+str(result[1]).ljust(20) + "\n"

		string = string + "-" * 90 + "\n"
		self.addToQueryBox(string)

	def phoneQuery(self, entry):
		query = ("select NAME.name, PROPERTY.partype, PROPERTY.value  from NAME,PROPERTY "
		"where NAME.name_id = PROPERTY.name_id and PROPERTY.pname = 'TEL' and partype like '%" + entry +"%'")
		try:
			self.dbcursor.execute(query)

		except:
			self.addToQueryBox("Error with your query")
	
		
		results = self.dbcursor.fetchall()
		string = "=" * 90 + "\n"
		string = string + "Name:".ljust(20) + "Type:".ljust(20) + "Phone Number:".ljust(15)  + "\n"
		string = string + "=" * 90 + "\n"
		print(string)
		for result in results:
			string = string + str(result[0]).ljust(20)+str(result[1]).ljust(20) + str(result[2]).ljust(15) + "\n"

		string = string + "-" * 90 + "\n"
		self.addToQueryBox(string)



	def customQuery(self, entry):
		try:
			self.dbcursor.execute(entry)
		except:
			self.addToQueryBox("There was a problem executing your query")
			return

		results = self.dbcursor.fetchall()

		string = ""
		for result in results:
			for tup in result:
				string += str(tup).ljust(15)
			string = string + "\n"

		self.addToQueryBox(string)
		self.addToQueryBox("-" * 90)

	def QueryExit(self):
		self.datamenu.entryconfig(4, state = NORMAL)
		self.queryWin.destroy()
		return

	def addToQueryBox(self, log):
		self.queryBox.text.config(state=NORMAL)
		self.queryBox.text.insert(END,log + "\n")
		self.queryBox.text.config(state=DISABLED)
		self.queryBox.text.see(END)


	def clearQueryBox(self):
		self.queryBox.text.config(state=NORMAL)
		self.queryBox.text.delete("1.0", END)
		self.queryBox.text.config(state=DISABLED)
		self.queryBox.text.see(END)

	def queryHelp(self):
	
		self.qHelpWin = Toplevel()
		self.qHelpWin.title("Query Help")
		self.qHelpWin.bind("<Escape>", lambda e: self.destroyWin(e.widget))

		Label(self.qHelpWin,text="Table: NAME").pack(side=TOP)
		Label(self.qHelpWin,text="name_id: Primary Key, number assoicated with particular card").pack(side=TOP)
		Label(self.qHelpWin,text="name: N property of the card").pack(side=TOP)

		Label(self.qHelpWin,text="Table: PROPERTY").pack(side=TOP)
		Label(self.qHelpWin,text="name_id: foreign key, number associated with particular card").pack(side=TOP)
		Label(self.qHelpWin,text="pname: Name of the property(ADR,TEL,etc.)").pack(side=TOP)
		Label(self.qHelpWin,text="pinst: Instance of that property").pack(side=TOP)
		Label(self.qHelpWin,text="partype: Type parameter of the property").pack(side=TOP)
		Label(self.qHelpWin,text="parval: val parameter of the property").pack(side=TOP)
		Label(self.qHelpWin,text="value: The value the property holds(if property is TEL then this is a phone number)").pack(side=TOP)

		Button(self.qHelpWin,text="Ok",command = self.qHelpWin.destroy).pack(side=TOP)
		self.qHelpWin.focus_set()
		self.qHelpWin.transient(root)

		while True:
			try:
				self.qHelpWin.grab_set()
			except TclError:
				pass
			else:
				break
			
		self.qHelpWin.wait_window(self.qHelpWin)


	def noAdd(self):
		self.check = "Don't add"
		self.matchWin.destroy()
		
	def endAdd(self):
		self.check = "Cancel"
		self.matchWin.destroy()

	def replace(self):
		self.check = "Replace"
		self.matchWin.destroy()

	def merge(self):
		self.check = "Merge"
		self.matchWin.destroy()


	#Functions for multilistbox binds

	def _select(self, e):
		sel = self.fileList.curselection()
		if(self.changesMade == True):
			self.fileList.selection_set(sel)
			self.makeChange = ""
			
			self.changeWin = Toplevel()
			self.changeWin.title("Commit changes?")
			self.changeWin.bind("<Escape>", lambda e: self.destroyWin(e.widget))
			Label(self.changeWin,text="Commit the changes you've made?").pack(side=TOP)
			Button(self.changeWin,text="OK",command = self.changeOK).pack(side=TOP)
			Button(self.changeWin,text="Cancel",command = self.changeWin.destroy).pack(side=TOP)
			self.changeWin.focus_set()
			self.changeWin.transient(root)

			while True:
				try:
					self.changeWin.grab_set()
				except TclError:
					pass
				else:
					break
			
			self.changeWin.wait_window(self.changeWin)

			if self.makeChange == "Yes":
				self.commit()
				return 'break'

			else:
				self.fileList.selection_set(sel)
				return 'break'


		else:
			self.fileList._select(e)
			self.loadCVP(e)
			return 'break'

		return 'break'

	def ctrlselect(self, e):
		self.fileList.ctrlselect(e)
		self.loadCVP(e)

	def shiftselect(self, e):
		self.fileList.shiftselect(e)
		self.loadCVP(e)

	def _2select(self, e):
		self.propList._select(e)
		
		self.editprop = Toplevel()
		topframe = Frame(self.editprop)
		self.editprop.title("Edit Property")
		self.editprop.bind("<Escape>", lambda e: self.destroyWin(e.widget))
		

		Label(topframe,text="Type Parameter: ").grid(row = 1, column = 0)
		self.editpartypeBox = Entry(topframe, width = 30)
		self.editpartypeBox.grid(row = 1, column = 1)

		Label(topframe,text="Val Parameter: ").grid(row = 2, column = 0)
		self.editparvalBox = Entry(topframe, width = 30)
		self.editparvalBox.grid(row = 2, column = 1)

		Label(topframe,text="Property Value: ").grid(row = 3, column = 0)
		self.editvalueBox = Entry(topframe, width = 30)
		self.editvalueBox.grid(row = 3, column = 1)
		topframe.pack(side=TOP)

		botframe = Frame(self.editprop)

		Button(botframe,text = "OK", command = self.editCheck).grid(row = 0, column = 0)
		Button(botframe,text = "Cancel", command = self.editprop.destroy).grid(row = 0, column = 1)
		botframe.pack(side=TOP)
		self.editTheProp = ""
	
		self.editprop.focus_set()
		self.editprop.transient(root)
		while True:
			try:
				self.editprop.grab_set()
			except TclError:
				pass
			else:
				break
		
		self.editprop.wait_window(self.editprop)
		
		return 'break'


	def editCheck(self):
		self.editTheProp = "Yes"
		
		cardsel = self.fileList.curselection()
		cardindex = int(cardsel[0])
		sel = self.propList.curselection()
		index = int(sel[0])

		partype = self.editpartypeBox.get()
		parval = self.editparvalBox.get()
		value = self.editvalueBox.get()

		prop = self.cardList[cardindex][index]

		newProp = (prop[0],)


		if partype == '':
			newProp = newProp +(prop[1],)
		else:
			newProp = newProp + (partype,)
		
		if parval == '':
			newProp = newProp + (prop[2],)
		else:
			newProp = newProp + (parval,)
		
		if value == '':
			newProp = newProp + (prop[3],)
		else:
			newProp = newProp + (value,)


		self.cardList[cardindex].pop(index)
		self.cardList[cardindex].insert(index,newProp)
		self.loadCVP("event")
		self.propList.selection_set(sel)
		self.changesMade = True
		self.editprop.destroy()

	def changeOK(self):
		self.makeChange = "Yes"
		self.changeWin.destroy()

	#Initialize GUI
	def __init__(self,root):

		self.edited = False
		self.changesMade = False

		self.gmap = GMapData(h = "Mapped cards")

		startWebServer(8080)
		
		hostname = 'dursley.socs.uoguelph.ca'
		if len(sys.argv) != 3 and len(sys.argv) != 4:
			print("Two or three arguments.")
			exit()


		if len(sys.argv) == 4:
			hostname = sys.argv[3]

		try:
			self.db = mysql.connector.connect(user=sys.argv[1],password = sys.argv[2], host = hostname,
				database = sys.argv[1])

		except mysql.connector.Error as err:
			print("Error")
			exit()


		#Try to create the tables

		self.dbcursor = self.db.cursor()

		TABLES = {}

		#Try to create tables

		TABLES['name'] = (
		    "CREATE TABLE `NAME` ("
		    "  `name_id` int AUTO_INCREMENT,"
		    "  `name` varchar(60),"
		    "  PRIMARY KEY (`name_id`)"
		    ")")

		TABLES['property'] = (
		    "CREATE TABLE `PROPERTY` ("
		    "  `name_id` int NOT NULL,"
		    "  `pname` char(8) NOT NULL,"
		    "  `pinst` smallint NOT NULL,"
		    "  `partype` tinytext,"
		    "  `parval` tinytext,"
		    "  `value` text,"
		    "  PRIMARY KEY (`name_id`, `pname`,`pinst`),"
		    "  FOREIGN KEY(`name_id`) REFERENCES NAME(`name_id`) ON DELETE CASCADE"
		    ")")
		
		for name,ddl in TABLES.items():
			try:
				self.dbcursor.execute(ddl)
			except:
				continue;
		
		#stores the cards
		self.cardList = []

		#stores the current filename
		self.currentFile = ""

		#menu
		self.menubar = Menu(root)

		#file
		self.filemenu = Menu(self.menubar,tearoff=0)
		self.filemenu.add_command(label="Open",command=self.open)
		self.filemenu.add_command(label="Append", command = self.append, state = DISABLED)
		self.filemenu.add_command(label="Save", command = self.saveDisplay, state = DISABLED)
		self.filemenu.add_command(label="Save As", command = self.saveAs, state = DISABLED)
		self.filemenu.add_separator()
		self.filemenu.add_command(label="Exit",command=lambda:mainWindow.exit(self))
		self.menubar.add_cascade(label="File", menu=self.filemenu)

		#Organize
		self.orgmenu = Menu(self.menubar,tearoff=0)
		self.orgmenu.add_command(label="Sort", state = DISABLED)
		self.orgmenu.add_command(label="Canonicalize", state = DISABLED)
		self.orgmenu.add_command(label="Select", state = DISABLED)
		self.orgmenu.add_separator()
		self.orgmenu.add_command(label="Undo", state = DISABLED, command = self.undo)
		self.menubar.add_cascade(label="Organize", menu=self.orgmenu)

		#database
		self.datamenu = Menu(self.menubar,tearoff=0)
		self.datamenu.add_command(label="Store All", state = DISABLED, command = self.storeAll)
		self.datamenu.add_command(label="Store Selected", state = DISABLED, command = self.storeSelected)
		self.datamenu.add_command(label="Open from Database", command = self.openFromDB)
		self.datamenu.add_command(label="Append from Database", state = DISABLED,command = self.appendFromDB)
		self.datamenu.add_command(label="Query", command = self.QueryWindow)
		self.menubar.add_cascade(label="Database", menu=self.datamenu)

		#Help
		self.helpmenu = Menu(self.menubar,tearoff=0)
		self.helpmenu.add_command(label="Cards,flags and colours",command=lambda:mainWindow.cards(self))
		self.helpmenu.add_command(label="About",command=self.about)
		self.menubar.add_cascade(label="Help", menu=self.helpmenu)

		#Configure menu
		root.config(menu=self.menubar)


		"""
		FRAMES
		"""


		#Top frame
		top = Frame(root)
		top.pack(side=TOP)
		self.fileList = MultiListbox(top, (('#', 6), ('Card Name', 15), ('Region', 10), 
			('Country', 20), ('#ADR', 5), ('#TEL', 5), ('Flags', 10)))
		
		for lb in self.fileList.lists:
			lb.bind('<Button-1>', lambda e: self._select(e.y))
			lb.bind('<Control-Button-1>', lambda e,s=self: s.ctrlselect(e.y))
			lb.bind('<Shift-Button-1>', lambda e,s=self: s.shiftselect(e.y))

		self.fileList.pack(side=LEFT)
		

		topRight = Frame(top)
		topRight.pack(side=RIGHT)


		#middle frame
		mid = Frame(root)
		mid.pack(side=TOP)

		self.propList = MultiListbox2(mid,(("Name", 10), ("Type Parameter", 20), ("Value Parameter", 20), ("Value", 22)))
		self.propList.pack(side=LEFT)

		for lb in self.propList.lists:
			lb.bind('<Button-1>', lambda e: self._2select(e.y))

		

		midRight = Frame(mid)
		midRight.pack(side=RIGHT)

		
		#bottom frame

		bot = Frame(root)
		bot.pack(side=TOP)
		self.box = tix.ScrolledText(bot,width = 700, height = 180, scrollbar="y")
		self.box.text.config(bg = "black", fg = "white", state=DISABLED)
		self.box.pack(side=LEFT)
		Button(root, text = "Clear", command = self.clear).pack(side=BOTTOM)

		#Top frame buttons
		#Buttons
		self.mSelectButton = Button(topRight,width = 10,text = "Map Selected",command =lambda:mainWindow.mapSelect(self))
		self.mSelectButton.pack(side=TOP)
		self.resetMapButton = Button(topRight,width = 10,text = "Reset Map",command =lambda:mainWindow.mapReset(self))
		self.resetMapButton.pack(side=TOP)
		self.bSelectButton = Button(topRight,width = 10,text = "Browse Selected",command =lambda:mainWindow.browseSelected(self))
		self.bSelectButton.pack(side=TOP)
		self.dSelectButton = Button(topRight,width = 10,text = "Delete Selected",command =lambda:mainWindow.delSelected(self))
		self.dSelectButton.pack(side=TOP)
		self.addCardButton = Button(topRight,width = 10,text = "Add Card",command =lambda:mainWindow.addCard(self))
		self.addCardButton.pack(side=TOP)

		#mid frame buttons
		#Buttons
		self.upButton = Button(midRight,width = 10,text = "Up", command=lambda:mainWindow.up(self))
		self.upButton.pack(side=TOP)
		self.downButton = Button(midRight,width = 10,text = "Down",command=lambda:mainWindow.down(self))
		self.downButton.pack(side=TOP)
		self.addPButton = Button(midRight,width = 10,text = "Add Property",command=lambda:mainWindow.addProp(self))
		self.addPButton.pack(side=TOP)
		self.delPButton = Button(midRight,width = 10,text = "Delete Property",command=lambda:mainWindow.delProp(self))
		self.delPButton.pack(side=TOP)
		self.commitButton = Button(midRight,width = 10,text = "Commit",command=lambda:mainWindow.commit(self))
		self.commitButton.pack(side=TOP)
		self.revertButton = Button(midRight,width = 10,text = "Revert",command=lambda:mainWindow.revert(self))
		self.revertButton.pack(side=TOP)


	def destroyWin(self, y):
		y.destroy()


	def close(self):
		self.db.close()
		killServers()
		os.remove("temp.vcf")
		sys.exit()
Exemple #14
0
	def __init__(self,root):

		self.edited = False
		self.changesMade = False

		self.gmap = GMapData(h = "Mapped cards")

		startWebServer(8080)
		
		hostname = 'dursley.socs.uoguelph.ca'
		if len(sys.argv) != 3 and len(sys.argv) != 4:
			print("Two or three arguments.")
			exit()


		if len(sys.argv) == 4:
			hostname = sys.argv[3]

		try:
			self.db = mysql.connector.connect(user=sys.argv[1],password = sys.argv[2], host = hostname,
				database = sys.argv[1])

		except mysql.connector.Error as err:
			print("Error")
			exit()


		#Try to create the tables

		self.dbcursor = self.db.cursor()

		TABLES = {}

		#Try to create tables

		TABLES['name'] = (
		    "CREATE TABLE `NAME` ("
		    "  `name_id` int AUTO_INCREMENT,"
		    "  `name` varchar(60),"
		    "  PRIMARY KEY (`name_id`)"
		    ")")

		TABLES['property'] = (
		    "CREATE TABLE `PROPERTY` ("
		    "  `name_id` int NOT NULL,"
		    "  `pname` char(8) NOT NULL,"
		    "  `pinst` smallint NOT NULL,"
		    "  `partype` tinytext,"
		    "  `parval` tinytext,"
		    "  `value` text,"
		    "  PRIMARY KEY (`name_id`, `pname`,`pinst`),"
		    "  FOREIGN KEY(`name_id`) REFERENCES NAME(`name_id`) ON DELETE CASCADE"
		    ")")
		
		for name,ddl in TABLES.items():
			try:
				self.dbcursor.execute(ddl)
			except:
				continue;
		
		#stores the cards
		self.cardList = []

		#stores the current filename
		self.currentFile = ""

		#menu
		self.menubar = Menu(root)

		#file
		self.filemenu = Menu(self.menubar,tearoff=0)
		self.filemenu.add_command(label="Open",command=self.open)
		self.filemenu.add_command(label="Append", command = self.append, state = DISABLED)
		self.filemenu.add_command(label="Save", command = self.saveDisplay, state = DISABLED)
		self.filemenu.add_command(label="Save As", command = self.saveAs, state = DISABLED)
		self.filemenu.add_separator()
		self.filemenu.add_command(label="Exit",command=lambda:mainWindow.exit(self))
		self.menubar.add_cascade(label="File", menu=self.filemenu)

		#Organize
		self.orgmenu = Menu(self.menubar,tearoff=0)
		self.orgmenu.add_command(label="Sort", state = DISABLED)
		self.orgmenu.add_command(label="Canonicalize", state = DISABLED)
		self.orgmenu.add_command(label="Select", state = DISABLED)
		self.orgmenu.add_separator()
		self.orgmenu.add_command(label="Undo", state = DISABLED, command = self.undo)
		self.menubar.add_cascade(label="Organize", menu=self.orgmenu)

		#database
		self.datamenu = Menu(self.menubar,tearoff=0)
		self.datamenu.add_command(label="Store All", state = DISABLED, command = self.storeAll)
		self.datamenu.add_command(label="Store Selected", state = DISABLED, command = self.storeSelected)
		self.datamenu.add_command(label="Open from Database", command = self.openFromDB)
		self.datamenu.add_command(label="Append from Database", state = DISABLED,command = self.appendFromDB)
		self.datamenu.add_command(label="Query", command = self.QueryWindow)
		self.menubar.add_cascade(label="Database", menu=self.datamenu)

		#Help
		self.helpmenu = Menu(self.menubar,tearoff=0)
		self.helpmenu.add_command(label="Cards,flags and colours",command=lambda:mainWindow.cards(self))
		self.helpmenu.add_command(label="About",command=self.about)
		self.menubar.add_cascade(label="Help", menu=self.helpmenu)

		#Configure menu
		root.config(menu=self.menubar)


		"""
		FRAMES
		"""


		#Top frame
		top = Frame(root)
		top.pack(side=TOP)
		self.fileList = MultiListbox(top, (('#', 6), ('Card Name', 15), ('Region', 10), 
			('Country', 20), ('#ADR', 5), ('#TEL', 5), ('Flags', 10)))
		
		for lb in self.fileList.lists:
			lb.bind('<Button-1>', lambda e: self._select(e.y))
			lb.bind('<Control-Button-1>', lambda e,s=self: s.ctrlselect(e.y))
			lb.bind('<Shift-Button-1>', lambda e,s=self: s.shiftselect(e.y))

		self.fileList.pack(side=LEFT)
		

		topRight = Frame(top)
		topRight.pack(side=RIGHT)


		#middle frame
		mid = Frame(root)
		mid.pack(side=TOP)

		self.propList = MultiListbox2(mid,(("Name", 10), ("Type Parameter", 20), ("Value Parameter", 20), ("Value", 22)))
		self.propList.pack(side=LEFT)

		for lb in self.propList.lists:
			lb.bind('<Button-1>', lambda e: self._2select(e.y))

		

		midRight = Frame(mid)
		midRight.pack(side=RIGHT)

		
		#bottom frame

		bot = Frame(root)
		bot.pack(side=TOP)
		self.box = tix.ScrolledText(bot,width = 700, height = 180, scrollbar="y")
		self.box.text.config(bg = "black", fg = "white", state=DISABLED)
		self.box.pack(side=LEFT)
		Button(root, text = "Clear", command = self.clear).pack(side=BOTTOM)

		#Top frame buttons
		#Buttons
		self.mSelectButton = Button(topRight,width = 10,text = "Map Selected",command =lambda:mainWindow.mapSelect(self))
		self.mSelectButton.pack(side=TOP)
		self.resetMapButton = Button(topRight,width = 10,text = "Reset Map",command =lambda:mainWindow.mapReset(self))
		self.resetMapButton.pack(side=TOP)
		self.bSelectButton = Button(topRight,width = 10,text = "Browse Selected",command =lambda:mainWindow.browseSelected(self))
		self.bSelectButton.pack(side=TOP)
		self.dSelectButton = Button(topRight,width = 10,text = "Delete Selected",command =lambda:mainWindow.delSelected(self))
		self.dSelectButton.pack(side=TOP)
		self.addCardButton = Button(topRight,width = 10,text = "Add Card",command =lambda:mainWindow.addCard(self))
		self.addCardButton.pack(side=TOP)

		#mid frame buttons
		#Buttons
		self.upButton = Button(midRight,width = 10,text = "Up", command=lambda:mainWindow.up(self))
		self.upButton.pack(side=TOP)
		self.downButton = Button(midRight,width = 10,text = "Down",command=lambda:mainWindow.down(self))
		self.downButton.pack(side=TOP)
		self.addPButton = Button(midRight,width = 10,text = "Add Property",command=lambda:mainWindow.addProp(self))
		self.addPButton.pack(side=TOP)
		self.delPButton = Button(midRight,width = 10,text = "Delete Property",command=lambda:mainWindow.delProp(self))
		self.delPButton.pack(side=TOP)
		self.commitButton = Button(midRight,width = 10,text = "Commit",command=lambda:mainWindow.commit(self))
		self.commitButton.pack(side=TOP)
		self.revertButton = Button(midRight,width = 10,text = "Revert",command=lambda:mainWindow.revert(self))
		self.revertButton.pack(side=TOP)