Beispiel #1
0
	def setupGUI(self):
		self.root = tk.Tk()
		self.root.title("FTP Host")
		self.root.config(padx=10,pady=10)

		#connection frame
		connection_group = tk.LabelFrame(self.root,
										text="Connection",
										padx=5,
										pady=5)
		connection_group.grid(row=0,column=0)
		server_label = tk.Label(connection_group,text="Sever Hostname:")
		server_label.grid(row=0,column=0)
		self.server_entry = tk.Entry(connection_group)
		self.server_entry.grid(row=0,column=1)
		port_label = tk.Label(connection_group,text="Port:")
		port_label.grid(row=0,column=2)
		self.port_entry = tk.Entry(connection_group)
		self.port_entry.grid(row=0,column=3)
		connect_button = tk.Button(connection_group,text="Connect",width=15,command=self.connectToServer)
		connect_button.grid(row=0,column=4,columnspan=2,padx=10)
		username_label = tk.Label(connection_group,text="Username:"******"Hostname:")
		hostname_label.grid(row=1,column=2)
		self.hostname_text = tk.StringVar()
		self.hostname_entry = tk.Entry(connection_group,textvariable=self.hostname_text)
		self.hostname_text.set(self.host_server.getHostInfo())
		self.hostname_entry.grid(row=1,column=3)
		speed_label = tk.Label(connection_group,text="Speed:")
		speed_label.grid(row=1,column=4,padx=10)
		self.speed_val = tk.StringVar(self.root)
		self.speed_val.set("Ethernet")
		self.speed_menu = tk.OptionMenu(connection_group,
									self.speed_val,
									"Ethernet",
									"T1",
									"28.8k",
									"56k",
									"Cup and String",
									"DSL")
		self.speed_menu.grid(row=1,column=5)


		#Search Frame
		search_group = tk.LabelFrame(self.root,text="Search",padx=5,pady=5)
		search_group.grid(row=1,column=0,sticky="W")
		keyword_label = tk.Label(search_group,text="Keyword:")
		keyword_label.grid(row=0,column=0,sticky="W")
		self.keyword_entry = tk.Entry(search_group,width=29)
		self.keyword_entry.grid(row=0,column=1,sticky="W")
		search_button = tk.Button(search_group,text="Search",command=self.searchForFile)
		search_button.grid(row=0,column=2)
		retrieve_button = tk.Button(search_group,text="Retrieve",command=self.retrieveButton)
		retrieve_button.grid(row=0,column=3)
		self.search_listbox = tk.Listbox(search_group,width=70,height=8,selectmode='multiple')
		self.search_listbox.grid(row=1,column=0,columnspan=4,sticky="NS")
		#Vertical scrollbar
		search_scroll_v = tk.Scrollbar(search_group,orient=tk.VERTICAL)
		search_scroll_v.grid(row=1,column=0,columnspan=4,sticky="NSE")
		search_scroll_v.config(command=self.search_listbox.yview)
		self.search_listbox.config(yscrollcommand=search_scroll_v.set,font=("courier new",10,"normal"))
		#horizontal scrollbar
		search_scroll_h = tk.Scrollbar(search_group,orient=tk.HORIZONTAL)
		search_scroll_h.grid(row=1,column=0,columnspan=4,sticky="ESW")
		search_scroll_h.config(command=self.search_listbox.xview)
		self.search_listbox.config(xscrollcommand=search_scroll_h)

		#ftp group
		ftp_group = tk.LabelFrame(self.root,text="FTP",padx=5,pady=5)
		ftp_group.grid(row=2,column=0,sticky="W")
		command_label = tk.Label(ftp_group,text="Enter Command:")
		command_label.grid(row=0,column=0)
		self.command_entry = tk.Entry(ftp_group,width=40)
		self.command_entry.grid(row=0,column=1)
		go_button = tk.Button(ftp_group,text="Go",width=10,command=self.ftpButton)
		go_button.grid(row=0,column=2,padx=10)


		self.log_listbox = tk.Listbox(ftp_group,width=80)
		self.log_listbox.grid(row=1,column=0,columnspan=3,sticky="NS")
		log_scroll = tk.Scrollbar(ftp_group,orient=tk.VERTICAL)
		log_scroll.grid(row=1,column=0,columnspan=3,sticky="NSE")
		log_scroll.config(command=self.log_listbox.yview)
		self.log_listbox.config(yscrollcommand=log_scroll.set)



		self.root.protocol("WM_DELETE_WINDOW",self.close)
		self.root.mainloop()
    def __init__(self):
        Screen.__init__(self)

        self.options = ["one", "two"]
        self.tkvar = tk.StringVar(self)
        self.tkvar.set(self.options[0])

        self.lbl_title = tk.Label(self, text="Search", font=("Arial", "25"))
        self.lbl_title.grid(row=0, column=0, sticky="news")

        self.search_by = tk.Label(self,
                                  text="Search By:",
                                  font=("arial", "18"))
        self.search_by.grid(row=1, column=0, sticky="news")

        self.search_by2 = tk.OptionMenu(self, self.tkvar, *self.options)
        self.search_by2.grid(row=1, column=1, sticky='news')

        self.search_for = tk.Label(self,
                                   text="Search For:",
                                   font=("arial", "18"))
        self.search_for.grid(row=2, column=0, sticky="news")

        self.ent_search = tk.Entry(self)
        self.ent_search.grid(row=2, column=1)
        background = self.ent_search.cget("bg")

        self.filters = tk.Label(self,
                                text="Print Filters:",
                                font=("arial", "18"))
        self.filters.grid(row=1, column=2, sticky="news")

        self.chk1 = tk.Checkbutton(self, text='Title')
        self.chk1.grid(row=1, column=4)
        self.chk2 = tk.Checkbutton(self, text='Genre')
        self.chk2.grid(row=2, column=4)
        self.chk3 = tk.Checkbutton(self, text='Developer')
        self.chk3.grid(row=3, column=4)
        self.chk4 = tk.Checkbutton(self, text='Publisher')
        self.chk4.grid(row=4, column=4)
        self.chk5 = tk.Checkbutton(self, text='System')
        self.chk5.grid(row=1, column=5)
        self.chk6 = tk.Checkbutton(self, text='Release')
        self.chk6.grid(row=2, column=5)
        self.chk7 = tk.Checkbutton(self, text='Rating')
        self.chk7.grid(row=3, column=5)
        self.chk8 = tk.Checkbutton(self, text='Co-op')
        self.chk8.grid(row=4, column=5)
        self.chk9 = tk.Checkbutton(self, text='Price')
        self.chk9.grid(row=1, column=6)
        self.chk10 = tk.Checkbutton(self, text='Beaten')
        self.chk10.grid(row=2, column=6)
        self.chk11 = tk.Checkbutton(self, text='Purchase')
        self.chk11.grid(row=3, column=6)

        self.edit_space = ScrolledText(
            self,
            wrap='word',  # wrap text at full words only
            width=40,  # characters
            height=10,  # text lines
            bg='blue'  # background color of edit area
        )

        self.edit_space.grid(row=5, column=0)
        mytext = '''\
                Did you ever hear the tragedy of Darth Plagueis "the wise"? I thought not. It's not a story the Jedi would tell you. It's a Sith legend.
                Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life...
                He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway
                to many abilities some consider to be unnatural. He became so powerful... the only thing he was afraid of was losing his power, which eventually,
                of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep.
                Ironic he could save others from death, but not himself.
                '''
        self.edit_space.insert('insert', mytext)

        self.btn_cancel = tk.Button(self,
                                    text="Cancel",
                                    font=("Arial", "15"),
                                    command=self.go_home)
        self.btn_cancel.grid(row=6, column=0)

        self.btn_clear = tk.Button(self, text="Clear", font=("Arial", "15"))
        self.btn_clear.grid(row=6, column=1)

        self.btn_submit = tk.Button(self, text="Submit", font=("Arial", "15"))
        self.btn_submit.grid(row=6, column=3)

        self.grid_columnconfigure(0, weight=1)
        self.grid_columnconfigure(1, weight=1)
        self.grid_columnconfigure(2, weight=1)
        self.grid_columnconfigure(3, weight=1)
Beispiel #3
0
    def __init__(self,
                 parent,
                 length,
                 width,
                 directory='/',
                 lev="1",
                 rm_tp=8,
                 title="*Untitled File"):
        self.parent = parent
        self.parent.title(title)
        w = str(max(120 + 32 * width, 600))
        h = str(210 + 32 * length)
        self.parent.geometry(w + "x" + h)
        self.frame = tk.Frame(self.parent)
        self.length = length
        self.width = width

        spawns = get_image_file('./images/spawn')

        tiles = get_image_file('./images/tiles')
        self.tile = tk.StringVar(self.parent)
        self.tile.set(tiles[0])
        self.tile_text = tk.Label(self.parent, text="Tile:").place(x=10, y=10)
        self.tile_dropdown = tk.OptionMenu(self.parent, self.tile, "No Change",
                                           *tiles).place(x=40, y=10)

        obstacles = get_image_file('./images/obstacles')
        obstacles_cleaned = [(int(ob.split('-')[0]), ob.split('_')[0])
                             for ob in obstacles]
        obstacles_cleaned = sorted(obstacles_cleaned, key=lambda x: x[0])
        obstacles_cleaned = [ob[1] for ob in obstacles_cleaned]
        self.obstacle = tk.StringVar(self.parent)
        self.obstacle.set("No Change")
        self.ob_text = tk.Label(self.parent, text="Obstacle:").place(x=190,
                                                                     y=10)
        self.obstacle_dropdown = tk.OptionMenu(self.parent, self.obstacle,
                                               "No Change",
                                               *obstacles_cleaned).place(x=250,
                                                                         y=10)

        floor = get_image_file('./images/floor')
        floor_cleaned = [(int(ob.split('-')[0]), ob.split('_')[0])
                         for ob in floor]
        floor_cleaned = sorted(floor_cleaned, key=lambda x: x[0])
        floor_cleaned = [ob[1] for ob in floor_cleaned]
        self.floor = tk.StringVar(self.parent)
        self.floor.set("No Change")
        self.floor_text = tk.Label(self.parent, text="Floor:").place(x=10,
                                                                     y=50)
        self.floor_dropdown = tk.OptionMenu(self.parent, self.floor,
                                            "No Change",
                                            *floor_cleaned).place(x=50, y=50)

        hang = get_image_file('./images/hang')
        hang_cleaned = [(int(ob.split('-')[0]), ob.split('_')[0])
                        for ob in hang]
        hang_cleaned = sorted(hang_cleaned, key=lambda x: x[0])
        hang_cleaned = [ob[1] for ob in hang_cleaned]
        self.hang = tk.StringVar(self.parent)
        self.hang.set("No Change")
        self.hang_text = tk.Label(self.parent, text="Hang:").place(x=200, y=50)
        self.hang_dropdown = tk.OptionMenu(self.parent, self.hang, "No Change",
                                           *hang_cleaned).place(x=250, y=50)

        walldecs = get_image_file('./images/walls/decorations')
        self.walldec = tk.StringVar(self.parent)
        self.walldec.set(walldecs[0])
        self.walldec_text = tk.Label(self.parent, text="Wall:").place(x=400,
                                                                      y=10)
        self.walldec_dropdown = tk.OptionMenu(self.parent, self.walldec,
                                              *walldecs).place(x=430, y=10)

        self.level = tk.StringVar(self.parent)
        self.level.set(lev)
        self.level_text = tk.Label(self.parent, text="Level:").place(x=550,
                                                                     y=10)
        self.level_dropdown = tk.OptionMenu(self.parent, self.level, "1", "2",
                                            "3", "4", "5", "6",
                                            "7").place(x=590, y=10)

        room_type_list = [
            "1-Offering", "2-Supply", "3-Trove", "4-Treasure", "5-Trial",
            "6-MiniBoss", "7-Shop", "8-Combat", "9-Spawn"
        ]
        self.room = tk.StringVar(self.parent)
        self.room.set(room_type_list[rm_tp - 1])
        self.room_text = tk.Label(self.parent, text="Room:").place(x=655, y=10)
        self.level_dropdown = tk.OptionMenu(self.parent, self.room,
                                            *room_type_list).place(x=700, y=10)

        self.directory = directory

        self.new_csv = tk.Button(self.parent,
                                 text='Upload CSV',
                                 command=self.upload_csv).place(x=400, y=50)

        self.save_csv = tk.Button(self.parent,
                                  text='Save CSV',
                                  command=self.saveys).place(x=525, y=50)
        self.error_check = tk.Button(self.parent,
                                     text='Error Check',
                                     command=self.errorCheck).place(x=650,
                                                                    y=50)

        self.grid = Grid(self.length, self.width)
        self.error = False

        self.canvas = tk.Canvas(root,
                                height=100 + 32 * width,
                                width=110 + 32 * length,
                                bg='white')
        self.canvas.place(x=10, y=100)

        self.parent.wall_imgs = [None] * 12
        wall = Image.open("./images/walls/wall.png")
        corner = Image.open("./images/walls/corner.png")
        door = Image.open("./images/walls/door.png")
        self.parent.wall_imgs[0] = wall
        for i in range(4):
            self.parent.wall_imgs[i] = ImageTk.PhotoImage(wall)
            self.parent.wall_imgs[i + 4] = ImageTk.PhotoImage(corner)
            self.parent.wall_imgs[i + 8] = ImageTk.PhotoImage(door)
            wall = wall.transpose(Image.ROTATE_90)
            corner = corner.transpose(Image.ROTATE_90)
            door = door.transpose(Image.ROTATE_90)

        self.parent.hover_imgs = []
        self.parent.hover_imgs.append(
            ImageTk.PhotoImage(Image.open("./images/clear.png")))
        self.parent.hover_imgs.append(
            ImageTk.PhotoImage(Image.open("./images/hover.png")))

        self.parent.walldec_imgs = [{}, {}, {}, {}]
        for w in walldecs:
            img = Image.open("./images/walls/decorations/" + w + ".png")
            for i in range(4):
                num = int(w.split('-')[0])
                self.parent.walldec_imgs[i][num] = ImageTk.PhotoImage(img)
                img = img.transpose(Image.ROTATE_90)

        self.parent.obstacle_imgs = {}
        self.obstacle_dict = {}
        for ob in obstacles:
            num = int(ob.split('-')[0])
            ob_tup = ast.literal_eval(ob.split('_')[1])
            self.obstacle_dict[num] = ob_tup

            img_file = Image.open("./images/obstacles/" + ob + ".png")
            self.parent.obstacle_imgs[num] = ImageTk.PhotoImage(img_file)

        self.parent.floor_imgs = {}
        self.floor_dict = {}
        for f in floor:
            num = int(f.split('-')[0])
            f_tup = ast.literal_eval(f.split('_')[1])
            self.floor_dict[num] = f_tup

            img_file = Image.open("./images/floor/" + f + ".png")
            self.parent.floor_imgs[num] = ImageTk.PhotoImage(img_file)

        self.parent.hang_imgs = {}
        self.hang_dict = {}
        for h in hang:
            num = int(h.split('-')[0])
            h_tup = ast.literal_eval(h.split('_')[1])
            self.hang_dict[num] = h_tup

            img_file = Image.open("./images/hang/" + h + ".png")
            self.parent.hang_imgs[num] = ImageTk.PhotoImage(img_file)

        self.parent.spawn_imgs = {}
        for spawn in spawns:
            img_file = Image.open("./images/spawn/" + spawn + ".png")
            num = int(spawn.split('-')[0])
            self.parent.spawn_imgs[num] = ImageTk.PhotoImage(img_file)

        self.parent.tile_imgs = {}
        self.parent.tile_imgs1 = {}
        self.parent.tile_imgs2 = {}
        for ti in tiles:
            num = int(ti.split('-')[0]) - 1
            img_file = Image.open("./images/tiles/" + ti + ".png")
            img_file = img_file.convert('RGB')
            self.parent.tile_imgs[num] = ImageTk.PhotoImage(img_file)
            yellow = tint_image(img_file, 'yellow')
            self.parent.tile_imgs1[num] = ImageTk.PhotoImage(yellow)
            red = tint_image(img_file, 'red')
            self.parent.tile_imgs2[num] = ImageTk.PhotoImage(red)

        self.wall_refs = [[], [], [], [], []]
        self.dec_refs = [[], [], [], []]
        corner = self.canvas.create_image(18,
                                          18,
                                          anchor="nw",
                                          image=self.parent.wall_imgs[4])
        self.wall_refs[4].append(corner)
        corner = self.canvas.create_image(18,
                                          50 + (width) * 32,
                                          anchor="nw",
                                          image=self.parent.wall_imgs[5])
        self.wall_refs[4].append(corner)
        corner = self.canvas.create_image(50 + (length) * 32,
                                          50 + (width) * 32,
                                          anchor="nw",
                                          image=self.parent.wall_imgs[6])
        self.wall_refs[4].append(corner)
        corner = self.canvas.create_image(50 + (length) * 32,
                                          18,
                                          anchor="nw",
                                          image=self.parent.wall_imgs[7])
        self.wall_refs[4].append(corner)
        for i in range(length):
            img_top = self.canvas.create_image(50 + (i) * 32,
                                               18,
                                               anchor="nw",
                                               image=self.parent.wall_imgs[0])
            img_bot = self.canvas.create_image(50 + (i) * 32,
                                               50 + (width) * 32,
                                               anchor="nw",
                                               image=self.parent.wall_imgs[2])
            self.wall_refs[0].append(img_top)
            self.wall_refs[2].append(img_bot)
            #self.canvas.tag_bind(self.wall_refs[0][i], '<ButtonPress-1>', self.second_helper(0,i))
            #self.canvas.tag_bind(self.wall_refs[2][i], '<ButtonPress-1>', self.second_helper(2,i))

            dec_top = self.canvas.create_image(
                50 + 16 + (i) * 32,
                18 + 25,
                anchor="s",
                image=self.parent.walldec_imgs[0][0])
            self.canvas.tag_raise(dec_top)
            self.dec_refs[0].append(dec_top)
            #self.canvas.tag_bind(self.dec_refs[0][i], '<ButtonPress-1>', self.second_helper(0,i))

            dec_bot = self.canvas.create_image(
                50 + 16 + (i) * 32,
                50 + (width) * 32 + 7,
                anchor="n",
                image=self.parent.walldec_imgs[2][0])
            self.canvas.tag_raise(dec_bot)
            self.dec_refs[2].append(dec_bot)
            #self.canvas.tag_bind(self.dec_refs[2][i], '<ButtonPress-1>', self.second_helper(2,i))

        self.tile_refs = []
        for i in range(length):
            self.tile_refs.append([])
            for j in range(width):
                img = self.canvas.create_image(50 + (i) * 32,
                                               50 + (j) * 32,
                                               anchor="nw",
                                               image=self.parent.tile_imgs[0])
                self.tile_refs[i].append(img)

        self.f_refs = []
        for i in range(length):
            self.f_refs.append([])
            for j in range(width):
                img = self.canvas.create_image(50 + 32 + (i) * 32,
                                               50 + (j) * 32,
                                               anchor="ne",
                                               image=self.parent.floor_imgs[0])
                self.canvas.tag_raise(img)
                self.f_refs[i].append(img)

        self.ob_refs = []
        for i in range(length):
            self.ob_refs.append([])
            for j in range(width):
                img = self.canvas.create_image(
                    50 + 32 + (i) * 32,
                    50 + (j) * 32,
                    anchor="ne",
                    image=self.parent.obstacle_imgs[0])
                self.canvas.tag_raise(img)
                self.ob_refs[i].append(img)

        self.h_refs = []
        for i in range(length):
            self.h_refs.append([])
            for j in range(width):
                img = self.canvas.create_image(50 + 32 + (i) * 32,
                                               50 + 32 + (j) * 32,
                                               anchor="se",
                                               image=self.parent.hang_imgs[0])
                self.canvas.tag_raise(img)
                self.h_refs[i].append(img)

        self.spawn_refs = []
        for i in range(length):
            self.spawn_refs.append([])
            for j in range(width):
                img = self.canvas.create_image(50 + (i) * 32,
                                               50 + (j) * 32,
                                               anchor="nw",
                                               image=self.parent.spawn_imgs[0])
                self.canvas.tag_raise(img)
                self.spawn_refs[i].append(img)

        for j in range(width):
            img_l = self.canvas.create_image(18,
                                             50 + (j) * 32,
                                             anchor="nw",
                                             image=self.parent.wall_imgs[1])
            img_r = self.canvas.create_image(50 + (length) * 32,
                                             50 + (j) * 32,
                                             anchor="nw",
                                             image=self.parent.wall_imgs[3])
            self.wall_refs[3].append(img_r)
            self.wall_refs[1].append(img_l)
            #self.canvas.tag_bind(self.wall_refs[3][j], '<ButtonPress-1>', self.second_helper(3,j))
            #self.canvas.tag_bind(self.wall_refs[1][j], '<ButtonPress-1>', self.second_helper(1,j))

            dec_r = self.canvas.create_image(
                18 + 25,
                50 + 16 + (j) * 32,
                anchor="e",
                image=self.parent.walldec_imgs[1][0])
            self.canvas.tag_raise(dec_r)
            self.dec_refs[1].append(dec_r)
            #self.canvas.tag_bind(self.dec_refs[1][j], '<ButtonPress-1>', self.second_helper(1,j))

            dec_l = self.canvas.create_image(
                50 + (length) * 32 + 7,
                50 + 16 + (j) * 32,
                anchor="w",
                image=self.parent.walldec_imgs[3][0])
            self.canvas.tag_raise(dec_l)
            self.dec_refs[3].append(dec_l)
            #self.canvas.tag_bind(self.dec_refs[3][j], '<ButtonPress-1>', self.second_helper(3,j))
        door = self.canvas.create_image(50 + (length) * 16,
                                        57,
                                        anchor="s",
                                        image=self.parent.wall_imgs[8])
        self.canvas.tag_raise(door)
        self.wall_refs[4].append(door)
        door = self.canvas.create_image(57,
                                        50 + (width) * 16,
                                        anchor="e",
                                        image=self.parent.wall_imgs[9])
        self.canvas.tag_raise(door)
        self.wall_refs[4].append(door)
        door = self.canvas.create_image(50 + (length) * 16,
                                        43 + (width) * 32,
                                        anchor="n",
                                        image=self.parent.wall_imgs[10])
        self.canvas.tag_raise(door)
        self.wall_refs[4].append(door)
        door = self.canvas.create_image(43 + (length) * 32,
                                        50 + (width) * 16,
                                        anchor="w",
                                        image=self.parent.wall_imgs[11])
        self.canvas.tag_raise(door)
        self.wall_refs[4].append(door)

        self.hov_refs = []
        for i in range(length + 2):
            self.hov_refs.append([])
            for j in range(width + 2):
                img = self.canvas.create_image(18 + (i) * 32,
                                               18 + (j) * 32,
                                               anchor="nw",
                                               image=self.parent.hover_imgs[0])
                self.canvas.tag_raise(img)
                self.hov_refs[i].append(img)
                self.canvas.tag_bind(self.hov_refs[i][j], '<Enter>',
                                     self.first_helper(i, j, 1))
                self.canvas.tag_bind(self.hov_refs[i][j], '<Leave>',
                                     self.first_helper(i, j, 0))

        self.mouse_pressed = False
        self.canvas.bind("<ButtonPress-1>", self.mouseDown)
        self.canvas.bind("<ButtonRelease-1>", self.mouseUp)
        self.canvas.bind('<Motion>', self.poll)
        self.canvas.bind_all('e', self.click_spawn)
        self.canvas.bind_all('z', self.undo)
        self.canvas.bind("<ButtonPress-2>", self.erase)
        self.canvas.bind("<ButtonPress-3>", self.erase)
Beispiel #4
0
    def __init__(self):

        tk.Tk.__init__(self)

        self.title('OpenDrift ' + opendrift.__version__ + ' GTI Turbo Ultra')

        ##################
        # Layout frames
        ##################
        self.n = ttk.Notebook(self.master)
        self.n.grid()
        self.seed = ttk.Frame(self.n)
        self.confignotebook = ttk.Notebook(self.n)
        self.config = ttk.Frame(self.confignotebook)
        self.forcing = ttk.Frame(self.n)
        self.n.add(self.seed, text='Seeding')
        self.n.add(self.confignotebook, text='Config')
        self.n.add(self.forcing, text='Forcing')
        self.confignotebook.add(self.config, text='SubConfig')

        # Top
        self.top = tk.Frame(self.seed, relief=tk.FLAT, pady=25, padx=25)
        self.top.grid(row=0, column=1, rowspan=1)
        # Time start and end
        self.start_t = tk.Frame(self.seed, relief=tk.FLAT)
        self.start_t.grid(row=20, column=0, rowspan=1)
        self.end_t = tk.Frame(self.seed, relief=tk.FLAT)
        self.end_t.grid(row=30, column=0, rowspan=1)
        self.start = tk.Frame(self.seed,
                              bg='lightgray',
                              bd=2,
                              relief=tk.SUNKEN,
                              pady=5,
                              padx=5)
        self.start.grid(row=20, column=1, rowspan=1)
        self.end = tk.Frame(self.seed,
                            bg='gray',
                            bd=2,
                            relief=tk.SUNKEN,
                            padx=5,
                            pady=5)
        self.end.grid(row=30, column=1)
        self.coastline = tk.Frame(self.seed,
                                  bd=2,
                                  relief=tk.FLAT,
                                  padx=5,
                                  pady=0)
        self.coastline.grid(row=40, column=1)
        self.duration = tk.Frame(self.seed,
                                 bd=2,
                                 relief=tk.FLAT,
                                 padx=5,
                                 pady=5)
        self.duration.grid(row=50, column=1)
        self.output = tk.Frame(self.seed, bd=2, relief=tk.FLAT, padx=5, pady=0)
        self.output.grid(row=70, column=0, columnspan=7, sticky='nsew')

        self.results = tk.Frame(self.seed,
                                bd=2,
                                relief=tk.FLAT,
                                padx=5,
                                pady=0)
        self.results.grid(row=60, column=7, columnspan=1, sticky='ew')

        #######################################################
        tk.Label(self.top, text='Simulation type').grid(row=0, column=0)
        self.model = tk.StringVar()
        self.model.set(list(self.opendrift_models)[0])
        self.modeldrop = tk.OptionMenu(self.top,
                                       self.model,
                                       *(list(self.opendrift_models)),
                                       command=self.set_model)
        self.modeldrop.grid(row=0, column=1)

        help_button = tk.Button(self.top, text='Help', command=self.show_help)
        help_button.grid(row=0, column=2, padx=50)

        ##########
        # Release
        ##########
        startlabel = tk.Label(self.start_t, text="\n\nStart release\n\n")
        startlabel.grid(row=0, column=0)

        tk.Label(self.start, text='Longitude').grid(row=0, column=1)
        tk.Label(self.start, text='Latitude').grid(row=0, column=0)
        tk.Label(self.start, text='Radius [m]').grid(row=0, column=2)
        self.latvar = tk.StringVar()
        self.lonvar = tk.StringVar()
        self.radiusvar = tk.StringVar()
        self.lat = tk.Entry(self.start,
                            textvariable=self.latvar,
                            width=6,
                            justify=tk.RIGHT)
        self.lon = tk.Entry(self.start,
                            textvariable=self.lonvar,
                            width=6,
                            justify=tk.RIGHT)
        self.radius = tk.Entry(self.start,
                               width=6,
                               textvariable=self.radiusvar,
                               justify=tk.RIGHT)
        self.lon.grid(row=10, column=1)
        self.lon.insert(0, '4.5')
        self.lat.grid(row=10, column=0)
        self.lat.insert(0, '60.0')
        self.radius.grid(row=10, column=2)
        self.radius.insert(0, '1000')
        self.lonvar.trace('w', self.copy_position)
        self.latvar.trace('w', self.copy_position)
        self.radiusvar.trace('w', self.copy_position)
        ##########
        # Time
        ##########
        now = datetime.utcnow()
        tk.Label(self.start, text='Day').grid(row=20, column=0)
        tk.Label(self.start, text='Month').grid(row=20, column=1)
        tk.Label(self.start, text='Year').grid(row=20, column=2)
        tk.Label(self.start, text='Hour').grid(row=20, column=3)
        tk.Label(self.start, text='Minutes [UTC]').grid(row=20, column=4)
        self.datevar = tk.StringVar()
        self.dates = range(1, 32)
        self.datevar.set(now.day)
        self.date = tk.OptionMenu(self.start, self.datevar, *self.dates)
        self.date.grid(row=30, column=0)

        self.monthvar = tk.StringVar()
        self.months = [
            'January', 'February', 'March', 'April', 'May', 'June', 'July',
            'August', 'September', 'October', 'November', 'December'
        ]
        self.monthvar.set(self.months[now.month - 1])
        self.month = tk.OptionMenu(self.start, self.monthvar, *self.months)
        self.month.grid(row=30, column=1)

        self.yearvar = tk.StringVar()
        self.years = range(2015, now.year + 2)
        self.yearvar.set(now.year)
        self.year = tk.OptionMenu(self.start, self.yearvar, *self.years)
        self.year.grid(row=30, column=2)

        self.hourvar = tk.StringVar()
        self.hours = range(0, 24)
        self.hourvar.set(now.hour)
        self.hour = tk.OptionMenu(self.start, self.hourvar, *self.hours)
        self.hour.grid(row=30, column=3)

        self.minutevar = tk.StringVar()
        self.minutes = range(0, 60, 5)
        self.minutevar.set(now.minute)
        self.minute = tk.OptionMenu(self.start, self.minutevar, *self.minutes)
        self.minute.grid(row=30, column=4)

        self.datevar.trace('w', self.copy_position)
        self.monthvar.trace('w', self.copy_position)
        self.yearvar.trace('w', self.copy_position)
        self.hourvar.trace('w', self.copy_position)
        self.minutevar.trace('w', self.copy_position)

        ###############
        # Release End
        ###############
        endlabel = tk.Label(self.end_t, text="\n\nEnd release\n\n")
        endlabel.grid(row=0, column=0)
        tk.Label(self.end, text='Longitude', bg='gray').grid(row=0, column=1)
        tk.Label(self.end, text='Latitude', bg='gray').grid(row=0, column=0)
        tk.Label(self.end, text='Radius [m]', bg='gray').grid(row=0, column=2)
        self.elat = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.elon = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.eradius = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.elon.grid(row=10, column=1)
        self.elon.insert(0, '4.5')
        self.elat.grid(row=10, column=0)
        self.elat.insert(0, '60.0')
        self.eradius.grid(row=10, column=2)
        self.eradius.insert(0, '1000')
        ##########
        # Time
        ##########
        now = datetime.utcnow()
        tk.Label(self.end, text='Day', bg='gray').grid(row=20, column=0)
        tk.Label(self.end, text='Month', bg='gray').grid(row=20, column=1)
        tk.Label(self.end, text='Year', bg='gray').grid(row=20, column=2)
        tk.Label(self.end, text='Hour', bg='gray').grid(row=20, column=3)
        tk.Label(self.end, text='Minutes [UTC]', bg='gray').grid(row=20,
                                                                 column=4)
        self.edatevar = tk.StringVar()
        self.edates = range(1, 32)
        self.edatevar.set(now.day)
        self.edate = tk.OptionMenu(self.end, self.edatevar, *self.edates)
        self.edate.grid(row=30, column=0)

        self.emonthvar = tk.StringVar()
        self.emonthvar.set(self.months[now.month - 1])
        self.emonth = tk.OptionMenu(self.end, self.emonthvar, *self.months)
        self.emonth.grid(row=30, column=1)

        self.eyearvar = tk.StringVar()
        self.eyears = range(2015, now.year + 2)
        self.eyearvar.set(now.year)
        self.eyear = tk.OptionMenu(self.end, self.eyearvar, *self.eyears)
        self.eyear.grid(row=30, column=2)

        self.ehourvar = tk.StringVar()
        self.ehours = range(0, 24)
        self.ehourvar.set(now.hour)
        self.ehour = tk.OptionMenu(self.end, self.ehourvar, *self.ehours)
        self.ehour.grid(row=30, column=3)

        self.eminutevar = tk.StringVar()
        self.eminutes = range(0, 60, 5)
        self.eminutevar.set(now.minute)
        self.eminute = tk.OptionMenu(self.end, self.eminutevar, *self.eminutes)
        self.eminute.grid(row=30, column=4)
        self.eyear.config(bg='gray')
        self.emonth.config(bg='gray')
        self.edate.config(bg='gray')
        self.ehour.config(bg='gray')
        self.eminute.config(bg='gray')

        # Check seeding
        check_seed = tk.Button(self.end_t,
                               text='Check seeding',
                               command=self.check_seeding)
        check_seed.grid(row=10, column=0, padx=0)

        #######################
        # Simulation duration
        #######################
        tk.Label(self.duration, text='Run simulation ').grid(row=50, column=0)
        self.durationhours = tk.Entry(self.duration, width=3, justify=tk.RIGHT)
        self.durationhours.grid(row=50, column=1)
        self.durationhours.insert(0, 12)
        tk.Label(self.duration, text=' hours ').grid(row=50, column=2)

        self.directionvar = tk.StringVar()
        self.directionvar.set('forwards')
        self.direction = tk.OptionMenu(self.duration, self.directionvar,
                                       'forwards', 'backwards')
        self.direction.grid(row=50, column=3)
        tk.Label(self.duration, text=' in time ').grid(row=50, column=4)

        ##############
        # Output box
        ##############
        self.text = tk.Text(self.output, wrap="word", height=18)
        self.text.grid(row=60, columnspan=6, sticky='nsw')
        self.text.tag_configure("stderr", foreground="#b22222")
        sys.stdout = TextRedirector(self.text, "stdout")
        sys.stderr = TextRedirector(self.text, "stderr")
        s = tk.Scrollbar(self)
        s.grid(row=60, column=6, sticky='ns')
        s.config(command=self.text.yview)
        self.text.config(yscrollcommand=s.set)

        # Diana
        self.dianadir = '/vol/vvfelles/opendrift/output/'
        if os.path.exists(self.dianadir):
            self.has_diana = True
            print('Diana is available!')
            self.outputdir = '/vol/vvfelles/opendrift/output_native/'
            startbutton = 'PEIS PAO'
        else:
            self.has_diana = False
            startbutton = 'START'

        ##############
        # Initialise
        ##############
        self.set_model(list(self.opendrift_models)[0])

        forcingfiles = open(
            self.o.test_data_folder() +
            '../../opendrift/scripts/data_sources.txt').readlines()
        print(forcingfiles)
        for i, ff in enumerate(forcingfiles):
            tk.Label(self.forcing,
                     text=ff.strip(),
                     wraplength=650,
                     font=('Courier', 8)).grid(row=i, column=0, sticky=tk.W)

        ##########################
        try:
            img = ImageTk.PhotoImage(
                Image.open(self.o.test_data_folder() +
                           '../../docs/opendrift_logo.png'))
            panel = tk.Label(self.seed, image=img)
            panel.image = img
            panel.grid(row=0, column=0)
        except Exception as e:
            print(e)
            pass  # Could not display logo

        ##########
        # RUN
        ##########
        tk.Button(self.seed,
                  text=startbutton,
                  bg='green',
                  command=self.run_opendrift).grid(row=80,
                                                   column=1,
                                                   sticky=tk.W,
                                                   pady=4)
Beispiel #5
0
         command=UpdateSharpness).grid(row=2, column=3)
tk.Scale(root.buttonframe,
         from_=-100,
         to=100,
         orient=tk.HORIZONTAL,
         label="Saturation",
         command=UpdateSaturation).grid(row=3, column=1)
tk.Scale(root.buttonframe,
         from_=10,
         to=99,
         orient=tk.HORIZONTAL,
         label="Zoom",
         command=Zoom).grid(row=4, column=1)

AWB_Var = tk.StringVar(root)
AWB_Var.set(choices[0])
AWB_Option = tk.OptionMenu(root.buttonframe, AWB_Var, *choices,
                           command=SetAWB).grid(row=3, column=2)

EFFECT_Var = tk.StringVar(root)
EFFECT_Var.set(effects[0])
EFFECT_Option = tk.OptionMenu(root.buttonframe,
                              EFFECT_Var,
                              *effects,
                              command=SetEFFECTS).grid(row=3, column=3)

#enable next line to lock window in place
#root.overrideredirect(True)

root.mainloop()
    def __init__(self, parent, controller):
        # parent representa el Frame principal del programa, tenemos que indicarle
        # cuando MenuInputOutput será dibujado

        # controller lo utilizamos cuando necesitamos que el controlador principal del programa haga algo

        # llamamos al constructor
        tk.Frame.__init__(self, parent)

        self.controller = controller
        self.parent = parent

        self.title = tk.Label(self,
                              height=1,
                              width=50,
                              text="High-Pass Filter Parameters",
                              font=Config.LARGE_FONT,
                              background="#ffccd5")
        ############ FIRST ORDER ######################
        self.titleFo = tk.Label(self,
                                height=1,
                                width=50,
                                text="Critical Frequency",
                                font=Config.SMALL_FONT,
                                background="#ccffd5")
        self.var = tk.StringVar(self)
        self.var.set("Hz")
        OPTION_TUPLE = ("Hz", "KHz", "MHz", "GHz")
        self.scale = tk.OptionMenu(self, self.var, *OPTION_TUPLE)

        self.w2 = tk.Scale(self,
                           from_=0,
                           to=1000,
                           resolution=0.1,
                           orient=tk.HORIZONTAL)

        ############ SECOND ORDER ######################
        self.titleF1 = tk.Label(self,
                                height=1,
                                width=50,
                                text="Critical Frequency 2nd Order",
                                font=Config.SMALL_FONT,
                                background="#ccffd5")
        self.titleEpsilon = tk.Label(self,
                                     height=1,
                                     width=50,
                                     text="Epsilon ε",
                                     font=Config.SMALL_FONT,
                                     background="#ccffd5")
        self.epsilon = tk.Scale(self,
                                from_=0,
                                to=2,
                                resolution=0.05,
                                orient=tk.HORIZONTAL)
        ############ COMMON ######################
        self.titleG = tk.Label(self,
                               height=1,
                               width=50,
                               text="Gain",
                               font=Config.SMALL_FONT,
                               background="#ccffd5")

        self.gain = tk.Scale(self,
                             from_=0,
                             to=1000,
                             resolution=1,
                             orient=tk.HORIZONTAL)
        self.buttonSimulate = tk.Button(self,
                                        height=2,
                                        width=50,
                                        text="Simulate",
                                        font=Config.SMALL_FONT,
                                        background="#ccffd5",
                                        command=self.simulate)
        # Back to Home
        self.buttonBackFromFirst = tk.Button(self,
                                             height=1,
                                             width=50,
                                             text="Home Screen",
                                             font=Config.SMALL_FONT,
                                             background="#eb1717",
                                             command=self.backFromLow)
Beispiel #7
0
    def __init__(self, master):
        self.window = master

        # Set up for high-resolution screens
        normscrwidt = 1024
        normscrhigt = 768
        scrwidt = master.winfo_screenwidth()
        scrhigt = master.winfo_screenheight()
        # These to use if operating system doesn't automatically adjust
        #self.widfac=scrwidt/normscrwidt
        #self.highfac=scrhigt/normscrhigt
        self.widfac = normscrwidt / normscrhigt
        self.highfac = 1
        fontfac = (normscrwidt / normscrhigt) / (scrwidt / scrhigt)

        master.title("GPRPy")

        # Variables specific to GUI
        self.balloon = Pmw.Balloon()
        self.picking = False
        self.delimiter = None
        self.grid = False

        # Initialize the gprpy
        proj = gp.gprpyProfile()

        # Show splash screen
        fig = Figure(figsize=(8 * self.widfac, 5 * self.highfac))
        a = fig.add_subplot(111)
        dir_path = os.path.dirname(os.path.realpath(__file__))
        splash.showSplash(a, dir_path, self.widfac, self.highfac, fontfac)

        # Set font size for screen res
        mpl.rcParams.update(
            {'font.size': mpl.rcParams['font.size'] * self.widfac})
        a.tick_params(direction='out',
                      length=6 * self.widfac,
                      width=self.highfac)

        a.get_xaxis().set_visible(False)
        a.get_yaxis().set_visible(False)
        canvas = FigureCanvasTkAgg(fig, master=self.window)
        canvas.get_tk_widget().grid(row=2,
                                    column=0,
                                    columnspan=figcolsp,
                                    rowspan=figrowsp,
                                    sticky='nsew')

        canvas.draw()

        ## Visualization Buttons

        # Undo Button
        undoButton = tk.Button(
            text="undo",
            command=lambda: [
                self.resetYrng(proj),
                self.undo(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        undoButton.config(height=1, width=2 * halfwid)
        undoButton.grid(row=0, column=0, sticky='nsew', rowspan=2)
        self.balloon.bind(
            undoButton, '"Undoes" the most recent processing step and\n'
            'sets the data back to its previous state.\n'
            'This also removes the most recent processing\n'
            'step from the history. Does not revert\n'
            'visualization settings such as "set x-range"\n'
            'etc.')

        # Full view
        FullButton = tk.Button(
            text="full view",
            fg="black",
            command=lambda: [
                self.setFullView(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        FullButton.config(height=1, width=2 * halfwid)
        FullButton.grid(row=0, column=1, sticky='nsew', rowspan=2)
        self.balloon.bind(FullButton,
                          "Resets x- and y-axis limits to full data.")

        # Grid button
        GridButton = tk.Button(
            text="grid",
            fg="black",
            command=lambda: [
                self.toggleGrid(),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        GridButton.config(height=1, width=2 * halfwid)
        GridButton.grid(row=0, column=2, sticky='nsew', rowspan=2)
        self.balloon.bind(GridButton, "Toggles grid on/off.")

        # X range
        XrngButton = tk.Button(
            text="set x-range",
            fg="black",
            command=lambda: [
                self.setXrng(),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        XrngButton.config(height=1, width=2 * halfwid)
        XrngButton.grid(row=0, column=3, sticky='nsew', rowspan=2)
        self.balloon.bind(XrngButton, "Set the x-axis display limits.")

        # Y range
        YrngButton = tk.Button(
            text="set y-range",
            fg="black",
            command=lambda: [
                self.setYrng(),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        YrngButton.config(height=1, width=2 * halfwid)
        YrngButton.grid(row=0, column=4, sticky='nsew', rowspan=2)
        self.balloon.bind(YrngButton, "Set the y-axis display limits.")

        # Aspect
        AspButton = tk.Button(
            text="aspect ratio",
            fg="black",
            command=lambda: [
                self.setAspect(),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        AspButton.config(height=1, width=2 * halfwid)
        AspButton.grid(row=0, column=5, sticky='nsew', rowspan=2)
        self.balloon.bind(AspButton,
                          "Set the aspect ratio between x- and y-axis.")

        # Contrast
        contrtext = tk.StringVar()
        contrtext.set("contrast")
        contrlabel = tk.Label(master,
                              textvariable=contrtext,
                              height=1,
                              width=2 * halfwid)
        contrlabel.grid(row=0, column=6, sticky='nsew')
        self.balloon.bind(contrlabel, "Set color saturation")
        self.contrast = tk.DoubleVar()
        contrbox = tk.Entry(master,
                            textvariable=self.contrast,
                            width=2 * halfwid)
        contrbox.grid(row=1, column=6, sticky='nsew')
        #contr.set("1.0")
        self.contrast.set("1.0")

        # Mode switch for figure color
        self.color = tk.StringVar()
        self.color.set("gray")
        colswitch = tk.OptionMenu(master, self.color, "gray", "bwr")
        colswitch.grid(row=0, column=7, sticky='nsew', rowspan=2)
        self.balloon.bind(
            colswitch, "Choose between gray-scale\n"
            "and red-white-blue (rwb)\n"
            "data representation.")

        # Refreshing plot
        plotButton = tk.Button(text="refresh plot",
                               command=lambda: self.plotProfileData(
                                   proj, fig=fig, a=a, canvas=canvas))
        plotButton.config(height=1, width=2 * halfwid)
        plotButton.grid(row=0, column=8, sticky='nsew', rowspan=2)
        self.balloon.bind(
            plotButton, "Refreshes the figure after changes\n"
            "in the visualization settings. Also\n"
            "removes any plotted hyperbolae.")

        ## Methods buttons

        # Load data
        LoadButton = tk.Button(
            text="import data",
            fg="black",
            command=lambda: [
                self.loadData(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        LoadButton.config(height=1, width=2 * halfwid)
        LoadButton.grid(row=0,
                        column=rightcol,
                        sticky='nsew',
                        columnspan=colsp,
                        rowspan=2)
        self.balloon.bind(LoadButton, "Load .gpr, .DT1, or .DZT data.")

        # Adjust profile length; if trigger wheel is not good
        AdjProfileButton = tk.Button(
            text="adj profile",
            fg="black",
            command=lambda: [
                self.adjProfile(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        AdjProfileButton.config(height=1, width=2 * halfwid)
        AdjProfileButton.grid(row=2,
                              column=rightcol,
                              sticky='nsew',
                              columnspan=colsp)
        self.balloon.bind(
            AdjProfileButton, "Adjust the profile length to \n"
            "known start and end positions\n"
            "and/or flip the profile horizontally\n"
            "(left to right)")

        # Set new zero time
        SetZeroTimeButton = tk.Button(
            text="set zero time",
            fg="black",
            command=lambda: [
                self.setZeroTime(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        SetZeroTimeButton.config(height=1, width=2 * halfwid)
        SetZeroTimeButton.grid(row=3,
                               column=rightcol,
                               sticky='nsew',
                               columnspan=colsp)
        self.balloon.bind(
            SetZeroTimeButton, "Set the two-way travel time \n"
            "that corresponds to the surface.")

        # TimeZero Adjust = align traces
        TrAlignButton = tk.Button(
            text="align traces",
            fg="black",
            command=lambda: [
                proj.alignTraces(),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        TrAlignButton.config(height=1, width=2 * halfwid)
        TrAlignButton.grid(row=4,
                           column=rightcol,
                           sticky='nsew',
                           columnspan=colsp)
        self.balloon.bind(
            TrAlignButton, 'Automatically shifts each trace up or down\n'
            'such that the maximum aplitudes of the individual\n'
            'traces align. Can lead to problems when the maxima\n'
            'are not in the air waves. If the results are bad,\n'
            'use the "undo" button.')

        # truncate Y
        truncYButton = tk.Button(
            text="truncate Y",
            fg="black",
            command=lambda: [
                self.truncateY(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        truncYButton.config(height=1, width=2 * halfwid)
        truncYButton.grid(row=5,
                          column=rightcol,
                          sticky='nsew',
                          columnspan=colsp)
        self.balloon.bind(
            truncYButton, "Remove data points at arrival times\n"
            "later than the chosen value. If velocity\n"
            "is given: remove data points at depths greater\n"
            "than the chosen value")

        # Cut
        cutButton = tk.Button(
            text="cut profile",
            fg="black",
            command=lambda: [
                self.cut(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        cutButton.config(height=1, width=2 * halfwid)
        cutButton.grid(row=6, column=rightcol, sticky='nsew', columnspan=colsp)
        self.balloon.bind(cutButton,
                          "trims data to desired along-profile range.")

        # Dewow
        DewowButton = tk.Button(
            text="dewow",
            fg="black",
            command=lambda: [
                self.dewow(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        DewowButton.config(height=1, width=2 * halfwid)
        DewowButton.grid(row=7,
                         column=rightcol,
                         sticky='nsew',
                         columnspan=colsp)
        self.balloon.bind(
            DewowButton, "Trace-wise low-cut filter. Removes\n"
            "from each trace a running mean of\n"
            "chosen window width.")

        # Rem mean trace
        remMeanTraceButton = tk.Button(
            text="rem mean tr",
            fg="black",
            command=lambda: [
                self.remMeanTrace(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        remMeanTraceButton.config(height=1, width=2 * halfwid)
        remMeanTraceButton.grid(row=8,
                                column=rightcol,
                                sticky='nsew',
                                columnspan=colsp)
        self.balloon.bind(
            remMeanTraceButton, "Removes from each trace the average\n"
            "of its surrounding traces. This can be\n"
            "useful to remove air waves, ground\n"
            "waves, or horizontal features.")

        # Smooth
        SmoothButton = tk.Button(
            text="smooth (temp)",
            fg="black",
            command=lambda: [
                self.smooth(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        SmoothButton.config(height=1, width=2 * halfwid)
        SmoothButton.grid(row=9,
                          column=rightcol,
                          sticky='nsew',
                          columnspan=colsp)
        self.balloon.bind(
            SmoothButton, "Trace-wise high-cut filter. Replaces\n"
            "each sample within a trace by a\n"
            "running mean of chosen window width.")

        # profile Smoothing Button
        profSmButton = tk.Button(
            text="profile smoothing",
            fg="black",
            command=lambda: [
                self.profileSmooth(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        profSmButton.config(height=1, width=2 * halfwid)
        profSmButton.grid(row=10,
                          column=rightcol,
                          sticky='nsew',
                          columnspan=colsp)
        self.balloon.bind(
            profSmButton, "First oversamples the profile (makes 'n' copies\n"
            "of each trace) and then replaces each trace by\n"
            "the mean of its neighboring 'm' traces.")

        # Gain
        tpowButton = tk.Button(
            text="tpow",
            fg="black",
            command=lambda: [
                self.tpowGain(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        tpowButton.config(height=1, width=halfwid)
        tpowButton.grid(row=11, column=rightcol, sticky='nsew')
        self.balloon.bind(
            tpowButton, "t-power gain. Increases the power of the\n"
            "signal by a factor of (two-way travel time)^p,\n"
            "where the user provides p. This gain is often\n"
            "less aggressive than agc.")

        agcButton = tk.Button(
            text="agc",
            fg="black",
            command=lambda: [
                self.agcGain(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        agcButton.config(height=1, width=halfwid)
        agcButton.grid(row=11, column=rightcol + 1, sticky='nsew')
        self.balloon.bind(
            agcButton, "Automatic gain controll. Normalizes the power\n"
            "of the signal per given sample window along\n"
            "each trace.")

        # show hyperbola
        hypButton = tk.Button(
            text="show hyperb",
            fg="black",
            command=lambda: [self.showHyp(proj, a),
                             canvas.draw()])
        hypButton.config(height=1, width=2 * halfwid)
        hypButton.grid(row=12,
                       column=rightcol,
                       sticky='nsew',
                       columnspan=colsp)
        self.balloon.bind(
            hypButton, "Draws a hyperbola depending on profile position,\n"
            "two-way travel time, and estimated velocity. This\n"
            "can be used to find the subsurface velocity when\n"
            "a hyperbola is visible in the data.\n"
            "The plotted hyperbola will disappear when the image\n"
            "is refreshed.")

        # Set Velocity
        setVelButton = tk.Button(
            text="set vel",
            fg="black",
            command=lambda: [
                self.setVelocity(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        setVelButton.config(height=1, width=2 * halfwid)
        setVelButton.grid(row=13,
                          column=rightcol,
                          sticky='nsew',
                          columnspan=colsp)
        self.balloon.bind(
            setVelButton,
            "Set the known subsurface radar velocity. This will\n"
            "turn the y-axis from two-way travel time to depth.\n"
            "This step is necessary for topographic correction.")

        # Correct for antenna separation
        antennaSepButton = tk.Button(
            text="antenna sep correct",
            fg="black",
            command=lambda: [
                self.antennaSep(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        antennaSepButton.config(height=1, width=2 * halfwid)
        antennaSepButton.grid(row=14,
                              column=rightcol,
                              sticky='nsew',
                              columnspan=colsp)
        self.balloon.bind(
            antennaSepButton,
            "If the antenna offset is provided, this corrects for\n"
            "distortion of arrival times near the surface due to\n"
            "the separation of transmitter and receiver antenna.\n"
            "You must have picked the first break of the airwave\n"
            "for this to function properly and the velocity must be set.")

        # Migration Button
        migButton = tk.Button(
            text="fk migration",
            fg="black",
            command=lambda: [
                self.fkMigration(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        migButton.config(height=1, width=2 * halfwid)
        migButton.grid(row=15,
                       column=rightcol,
                       sticky='nsew',
                       columnspan=colsp)
        self.balloon.bind(
            migButton, "Stolt's fk migration using a code originally written\n"
            "in Matlab for the CREWES software package.\n"
            "Translated into Python 2 by Nat Wilson.")

        # Topo Correct
        topoCorrectButton = tk.Button(
            text="topo correct",
            fg="black",
            command=lambda: [
                self.topoCorrect(proj),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])
        topoCorrectButton.config(height=1, width=2 * halfwid)
        topoCorrectButton.grid(row=16,
                               column=rightcol,
                               sticky='nsew',
                               columnspan=colsp)
        self.balloon.bind(
            topoCorrectButton,
            "Reads a comma- or tab-separated file containing\n"
            "either 3 columns (easting, northing, elevation)\n"
            "or two columns (profile position, elevation).\n"
            "All coordinates in meters.")

        startPickButton = tk.Button(text="start pick",
                                    fg="black",
                                    command=lambda: self.startPicking(
                                        proj, fig=fig, a=a, canvas=canvas))
        startPickButton.config(height=1, width=halfwid)
        startPickButton.grid(row=17,
                             column=rightcol,
                             sticky='nsew',
                             columnspan=1)
        self.balloon.bind(
            startPickButton, "Start collecting location information\n"
            "by clicking on the profile.")

        stopPickButton = tk.Button(
            text="stop pick",
            fg="black",
            command=lambda: [
                self.stopPicking(proj, canvas),
                self.plotProfileData(proj, fig=fig, a=a, canvas=canvas)
            ])

        stopPickButton.config(height=1, width=halfwid)
        stopPickButton.grid(row=17,
                            column=rightcol + 1,
                            sticky='nsew',
                            columnspan=1)
        self.balloon.bind(
            stopPickButton, "Stop collecting location information\n"
            "and save the locations you collected\n"
            "in a text file.")

        # Save data
        SaveButton = tk.Button(text="save data",
                               fg="black",
                               command=lambda: self.saveData(proj))
        SaveButton.config(height=1, width=2 * halfwid)
        SaveButton.grid(row=18,
                        column=rightcol,
                        sticky='nsew',
                        columnspan=colsp)
        self.balloon.bind(
            SaveButton, 'saves the processed data including its history in a\n'
            '.gpr file. The resulting file will contain absolute\n'
            'path names of the used data and topography files.\n'
            'Visualization settings such as "set x-range" or\n'
            '"contrast" will not be saved.')

        # Print Figure
        PrintButton = tk.Button(
            text="print figure",
            fg="black",
            command=lambda: self.printProfileFig(proj=proj, fig=fig))
        PrintButton.config(height=1, width=2 * halfwid)
        PrintButton.grid(row=19,
                         column=rightcol,
                         sticky='nsew',
                         columnspan=colsp)
        self.balloon.bind(
            PrintButton, "Saves the current visible figure in a pdf with \n"
            "chosen resolution. If there is a hyperbola on\n"
            "the current figure, then the hyperbola will also\n"
            "appear on the printed figure.")

        # Export to VTK
        VTKButton = tk.Button(text="export to VTK",
                              fg="black",
                              command=lambda: self.exportVTK(proj))
        VTKButton.config(height=1, width=2 * halfwid)
        VTKButton.grid(row=20,
                       column=rightcol,
                       sticky='nsew',
                       columnspan=colsp)
        self.balloon.bind(
            VTKButton, "Exports the processed figure to a\n"
            "VTK format, that can be read by\n"
            "Paraview or similar 3D programs")

        # Write script
        HistButton = tk.Button(text="write script",
                               fg="black",
                               command=lambda: self.writeHistory(proj))
        HistButton.config(height=1, width=2 * halfwid)
        HistButton.grid(row=21,
                        column=rightcol,
                        sticky='nsew',
                        columnspan=colsp)
        self.balloon.bind(
            HistButton, 'Writes a python script to reproduce the \n'
            'current status.\n'
            '\n'
            'If the current data is from a .gpr file, \n'
            'then the python script will contain all \n'
            'steps going back to the raw data. \n'
            '\n'
            'The script will not contain visualization \n'
            'settings such as x-range settings, unless \n'
            'the "print figure" command was used. ')
Beispiel #8
0
    def change_climate(self):
        """
        Opens up a new window where the user can change the climate from the administration
        class "Simulation".
        """

        frame4 = tk.Toplevel(self)
        textwidg = tk.Text(frame4, width=70, height=7)

        textwidg.insert(
            tk.END,
            "Welcome! Not all animals can survive in every climate,and here you have the chance to change it to your preference. You won't know until after the simulation has started what animals can survive what. It's all put into chance."
        )
        textwidg.grid(row=0, column=0, rowspan=6, columnspan=3, sticky=tk.N)

        def choice(event):
            """
            Randomizes a temprature from the span that the user has decided on.
            """

            choice = option_variable3.get()
            if choice == "Snowstorm(-20 to -15 degrees)":
                self.weather_choice = random.randint(-20, -15)
            elif choice == "Summer in Alaska(-15 to -5 degrees)":
                self.weather_choice = random.randint(-15, -5)
            elif choice == "Swedish pissweather(-5 to 5 degrees)":
                self.weather_choice = random.randint(-5, 5)
            elif choice == "Can't believe it's not summer (5-15 degrees)":
                self.weather_choice = random.randint(5, 15)
            elif choice == "bikini-weather (15-25 degrees)":
                self.weather_choice = random.randint(15, 25)
            elif choice == "Not even gonna bother with a bikini (25-30 degrees)":
                self.weather_choice = random.randint(25, 30)
            elif choice == "Feeeel the bern (30 to 40 degrees)":
                self.weather_choice = random.randint(30, 40)

        def close_window():
            """
            Changes the temprature and closes the window.
            """

            self.sim.set_weather(self.weather_choice)
            self.update_window()
            frame4.destroy()

        def delete_choice():
            """
            Resets the temprature and closes the window.
            """

            self.weather_choice = self.sim.get_weather()
            frame4.destroy()

        option_variable3 = tk.StringVar(frame4)
        option_variable3.set("Option meny")
        option = tk.OptionMenu(
            frame4,
            option_variable3,
            "Snowstorm(-20 to -15 degrees)",
            "Summer in Alaska(-15 to -5 degrees)",
            "Swedish pissweather(-5 to 5 degrees)",
            "Can't believe it's not summer (5-15 degrees)",
            "bikini-weather (15-25 degrees)",
            "Not even gonna bother with a bikini (25-30 degrees)",
            "Feeeel the bern (30 to 40 degrees)",
            command=choice)
        option.grid(row=7, column=1)

        button3 = tk.Button(frame4,
                            text="Return without saving",
                            command=delete_choice)
        button4 = tk.Button(frame4,
                            text="save and return",
                            command=close_window)
        button3.grid(row=8, column=0)
        button4.grid(row=8, column=1)
Beispiel #9
0
    def create_new_species(self):
        """
        Window that pops up when the "Create new species"-button is pushed. In this window
        the user can create a new species of both herbivore and carnivore. It
        has a lot of private functions in it, that can't be used outside the methos or
        the class.
        """

        frame2 = tk.Toplevel(self)
        label1 = tk.Label(
            frame2,
            text=
            "Welcome to making your own species! Choice your animals attribute below"
        )
        label1.grid(row=0, column=0, columnspan=1, sticky=tk.N)

        def key(event):
            """
            Takes care of key-events.
            """

            if event.widget == entry1:
                self.name = entry1.get()
            if event.widget == entry2:
                self.size = entry2.get()
            if event.widget == entry3:
                self.surv_temp = entry3.get()

        label2 = tk.Label(frame2, text="Name of species")
        label2.grid(row=1, column=0, columnspan=1, sticky=tk.NW)

        entry1 = tk.Entry(frame2)
        entry1.bind("<KeyRelease>", key)
        entry1.grid(row=2, column=0, columnspan=1, sticky=tk.NW)

        label3 = tk.Label(frame2, text="Size (write a number between 1-3000)")
        label3.grid(row=1, column=1, columnspan=1, sticky=tk.NW)

        entry2 = tk.Entry(frame2)
        entry2.bind("<KeyRelease>", key)
        entry2.grid(row=2, column=1, columnspan=1, sticky=tk.NW)

        label7 = tk.Label(
            frame2,
            text=
            "What temprature can it survive in? (write a number between -20 to 40"
        )
        label7.grid(row=3, column=0, columnspan=1, sticky=tk.NW)

        entry3 = tk.Entry(frame2)
        entry3.bind("<KeyRelease>", key)
        entry3.grid(row=4, column=0, columnspan=1, sticky=tk.NW)

        def _get_allergy():
            """
            Returns "bird" if the user want their species to have allergies, which will
            make the species allergic to animals whom's meat type is of bird. If the user
            don't want the species to have this weakness, it returns "nothing".
            """

            if self.my_allergies == True:
                return "bird"
            else:
                return "nothing"

        allergy = property(_get_allergy)

        label5 = tk.Label(frame2,
                          text="Do you want your species to have allergies?")
        label6 = tk.Label(
            frame2,
            text="(only relevant if you choosen Carnivore. if not press No)")
        label5.grid(row=5, column=0, sticky=tk.NW)
        label6.grid(row=6, column=0, sticky=tk.NW)

        radio_value = tk.StringVar()
        radio_value2 = tk.StringVar()
        radio_value.set('Yes')
        radio_value2.set('Yes')

        def radio():
            """
            Writes out the value of the radio-buttons.
            """

            if radio_value.get() == "Yes":
                self.my_allergies = True

            if radio_value.get() == "No":
                self.my_allergies = False

        def radio2():
            """
            Also writes out the value of radio-button but on  a different question.
            """

            if radio_value2.get() == "Yes":
                self.my_allergies = True

            if radio_value2.get() == "No":
                self.my_allergies = False

        radio_button1 = tk.Radiobutton(frame2,
                                       text="Yes",
                                       variable=radio_value,
                                       value="Yes",
                                       command=radio)
        radio_button1.grid(row=7, column=0, sticky=tk.W)

        radio_button2 = tk.Radiobutton(frame2,
                                       text="No",
                                       variable=radio_value,
                                       value="No",
                                       command=radio)
        radio_button2.grid(row=7, column=1, sticky=tk.W)
        radio_button1.select()
        radio_button2.deselect()

        def _get_otherallergies():
            """
            Returns "bird" if the user want other species to have allergies on their
            new species, which will make their meat type "bird" when the species is created.
            """

            if self.others_allergies == True:
                return "bird"
            else:
                return "meat"

        otherallergies = property(_get_otherallergies)

        label6 = tk.Label(
            frame2,
            text=
            "Do you want other species to have allergies against you? (not everone will, but some)"
        )
        label6.grid(row=8, column=0)
        radio_button3 = tk.Radiobutton(frame2,
                                       text="Yes",
                                       variable=radio_value2,
                                       value="Yes",
                                       command=radio2)
        radio_button3.grid(row=9, column=0, sticky=tk.W)

        radio_button4 = tk.Radiobutton(frame2,
                                       text="No",
                                       variable=radio_value2,
                                       value="No",
                                       command=radio2)
        radio_button4.grid(row=10, column=1, sticky=tk.W)

        def herb_or_carn(event):
            """
            Sets the eater_type-attribute into herbivore or carnivore, depending on
            what the user has chosen.
            """

            self.eater_type = option_variable.get()

        label4 = tk.Label(frame2, text="What kind of eater?")
        label4.grid(row=3, column=1, columnspan=1, sticky=tk.NW)

        option_variable = tk.StringVar(frame2)
        option_variable.set("Herbivore")
        option = tk.OptionMenu(frame2,
                               option_variable,
                               "Herbivore",
                               "Carnivore",
                               command=herb_or_carn)
        option.grid(row=4, column=1, columnspan=1, sticky=tk.NW)

        def error_window(error_string):
            """
            Prints out an error message-window if the user written wrong somewhere
            when creating the species.
            """

            frajm = tk.Toplevel()
            label1 = tk.Label(frajm, text="Error message")
            label1.pack()
            label2 = tk.Label(frajm, text=error_string)
            label2.pack()

        def try_to_close_window():
            """
            Checks if the user has written right evertwhere or if it needs to send out
            an error-message. If not, it goes to the method that creates the new species.
            """
            def error_window():
                error_string = ""
                try:
                    int(self.size)
                    if int(self.size) > 3000:
                        error_string += "The size of the creature is to large \n"
                    if int(self.size) < 1:
                        error_string += "The size of the creature is to small \n"
                except:
                    error_string += "Please write a number in size \n"
                try:
                    int(self.surv_temp)
                    if int(self.surv_temp) > 40:
                        error_string += "Please write a smaller number in survival temprature \n"
                    if int(self.surv_temp) < -20:
                        error_string += "Please write a larger number in survival temprature \n"
                except:
                    error_string += "Please write a number in survival temprature \n"
                if error_string != "":
                    error_window(error_string)
                else:
                    close_window()

        def close_window():
            """
            Creates new species from the user's choices and then closes
            the window.
            """

            if self.eater_type == "Carnivore":
                self.sim.user_create_carnivore(self.name,
                                               self.others_allergies,
                                               self.eater_type, self.size, 1,
                                               self.my_allergies,
                                               self.surv_temp)
            elif self.eater_type == "Herbivore":
                self.sim.user_create_herbivore(self.name,
                                               self.others_allergies,
                                               self.eater_type, self.size, 1,
                                               self.my_allergies,
                                               self.surv_temp)

            def yes_on_saving_to_file():
                lst = ""
                file = open("myspecies.txt", "w")
                allergy = str(_get_allergy())

                lst += ("\n" + "Species: " + str(self.name) + "size: " +
                        str(self.size) + ". \n" + "Type of eater: " +
                        str(self.eater_type()) + ". \n" +
                        "Survival temprature: " + str(self.surv_temp()) +
                        "Allergies: " + str(allergy))
                file.write(lst)
                file.close()

            question_frame = tk.Toplevel()
            question_label = tk.Label(
                question_frame,
                text="Do you want to save your new species into a file?")
            question_label.pack()
            yesbutton = tk.Button(question_frame,
                                  text="Yes",
                                  command=yes_on_saving_to_file)
            yesbutton.pack()
            nobutton = tk.Button(question_frame,
                                 text="No",
                                 command=close_window)
            nobutton.pack()
            self.update_window()
            frame2.destroy()

        def reset_changes():
            """
            Resets eveything and closes the window.
            """

            self.name = ""
            self.size = 0
            self.surv_temp = 0
            self.my_allergies = True
            self.others_allergies = True
            self.eater_type = ""
            close_window()

        button3 = tk.Button(frame2,
                            text="return without saving",
                            command=reset_changes)
        button4 = tk.Button(frame2,
                            text="Save and return",
                            command=try_to_close_window)
        button3.grid(row=11, column=0)
        button4.grid(row=11, column=1)
Beispiel #10
0
    def __init__(self, parent, controller):

        # Initialize the Frame
        tk.Frame.__init__(self, parent, bg='#FFCA33')

        # Create new GradeCalculator class
        self.calculator = GradeCalculator()

        # Create boolean variables
        self.can_add_assignments = False
        self.can_calculate_grade = False

        # Create the field that adds new categories
        self.category_name_label = tk.Label(self,
                                            text='Category Name',
                                            font=HEADER_FONT,
                                            bg='#FFCA33')
        self.category_name_label.grid(row=0, column=0)

        self.new_category = tk.StringVar()
        self.category_name_entry = tk.Entry(self,
                                            textvariable=self.new_category,
                                            font=DEFAULT_FONT)
        self.category_name_entry.grid(row=1, column=0)

        self.category_percentage_label = tk.Label(self,
                                                  text='Impact in Percentage',
                                                  font=HEADER_FONT,
                                                  bg='#FFCA33')
        self.category_percentage_label.grid(row=2, column=0)

        self.new_category_percentage = tk.StringVar()
        self.category_percentage_entry = tk.Entry(
            self, textvariable=self.new_category_percentage, font=DEFAULT_FONT)
        self.category_percentage_entry.grid(row=3, column=0)

        self.category_button = tk.Button(
            self,
            text="Add The Category",
            font=DEFAULT_FONT,
            command=(lambda: self._create_new_category(
                self.new_category.get(), self.new_category_percentage.get())))
        self.category_button.grid(row=4, column=0, pady=5)

        # Create category removal capabilities
        self.remove_category_button = tk.Button(
            self,
            text="Remove The Category",
            font=DEFAULT_FONT,
            command=(
                lambda: self._remove_category(self.chosen_category.get())))
        self.remove_category_button.grid(row=5, column=0, pady=5)

        # Create the field that adds new assignments
        self.assignment_name_label = tk.Label(self,
                                              text='Assignment Name',
                                              font=HEADER_FONT,
                                              bg='#FFCA33')
        self.assignment_name_label.grid(row=0, column=1)

        self.new_assignment = tk.StringVar()
        self.assignment_name_entry = tk.Entry(self,
                                              textvariable=self.new_assignment,
                                              font=DEFAULT_FONT)
        self.assignment_name_entry.grid(row=1, column=1)

        self.assignment_score_label = tk.Label(
            self,
            text='Assignment Score (Score/Possible Score)',
            font=HEADER_FONT,
            bg='#FFCA33')
        self.assignment_score_label.grid(row=2, column=1)

        self.new_assignment_score = tk.StringVar()
        self.assignment_score_entry = tk.Entry(
            self, textvariable=self.new_assignment_score, font=DEFAULT_FONT)
        self.assignment_score_entry.grid(row=3, column=1)

        self.chosen_category = tk.StringVar()
        self.chosen_category.set('Choose The Category')
        self.category_chooser = tk.OptionMenu(self, self.chosen_category, '-')
        self.category_chooser.config(font=DEFAULT_FONT)
        self.category_chooser.grid(row=4, column=1, pady=10)

        self.assignment_button = tk.Button(
            self,
            text="Add Assignment",
            font=DEFAULT_FONT,
            command=(lambda: self._create_new_assignment(
                self.chosen_category.get(), self.new_assignment.get(),
                self.new_assignment_score.get())))
        self.assignment_button.grid(row=5, column=1)

        # Create the text box that shows all categories and assignments
        self.class_info = tk.Text(self)
        self.class_info.grid(row=6, column=0, columnspan=2, padx=15, pady=15)
        self.class_info.config(state='disabled', font=DEFAULT_FONT)

        # Create a button that allows the user to go back to the main menu
        self.back_button = tk.Button(
            self,
            text='Back',
            font=DEFAULT_FONT,
            command=(lambda: controller.show_frame(MainMenuPage)))
        self.back_button.grid(row=8, column=0, sticky='w', padx=10)

        # Create a button that allows the user to reset the calculator
        self.reset_button = tk.Button(self,
                                      text='Reset',
                                      font=DEFAULT_FONT,
                                      command=self._reset_calculator)
        self.reset_button.grid(row=8, column=1, sticky='e', padx=10)

        # Create a button that calculates the grade and creates a pop up
        self.calculate_grade_button = tk.Button(
            self,
            text='Calculate grade',
            font=DEFAULT_FONT,
            command=self._calculate_current_grade)
        self.calculate_grade_button.grid(row=7,
                                         column=1,
                                         stick='e',
                                         pady=10,
                                         padx=10)
Beispiel #11
0
    def delete_window(self):
        """
        A method that opens up a new window that pops up when the user push "Delete existing
        species". This method has a lot of private functions that can't be used outside of
        this method.
        """

        frame3 = tk.Toplevel(self)
        textwidg2 = tk.Text(frame3, width=80, height=25)

        def info():
            spec = ""
            for species in self.sim.grass_eaters:
                if species.species not in spec:
                    spec += ("\n" + "Species: " + str(species.get_species()) +
                             ". \n" + "Type of eater: " +
                             str(species.get_eater_type()) + ". \n" +
                             "Survival temprature: " +
                             str(species.get_survival_temprature()) + ". \n" +
                             "DNA:" + str(species.get_dna()) + "\n")

            lst = ""
            for species in self.sim.meat_eaters:
                if species.species not in lst:
                    lst += ("\n" + "Species: " + str(species.get_species()) +
                            ". \n" + "Type of eater: " +
                            str(species.get_eater_type()) + ". \n" +
                            "Survival temprature: " +
                            str(species.get_survival_temprature()) + ". \n" +
                            "DNA:" + str(species.get_dna()[0].get_species()) +
                            "\n")
            infos = (
                "Press on the screen and scroll down to read the information about the species "
                +
                "of this simulation. You can only delete one species at a time."
                + " The animals in this world are: " + str(spec) + str(lst))
            return infos

        textwidg2.insert(tk.END, info())
        textwidg2.grid(row=0, column=0, rowspan=6, columnspan=3, sticky=tk.N)

        def delete_instanses(event):
            """
            Deletes species from the simulation. Only one specie at a time can be deleted.
            """

            self.delete_choice = option_variable3.get()

        def close_window():
            """
            The user's action to delete a species is performed and the main
            window gets updates with how many species there are in the world.
            Then it closes the "Delete existing species"-window.
            """
            self.sim.grass_eaters[:] = [
                species for species in self.sim.grass_eaters
                if species.get_species() != self.delete_choice
            ]
            self.sim.meat_eaters[:] = [
                species for species in self.sim.meat_eaters
                if species.get_species() != self.delete_choice
            ]

            self.update_window()
            frame3.destroy()

        def reset_choice():
            """
            Doesn't save the changes if the user realises that the choices that was
           made was wrong"""

            self.delete_choice = ""
            close_window()

        label7 = tk.Label(
            frame3,
            text="What species do you want to delete from the simulation?")
        label7.grid(row=7, column=0, sticky=tk.N)

        option_variable3 = tk.StringVar(frame3)
        option_variable3.set("Option")
        option = tk.OptionMenu(frame3,
                               option_variable3,
                               "goat",
                               "ostrich",
                               "walking shark",
                               "lama",
                               "kangaroo",
                               "wombat",
                               "black bird",
                               "lion",
                               "snake",
                               "penguin",
                               self.name,
                               command=delete_instanses)
        option.grid(row=8, column=0)

        button3 = tk.Button(frame3,
                            text="Return without saving",
                            command=reset_choice)
        button4 = tk.Button(frame3,
                            text="Save and return",
                            command=close_window)
        button3.grid(row=9, column=0)
        button4.grid(row=9, column=1)
Beispiel #12
0
    def create_statistic(self):
        window_statistic = tk.Toplevel()
        window_statistic.title('歷史統計資料查詢')
        window_statistic.geometry('800x800')

        top_frame = tk.Frame(window_statistic, highlightbackground='white')
        top_frame.pack(side='top')
        top_label = tk.Label(top_frame, text='歷史統計資料查詢')
        top_label.pack(side='top')

        OptionList = [
            "純文字分析",
            "有場分析_時段",
            "有場分析_月",
            "活動分析_時段",
            "活動分析_月",
            "各事件分析_時段",
            "各事件分析_月"
        ] 

        variable = tk.StringVar(window_statistic)
        variable.set(OptionList[0])

        tk.Label(font=('Helvetica', 18), text="歷史查詢事件").pack(side="top")
        opt = tk.OptionMenu(window_statistic, variable, *OptionList)
        opt.config(width=40, font=('Helvetica', 18))
        opt.pack(side="top")

        labelTest = tk.Label(text="", font=('Helvetica', 18), fg='red')
        labelTest.pack(side="top")

        def callback(*args):
                labelTest.configure(text=variable.get())
                if(variable.get()==OptionList[0]):
                    finish.configure(command=create_one)
                elif(variable.get()==OptionList[1]):
                    finish.configure(command=create_two)
                elif(variable.get()==OptionList[2]):
                    finish.configure(command=create_three)
                elif(variable.get()==OptionList[3]):
                    finish.configure(command=create_four)
                elif(variable.get()==OptionList[4]):
                    finish.configure(command=create_five)
                elif(variable.get()==OptionList[5]):
                    finish.configure(command=create_six)
                elif(variable.get()==OptionList[6]):
                    finish.configure(command=create_seven)

        finish = tk.Button(window_statistic, text='完成', width=10, height=1, command=callback, font=('Helvetica', 18))
        finish.pack()

        variable.trace("w", callback)

        def create_two():
            w = tk.Toplevel()
            w.geometry('600x600')
            w.title('result')

            dataList = [None for i in range(3)]

            t_a = tk.Label(w, text="請輸入欲查詢樓層(0,1,3) (如不需篩選則輸入-1):")
            t_a.grid(row=0, column=0)
            dataList[0] = tk.Entry(w,width=30,fg="black")
            dataList[0].grid(row=0, column=1)
            t_b = tk.Label(w, text="請輸入欲查詢年份(2010~2019):")
            t_b.grid(row=1, column=0)
            dataList[1] = tk.Entry(w,width=30,fg="black")
            dataList[1].grid(row=1, column=1)
            t_c = tk.Label(w, text="請輸入欲查詢月份(1~12):")
            t_c.grid(row=2, column=0)
            dataList[2] = tk.Entry(w,width=30,fg="black")
            dataList[2].grid(row=2, column=1)

            def get_result(dataList):
                new_dataList = [None for i in range(3)]
                for i in range(3):
                    new_dataList[i] = int(dataList[i].get())
                PA.Avail_Analysis_Period(new_dataList)
            
            done = tk.Button(w, text='完成', width=10, height=1, font=('Helvetica', 18), command=functools.partial(get_result, dataList))
            done.grid(row=3, column=1)
    
        def create_four():
            w = tk.Toplevel()
            w.geometry('600x600')
            w.title('result')

            dataList = [None for i in range(4)]

            t_a = tk.Label(w, text="請輸入欲查詢事件:")
            t_a.grid(row=0, column=0)
            dataList[0] = tk.Entry(w,width=30,fg="black")
            dataList[0].grid(row=0, column=1)
            t_b = tk.Label(w, text="請輸入欲查詢樓層(0,1,3) (如不需篩選則輸入-1):")
            t_b.grid(row=1, column=0)
            dataList[1] = tk.Entry(w,width=30,fg="black")
            dataList[1].grid(row=1, column=1)
            t_c = tk.Label(w, text="請輸入欲查詢年份(2010~2019):")
            t_c.grid(row=2, column=0)
            dataList[2] = tk.Entry(w,width=30,fg="black")
            dataList[2].grid(row=2, column=1)
            t_d = tk.Label(w, text="請輸入欲查詢月份(1~12):")
            t_d.grid(row=3, column=0)
            dataList[3] = tk.Entry(w,width=30,fg="black")
            dataList[3].grid(row=3, column=1)

            def get_result(dataList):
                new_dataList = [None for i in range(4)]
                for i in range(1, 4):
                    new_dataList[i] = int(dataList[i].get())
                PA.Single_Event_Analysis_Period(new_dataList)
            
            done = tk.Button(w, text='完成', width=10, height=1, font=('Helvetica', 18), command=functools.partial(get_result, dataList))
            done.grid(row=4, column=1)

        def create_six():
            w = tk.Toplevel()
            w.geometry('600x600')
            w.title('result')

            dataList = [None for i in range(3)]

            t_a = tk.Label(w, text="請輸入欲查詢樓層(0,1,3) (如不需篩選則輸入-1):")
            t_a.grid(row=0, column=0)
            dataList[0] = tk.Entry(w,width=30,fg="black")
            dataList[0].grid(row=0, column=1)
            t_b = tk.Label(w, text="請輸入欲查詢星期(1~7):")
            t_b.grid(row=1, column=0)
            dataList[1] = tk.Entry(w,width=30,fg="black")
            dataList[1].grid(row=1, column=1)
            t_c = tk.Label(w, text="請輸入欲查詢時段(8~21):")
            t_c.grid(row=2, column=0)
            dataList[2] = tk.Entry(w,width=30,fg="black")
            dataList[2].grid(row=2, column=1)

            def get_result(dataList):
                new_dataList = [None for i in range(3)]
                for i in range(3):
                    new_dataList[i] = int(dataList[i].get())
                PA.Multi_Event_Analysis_Period(new_dataList)
            
            done = tk.Button(w, text='完成', width=10, height=1, font=('Helvetica', 18), command=functools.partial(get_result, dataList))
            done.grid(row=3, column=1)
Beispiel #13
0
root.geometry("500x500")

v = tk.IntVar()

tk.Label(root, text="Choose Language:").place(relx=0.0,rely=0.0)
tk.Radiobutton(root, text="English",variable=v,value=1).place(relx=0.0,rely=0.05)
tk.Radiobutton(root,text="Kannada",variable=v,value=2).place(relx=0.0,rely=0.1)
tk.Radiobutton(root,text="Hindi",variable=v,value=3).place(relx=0.0,rely=0.15)


tk.Label(root, text="Choose Movie:").place(relx=0.0,rely=0.2)
var1 = tk.IntVar()
tk.Checkbutton(root, text="The Prestige", variable=var1).place(relx=0.0,rely=0.25)
var2 = tk.IntVar()
tk.Checkbutton(root, text="Inception", variable=var2).place(relx=0.25,rely=0.25)
var3 = tk.IntVar()
tk.Checkbutton(root, text="Memento", variable=var3).place(relx=0.5,rely=0.25)



tk.Label(root, text="Choose No. of Tickets:").place(relx=0.0,rely=0.31)
OptionList = ["Select",1,2,3,4,5]
var = tk.StringVar()
var.set(OptionList[0])
opt = tk.OptionMenu(root, var, *OptionList)
opt.place(relx=0.3,rely=0.3)

btn= tk.Button(root, text ="Book Movie", command = submit)
btn.place(relx=0.01,rely=0.38)

root.mainloop()
Beispiel #14
0
    def __init__(self, userid):
        self.userid = userid
        self.root = tk.Tk()
        self.root.title('Manage user')
        self.root.geometry('600x500')

        tk.Label(self.root, text='USERID').grid(row=0,
                                                column=0,
                                                padx=10,
                                                pady=10)
        tk.Label(self.root, text='USER NAME').grid(row=1,
                                                   column=0,
                                                   padx=10,
                                                   pady=10)
        tk.Label(self.root, text='USER TYPE').grid(row=2,
                                                   column=0,
                                                   padx=10,
                                                   pady=10)
        tk.Label(self.root, text='USER STATUS').grid(row=3,
                                                     column=0,
                                                     padx=10,
                                                     pady=10)
        tk.Label(self.root, text='NAME').grid(row=4,
                                              column=0,
                                              padx=10,
                                              pady=10)
        tk.Label(self.root, text='CONTACT').grid(row=5,
                                                 column=0,
                                                 padx=10,
                                                 pady=10)
        tk.Label(self.root, text='ADDRESS').grid(row=6,
                                                 column=0,
                                                 padx=10,
                                                 pady=10)
        tk.Label(self.root, text='EMAIL').grid(row=7,
                                               column=0,
                                               padx=10,
                                               pady=10)
        tk.Label(self.root, text='GENDER').grid(row=8,
                                                column=0,
                                                padx=10,
                                                pady=10)

        self.uid = tk.Entry(self.root)
        self.uid.grid(row=0, column=1)
        self.uname = tk.Entry(self.root)
        self.uname.grid(row=1, column=1)
        self.name = tk.Entry(self.root)
        self.name.grid(row=4, column=1)
        self.ucontact = tk.Entry(self.root)
        self.ucontact.grid(row=5, column=1)
        self.uemail = tk.Entry(self.root)
        self.uemail.grid(row=7, column=1)
        self.uaddress = tk.Text(self.root, height=4, width=15)
        self.uaddress.grid(row=6, column=1)

        self.gender = tk.StringVar()
        self.gender.set('0')
        self.ugm = tk.Radiobutton(self.root,
                                  text='Male',
                                  variable=self.gender,
                                  value='0')
        self.ugm.grid(row=8, column=1)
        self.ugf = tk.Radiobutton(self.root,
                                  text='Female',
                                  variable=self.gender,
                                  value='1')
        self.ugf.grid(row=8, column=2)

        self.status = tk.StringVar()
        self.status.set('0')
        self.usa = tk.Radiobutton(self.root,
                                  text='Active',
                                  variable=self.status,
                                  value='0')
        self.usa.grid(row=3, column=1)
        self.usi = tk.Radiobutton(self.root,
                                  text='Inactive',
                                  variable=self.status,
                                  value='1')
        self.usi.grid(row=3, column=2)

        self.type = tk.StringVar()
        self.type.set('Admin')
        self.utype = tk.OptionMenu(self.root, self.type, 'Admin', 'User')
        self.utype.grid(row=2, column=1)

        self.f = tk.Button(self.root,
                           text='First',
                           width=15,
                           command=self.clk_first)
        self.f.grid(row=9, column=0, padx=10, pady=10)
        self.p = tk.Button(self.root,
                           text='Previous',
                           width=15,
                           command=self.clk_previous)
        self.p.grid(row=9, column=1, padx=10, pady=10)
        self.n = tk.Button(self.root,
                           text='Next',
                           width=15,
                           command=self.clk_next)
        self.n.grid(row=9, column=2, padx=10, pady=10)
        self.l = tk.Button(self.root,
                           text='Last',
                           width=15,
                           command=self.clk_last)
        self.l.grid(row=9, column=3, padx=10, pady=10)
        self.a = tk.Button(self.root,
                           text='Add',
                           width=15,
                           command=self.clk_add)
        self.a.grid(row=10, column=0, padx=10, pady=10)
        self.e = tk.Button(self.root,
                           text='Edit',
                           width=15,
                           command=self.clk_edit)
        self.e.grid(row=10, column=1, padx=10, pady=10)
        self.s = tk.Button(self.root,
                           text='Save',
                           width=15,
                           command=self.clk_save)
        self.s.grid(row=10, column=2, padx=10, pady=10)
        self.c = tk.Button(self.root,
                           text='Cancel',
                           width=15,
                           command=self.clk_cancel)
        self.c.grid(row=10, column=3, padx=10, pady=10)

        self.userlist = UMS_services.view()
        self.curr_index = 0
        self.addeditflag = 'view'
        self.s.config(state='disabled')
        self.showRecord()
        self.root.mainloop()
Beispiel #15
0
def get_settings():
    """
    Generates a GUI to collect basic generation settings.
    Sets default values for any entries that are not filled.
    """

    menu = tk.Tk()
    tk_rgb = "#%02x%02x%02x" % (128, 192, 200)
    menu.title('Mandelbrot Settings')
    menu.configure(background=tk_rgb)

    def start_gen(gen_settings, color_option, status_label):
        arguments = [500, 500, -2.0, 1.0, -1.5, 1.5]
        # Argument Order: width, height, minx, maxx, miny, maxy
        if color_option.get() != "": 
            generate.color_code = color_option.get()
        for i, setting in enumerate(gen_settings):
            value = setting.get()
            try:
                value = float(setting.get())
                arguments[i] = value
            except ValueError:
                print("Invalid input, supplying default value of ", arguments[i])
        status_label.configure(text='Calculating...')
        menu.update_idletasks()
        calculate.find_points(*arguments)
        menu.destroy()
        pg_window(int(arguments[0]), int(arguments[1]))

    width_label = tk.Label(menu, text='Window Width', background=tk_rgb)
    width_field = tk.Entry(menu)
    height_label = tk.Label(menu, text='Window Height', background=tk_rgb)
    height_field = tk.Entry(menu)
    color_value = tk.StringVar(menu)
    color_codes = {"Really Random", "Random", "Purple Pop", "Fractal Flames"}
    for var in dir(user_schemes):
        if not var.startswith('__'):
            color_codes.add(var)
    color_label = tk.Label(menu, text='Color Scheme', background=tk_rgb)
    color_options = tk.OptionMenu(menu, color_value, *color_codes)
    minx_label = tk.Label(menu, text='Min X', background=tk_rgb)
    minx_field = tk.Entry(menu)
    maxx_label = tk.Label(menu, text='Max X', background=tk_rgb)
    maxx_field = tk.Entry(menu)
    miny_label = tk.Label(menu, text='Min Y', background=tk_rgb)
    miny_field = tk.Entry(menu)
    maxy_label = tk.Label(menu, text='Max Y', background=tk_rgb)
    maxy_field = tk.Entry(menu)

    entries = [width_field, height_field, minx_field, maxx_field,
        miny_field, maxy_field]

    generate_status = tk.Label(menu, text='Waiting...', background=tk_rgb)
    generate_button = tk.Button(menu, text='Generate Set', 
                                command=lambda: start_gen(entries, color_value, generate_status))

    # TODO: Find less stupid way to do this
    width_label.grid(row=1, column=0)
    width_field.grid(row=1, column=1, columnspan=2)
    height_label.grid(row=2, column=0)
    height_field.grid(row=2, column=1, columnspan=2)
    color_label.grid(row=3, column=0)
    color_options.grid(row=3, column=1, columnspan=2)
    minx_label.grid(row=4, column=0)
    minx_field.grid(row=4, column=1, columnspan=2)
    maxx_label.grid(row=5, column=0)
    maxx_field.grid(row=5, column=1, columnspan=2)
    miny_label.grid(row=6, column=0)
    miny_field.grid(row=6, column=1, columnspan=2)
    maxy_label.grid(row=7, column=0)
    maxy_field.grid(row=7, column=1, columnspan=2)
    generate_status.grid(row=8, column=0)
    generate_button.grid(row=8, column=1)

    menu.mainloop()
Beispiel #16
0
    def createWidgets(self):

        global all_news
        count = str(len(all_news))

        f1 = tkFont.Font(size=12, family="Courier New")
        f2 = tkFont.Font(size=16, family="Berlin Sans FB Demi")

        #使用者輸入變數
        self.head = tk.Label(self, text="股價新聞小幫手", height=2, width=20,
                             font=f2)  #執行完的text會變成 "共搜尋到" + count + "篇相關新聞"
        self.askforid = tk.Label(self,
                                 text="請輸入股價代碼:",
                                 height=1,
                                 width=15,
                                 font=f1)
        self.idInput = tk.Text(self, height=1, width=5, font=f1)

        self.askfortime = tk.Label(self,
                                   text="請輸入時間範圍(格式:2019/6/17)",
                                   height=1,
                                   width=25,
                                   font=1)
        self.startInput = tk.Text(self, height=1, width=5, font=f1)
        self.endInput = tk.Text(self, height=1, width=5, font=f1)
        self.run = tk.Button(self,
                             text="執行",
                             height=1,
                             width=5,
                             command=self.run,
                             font=f1)

        self.head.grid(row=0, column=0, columnspan=6, sticky=tk.NE + tk.SW)
        self.askforid.grid(row=1, column=0, sticky=tk.NE + tk.SW)
        self.idInput.grid(row=1, column=1, sticky=tk.NE + tk.SW)
        self.askfortime.grid(row=1, column=2, sticky=tk.NE + tk.SW)
        self.startInput.grid(row=1, column=3, sticky=tk.NE + tk.SW)
        self.endInput.grid(row=1, column=4, sticky=tk.NE + tk.SW)
        self.run.grid(row=1, column=5, sticky=tk.NW)

        #製作下拉式表單,選擇第__筆~第__筆新聞
        lst1 = ['第1~5筆', '第6~10筆', '第11~15筆', '第16~20筆', '第21~25筆', '第26~30筆']
        var1 = tk.StringVar()
        self.list = tk.OptionMenu(self, var1, *lst1)
        self.list.config(height=1, width=10, font=f1)
        self.btnconfir = tk.Button(self,
                                   text='確認',
                                   height=1,
                                   width=5,
                                   command=self.shownewstitle,
                                   font=f1)

        #右邊的標題列&選擇要讀哪一篇
        self.shownews_1 = tk.Label(self,
                                   relief="solid",
                                   justify="left",
                                   height=2,
                                   width=60,
                                   font=f1)
        self.shownews_2 = tk.Label(self,
                                   relief="solid",
                                   justify="left",
                                   height=2,
                                   width=60,
                                   font=f1)
        self.shownews_3 = tk.Label(self,
                                   relief="solid",
                                   justify="left",
                                   height=2,
                                   width=60,
                                   font=f1)
        self.shownews_4 = tk.Label(self,
                                   relief="solid",
                                   justify="left",
                                   height=2,
                                   width=60,
                                   font=f1)
        self.shownews_5 = tk.Label(self,
                                   relief="solid",
                                   justify="left",
                                   height=2,
                                   width=60,
                                   font=f1)

        self.btn1 = tk.Button(self,
                              text='點選',
                              height=1,
                              width=5,
                              command=self.clickBtnNews1,
                              font=f1)
        self.btn2 = tk.Button(self,
                              text='點選',
                              height=1,
                              width=5,
                              command=self.clickBtnNews2,
                              font=f1)
        self.btn3 = tk.Button(self,
                              text='點選',
                              height=1,
                              width=5,
                              command=self.clickBtnNews3,
                              font=f1)
        self.btn4 = tk.Button(self,
                              text='點選',
                              height=1,
                              width=5,
                              command=self.clickBtnNews4,
                              font=f1)
        self.btn5 = tk.Button(self,
                              text='點選',
                              height=1,
                              width=5,
                              command=self.clickBtnNews5,
                              font=f1)

        self.btnconfir.grid(row=2, column=4, sticky=tk.NW)
        self.list.grid(row=2, column=3, sticky=tk.NE)

        self.shownews_1.grid(row=3, column=3, columnspan=2, sticky=tk.NE)
        self.shownews_2.grid(row=4, column=3, columnspan=2, sticky=tk.NE)
        self.shownews_3.grid(row=5, column=3, columnspan=2, sticky=tk.NE)
        self.shownews_4.grid(row=6, column=3, columnspan=2, sticky=tk.NE)
        self.shownews_5.grid(row=7, column=3, columnspan=2, sticky=tk.NE)

        self.btn1.grid(row=3, column=5, sticky=tk.NW)
        self.btn2.grid(row=4, column=5, sticky=tk.NW)
        self.btn3.grid(row=5, column=5, sticky=tk.NW)
        self.btn4.grid(row=6, column=5, sticky=tk.NW)
        self.btn5.grid(row=7, column=5, sticky=tk.NW)

        #在最底下顯示全文內容
        self.show = tk.Message(self,
                               text="",
                               anchor=tk.NW,
                               justify="left",
                               width=1200,
                               padx=3,
                               pady=2,
                               font=f1)
        self.show.grid(row=13, column=0, columnspan=6, sticky=tk.NW)
Beispiel #17
0
ellipseRadiusAFromText = tk.Label(text="Начальное а:")
ellipseRadiusBFromText = tk.Label(text="Начальное b:")
ellipseRadiusAStepText = tk.Label(text="Шаг a:")
ellipseRadiusBStepText = tk.Label(text="Шаг b:")
ellipseRadiusNumText = tk.Label(text="Количество эллписов:")

ellipseRadiusAText = tk.Label(text="A:")
ellipseRadiusBText = tk.Label(text="B:")

drawEllipseButton = tk.Button(text="Нарисовать", command=drawEllipse)
ellipseRangeButton = tk.Button(text="Нарисовать \nмножество эллипсов",
                               command=rangeDrawEllipse)
#

drawingMethod = tk.StringVar()
colorDrawing = tk.StringVar()
drawingMethod.set("Библиотечный")
colorDrawing.set("Черный")
methodMenu = tk.OptionMenu(root, drawingMethod, "Библиотечный",
                           "Каноническое уравнение",
                           "Параметрическое уравнение", "Брезенхем",
                           "Метод средней точки")
colorMenu = tk.OptionMenu(root, colorDrawing, "Черный", "Синий", "Красный",
                          "Зеленый", "Белый")
x, y = normalToTkInter(XSAFE, YSAFE - 240)
methodMenu.place(x=x, y=y)
colorMenu.place(x=x, y=y + 30)
tk.Button(text="Очитстить", command=clearCanvasField).place(x=x, y=y + 60)

root.mainloop()
Beispiel #18
0
"jalgaon.jn",
"Bhusawal.jn"
]
To= [
"pachora.jn",
"jalgaon.jn",
"Bhusawal.jn"
]

variable1 = tk.StringVar(window)
variable1.set(From[0])

lbl = tk.Label(window, text="select station",width=20  ,height=2 ,bg="#8c8c8c" ,font=('times', 9, ' bold ') )
lbl.place(x=5, y=200)

opt = tk.OptionMenu(window, variable1, *From)
opt.config(width=20, font=('Helvetica', 12))
opt.place(x=240, y=200)

lbl2 = tk.Label(window, text="Going To",width=20 ,bg="#8c8c8c"    ,height=2 ,font=('times', 9, ' bold '))
lbl2.place(x=550, y=200)
variable2 = tk.StringVar(window)
variable2.set(To[0])

opt = tk.OptionMenu(window, variable2, *To)
opt.config(width=20, font=('Helvetica', 12))
opt.place(x=790, y=200)



lbl3= tk.Label(window, text="Name",width=30 ,bg="#8c8c8c"    ,height=2 ,font=('times', 9, ' bold '))
Beispiel #19
0
    def create_widgets(self):
        self.directory_selection_frame = tk.Frame(self)

        self.refresh_directories_button = tk.Button(
            master=self.directory_selection_frame,
            text="Refresh",
            width=BUTTON_WIDTH,
            command=self.refresh_directories)

        self.new_name_textbox = tk.Text(master=self.directory_selection_frame,
                                        height=1,
                                        width=22)
        self.new_name_textbox.bind("<<Modified>>", self.new_name_modified)

        self.new_name_button = tk.Button(master=self.directory_selection_frame,
                                         text="Create",
                                         width=BUTTON_WIDTH,
                                         command=self.create_server_directory)

        self.quit_button = tk.Button(master=self.directory_selection_frame,
                                     text="Quit",
                                     width=BUTTON_WIDTH,
                                     command=self.master.destroy)

        self.directories_list = tk.Listbox(
            master=self.directory_selection_frame,
            selectmode=tk.SINGLE,
            listvariable=self.directories_prop,
        )
        self.directories_list.bind('<<ListboxSelect>>', self.dir_selected)

        self.directory_operations_frame = tk.Frame(self)
        self.config_frame = tk.Frame(self.directory_operations_frame)
        self.config_operations_frame = tk.Frame(self.config_frame)

        self.config_load_button = tk.Button(
            master=self.config_operations_frame,
            text="Load",
            width=BUTTON_WIDTH,
            state=tk.DISABLED,
            command=self.load_config)

        self.config_save_button = tk.Button(
            master=self.config_operations_frame,
            text="Save",
            width=BUTTON_WIDTH,
            state=tk.DISABLED,
            command=self.save_config)

        self.config_editor_textbox = tk.Text(master=self.config_frame,
                                             width=80,
                                             height=40,
                                             state=tk.DISABLED)

        self.config_editor_version = tk.Text(master=self.config_frame,
                                             width=20,
                                             height=1,
                                             state=tk.DISABLED)

        self.port_textbox = tk.Text(master=self.directory_operations_frame,
                                    height=1,
                                    width=20)
        self.port_textbox.insert("1.0", self.port)
        self.port_textbox.bind("<<Modified>>", self.port_modified)

        self.selected_version.set(self.default_version)
        other_values = [x for x in self.versions if x != self.default_version]
        self.versions_list = tk.OptionMenu(self.directory_operations_frame,
                                           self.selected_version,
                                           self.selected_version.get(),
                                           *other_values)

        self.directory_start_button = tk.Button(
            master=self.directory_operations_frame,
            text="START!",
            width=BUTTON_WIDTH * 2,
            state=tk.DISABLED,
            command=self.start)
Beispiel #20
0
# scrolled text box used to display the serial data
frame = tk.Frame(root, bg='cyan')
frame.pack(side="bottom", fill='both', expand='no')
textbox = tkscrolledtext.ScrolledText(master=frame, wrap='word', width=180, height=28) #width=characters, height=lines
textbox.pack(side='bottom', fill='y', expand=True, padx=0, pady=0)
textbox.config(font="bold")

#COM Port label
label_comport = Label(root,width=12,height=2,text="Serial Port:")
label_comport.place(x=10,y=26)
label_comport.config(font="bold")

tkvar = StringVar(root)
tkvar.set(' ')
comport_combobox =  tk.OptionMenu(root, tkvar, *portlist, command=set_port)
comport_combobox.place(x=100,y=26)

canvas1 = Canvas(root, height=25, width=25)
led = canvas1.create_oval(5,5,20,20, fill=ledcolor)
canvas1.pack()


# Register the callback above with the serial port object
serialPort.RegisterReceiveCallback(OnReceiveSerialData)

def sdterm_main():
    if serialPort.IsOpen() :
        ledcolor = 'green'
    else:
        ledcolor = 'red'
Beispiel #21
0
from tkinter import *
import tkinter as tk

win = Tk()

var = tk.StringVar()
set1 = tk.OptionMenu(win, var, "DO", "Le")
set1.config(font=("Arial", 25))
set1.grid(row=1, column=0)

win.mainloop()
Beispiel #22
0
    #make single gaussian fit a function then call that many times for the other thing, set the lower and uppwer bounds to the cenrter +- the smear


text_size = 10
text_font = "Helvetica"

root.title('PPP')
root.state('zoomed')

x = 1500
y = 900

option_menu_title = tk.StringVar()
option_menu_title.set(CSV_files[0])
option_menu = tk.OptionMenu(root, option_menu_title, *CSV_files)
option_menu.place(x=x - 100, y=y, width=350, height=40)

Load_Button = tk.Button(root,
                        state=tk.NORMAL,
                        text='Load',
                        command=lambda: Load_CSV(
                            (Load_Button, option_menu),
                            (most_recent_coords_l, saved_recent_coords_l,
                             Add_Button, Single_Peak_Mode_Only_CB)),
                        font=(text_font, text_size))
Load_Button.place(x=x + 250, y=y + 2, height=36, width=58)

x = 1300
y = 300
    def __init__(self, image_annotations):
        """
            Give a VideoAnnotations object as argument
        """

        self.annotator = image_annotations

        # A root window for displaying objects
        super().__init__()

        # keep track how many elements are added to the main grid
        self._main_grid_rows = 0
        self._drawing = False
        self._original_click_pos = (0, 0)

        ################################## header ##################################

        # Header info labels
        self.info_parent = tkinter.Label(self)
        self.info_parent.pack(fill=tkinter.X, pady=5, padx=20)

        self.info_labels = [
            UpdateLabel(self.info_parent, 'Class: ', 'active_annotation_class',
                        self.annotator),
            UpdateLabel(self.info_parent, 'Object id: ',
                        'active_annotation_object_id', self.annotator),
            UpdateLabel(self.info_parent, 'Image count', 'frame_count',
                        self.annotator),
            UpdateLabel(self.info_parent, 'Current Image', 'current_frame',
                        self.annotator)
        ]

        for ind, label in enumerate(self.info_labels):
            label.pack(side=tkinter.LEFT, padx=5)

        self.current_object_text_var = tkinter.StringVar()
        self.current_object_text_var.set('Text: ')
        self.current_object_text_label = tkinter.Label(
            self.info_parent, textvariable=self.current_object_text_var)
        self.current_object_text_label.pack(side=tkinter.LEFT, padx=5)

        ################################## class and object optionmenus  ##################################

        self.menu_parent = tkinter.Label(self)

        # add an active annotation class widget
        self.class_string = tkinter.StringVar()
        self.class_string.set(self.annotator.active_annotation_class)
        self.annotator_class_select_widget = tkinter.OptionMenu(
            self.menu_parent,
            self.class_string,
            *self.annotator.annotation_classes,
            command=self.annotator_class_selection_callback)
        self.annotator_class_select_widget.pack(side=tkinter.LEFT, padx=10)
        self.annotator_class_select_widget.config(width=40)

        # add an active annotation object widget
        self.obj_string = tkinter.IntVar()
        self.obj_string.set(self.annotator.active_annotation_object_id)
        logger.debug(
            f"current_frame_objects: {self.annotator.current_frame_object_ids}"
        )
        self.annotator_obj_select_widget = tkinter.OptionMenu(
            self.menu_parent,
            self.obj_string,
            *self.annotator.current_frame_object_ids,
            command=self.annotator_object_selection_callback)
        self.annotator_obj_select_widget.pack(side=tkinter.LEFT, padx=10)
        self.annotator_obj_select_widget.config(width=20)

        self.menu_parent.pack(fill=tkinter.X)

        ################################## image ##################################

        # Video viewing frame
        self.image_area = tkinter.Canvas(self)
        self.image_area.pack(fill=tkinter.X)

        ################################## footer ##################################

        # buttons
        self.button_parent = tkinter.Label(self)
        self.button_parent.pack(fill=tkinter.X, pady=5, padx=20)

        self.buttons = [
            tkinter.Button(self.button_parent,
                           text="Next frame (a)",
                           command=self.next_frame),
            tkinter.Button(self.button_parent,
                           text="Previous frame (d)",
                           command=self.prev_frame),
            tkinter.Button(self.button_parent,
                           text="Mark annotation (m)",
                           command=self.mark_annotation),
            tkinter.Button(self.button_parent,
                           text="Save annotations",
                           command=self.save_annotations),
            tkinter.Button(self.button_parent,
                           text="Add text (t)",
                           command=self.request_active_object_text)
        ]

        # order buttons
        for ind, but in enumerate(self.buttons):
            but.pack(side=tkinter.LEFT, padx=5)

        self._current_frame = self.annotator.read_new_frame()
        self.on_gui_update()

        # bind events
        self.bind_events()

        # Start the GUI
        self.mainloop()
Beispiel #24
0
    def __init__(self, master, controller, **kw):
        super().__init__(master=master, **kw)
        self.controller = controller

        #liste option menù
        sexoption = ["M", "F", "ND"]

        smokopt = ["MAI FUMATO", "NON FUMA", "10", "20", "20+"]
        smokstorico = ["NON FUMA", "AUMENTATO", "RIDOTTO", "STAZIONARIO"]
        alcoolopt = ["NO", "SI"]
        alcoolunit = ["NON BEVE", "0,5", "1", "2", "3", "3+"]
        sport = ["NO", "SI"]
        spofr = [
            "NO/OCCASIONALMENTE", "1 VOLTA A SETTIMANA", "2 VOLTE A SETTIMANA",
            "3 VOLTE A SETTIMANA", "4 VOLTE A SETTIMANA"
        ]
        tera = ["NO", "SI"]
        cole = [
            "MAI/OCCASIONALMETE", "1 VOLTA ALL'ANNO", "1 VOLTA OGNI DUE ANNI"
        ]
        screen = [
            "NO/OCCASIONALE", "OGNI 2 ANNI", "1 VOLTA ALL'ANNO",
            "2 VOLTE ALL'ANNO"
        ]
        tipos = [
            "SANGUE OCCULTO", "PSA", "PAP TEST", "MAMMOGRAFIA",
            "CONTROLLO NEI", "ALTRO"
        ]

        title = tk.Label(self,
                         text="Modifica dipendente",
                         fg="black",
                         bg="white",
                         font="Helvetica 20")
        title.place(x=20, y=20)

        title1 = tk.Label(self, text="Nome", fg="black", bg="white")
        title1.place(x=20, y=60)

        e1 = tk.Entry(self)
        e1.place(x=190, y=60)

        title2 = tk.Label(self, text="Cognome", fg="black", bg="white")
        title2.place(x=20, y=90)

        e2 = tk.Entry(self)
        e2.place(x=190, y=90)

        title3 = tk.Label(self, text="Sesso", fg="black", bg="white")
        title3.place(x=20, y=120)

        var = tk.StringVar(self)
        var.set(sexoption[0])

        opt = tk.OptionMenu(self, var, *sexoption)
        opt.config(width=17, font=('Helvetica', 10))
        opt.place(x=190, y=120)

        title4 = tk.Label(self, text="Età", fg="black", bg="white")
        title4.place(x=20, y=150)

        e4 = tk.Entry(self)
        e4.place(x=190, y=150)

        title5 = tk.Label(self, text="Altezza", fg="black", bg="white")
        title5.place(x=20, y=210)

        e5 = tk.Entry(self)
        e5.place(x=190, y=210)

        title6 = tk.Label(self, text="Peso", fg="black", bg="white")
        title6.place(x=20, y=240)

        e6 = tk.Entry(self)
        e6.place(x=190, y=240)

        title7 = tk.Label(self, text="Pressione Min", fg="black", bg="white")
        title7.place(x=20, y=270)

        e7 = tk.Entry(self)
        e7.place(x=190, y=270)

        title8 = tk.Label(self, text="Pressione Max", fg="black", bg="white")
        title8.place(x=20, y=300)

        e8 = tk.Entry(self)
        e8.place(x=190, y=300)

        title9 = tk.Label(self,
                          text="Terapia pressione",
                          fg="black",
                          bg="white")
        title9.place(x=20, y=330)

        var1 = tk.StringVar(self)
        var1.set(tera[0])

        opt1 = tk.OptionMenu(self, var1, *tera)
        opt1.config(width=17, font=('Helvetica', 10))
        opt1.place(x=190, y=330)

        #Fumo
        title10 = tk.Label(self, text="Fumo", fg="black", bg="white")
        title10.place(x=20, y=360)

        var2 = tk.StringVar(self)
        var2.set(smokopt[0])

        opt2 = tk.OptionMenu(self, var2, *smokopt)
        opt2.config(width=17, font=('Helvetica', 10))
        opt2.place(x=190, y=360)

        #Fumo storico
        title11 = tk.Label(self, text="Fumo storico", fg="black", bg="white")
        title11.place(x=20, y=390)

        var3 = tk.StringVar(self)
        var3.set(smokstorico[0])

        opt3 = tk.OptionMenu(self, var3, *smokstorico)
        opt3.config(width=17, font=('Helvetica', 10))
        opt3.place(x=190, y=390)

        #Alcool
        title12 = tk.Label(self, text="Alcool", fg="black", bg="white")
        title12.place(x=20, y=420)

        var4 = tk.StringVar(self)
        var4.set(alcoolopt[0])

        opt4 = tk.OptionMenu(self, var4, *alcoolopt)
        opt4.config(width=17, font=('Helvetica', 10))
        opt4.place(x=190, y=420)

        #Alcool unita
        title13 = tk.Label(self, text="Alcool unità", fg="black", bg="white")
        title13.place(x=20, y=450)

        var5 = tk.StringVar(self)
        var5.set(alcoolunit[0])

        opt5 = tk.OptionMenu(self, var5, *alcoolunit)
        opt5.config(width=17, font=('Helvetica', 10))
        opt5.place(x=190, y=450)

        #Sport
        title14 = tk.Label(self, text="Sport", fg="black", bg="white")
        title14.place(x=380, y=60)

        var6 = tk.StringVar(self)
        var6.set(sport[0])

        opt6 = tk.OptionMenu(self, var6, *sport)
        opt6.config(width=22, font=('Helvetica', 8))
        opt6.place(x=530, y=60)

        #Frequenza sport
        title15 = tk.Label(self,
                           text="Frequenza sport",
                           fg="black",
                           bg="white")
        title15.place(x=380, y=90)

        var7 = tk.StringVar(self)
        var7.set(spofr[0])

        opt7 = tk.OptionMenu(self, var7, *spofr)
        opt7.config(width=22, font=('Helvetica', 8))
        opt7.place(x=530, y=90)

        #Colesterolo
        title16 = tk.Label(self, text="Colesterolo", fg="black", bg="white")
        title16.place(x=380, y=120)

        var8 = tk.StringVar(self)
        var8.set(cole[0])

        opt8 = tk.OptionMenu(self, var8, *cole)
        opt8.config(width=22, font=('Helvetica', 8))
        opt8.place(x=530, y=120)

        #Screening
        title17 = tk.Label(self, text="Screening", fg="black", bg="white")
        title17.place(x=380, y=150)

        var9 = tk.StringVar(self)
        var9.set(screen[0])

        opt9 = tk.OptionMenu(self, var9, *screen)
        opt9.config(width=22, font=('Helvetica', 8))
        opt9.place(x=530, y=150)

        title18 = tk.Label(self,
                           text="Tipologia screening",
                           fg="black",
                           bg="white")
        title18.place(x=380, y=180)

        var10 = tk.StringVar(self)
        var10.set(tipos[0])

        opt10 = tk.OptionMenu(self, var10, *tipos)
        opt10.config(width=22, font=('Helvetica', 8))
        opt10.place(x=530, y=180)

        button = tk.Button(self, text="Conferma modifica")
        button.place(x=550, y=440)
Beispiel #25
0
    def __effect_dialog(self):
        self.title("Effect")
        #params: id, index, name, r, s, eff, mode, text
        if isinstance(self.data, int):
            self.is_new = True
            self.data = (self.data, -1, "", 0, 0, "",
                         TM_remove_mode.get_default(), "")
        else:
            self.data = (self.data[0], self.data[1], self.data[2],
                         self.data[3], self.data[4], self.data[5],
                         TM_remove_mode.get_options()[self.data[6].value],
                         self.data[7])

        def block_entries(event=None):
            if TM_remove_mode.needs_rounds(mode.get()):
                rounds_entry.config(state=tk.NORMAL)
            else:
                rounds_entry.config(state=tk.DISABLED)

            if TM_remove_mode.needs_stacks(mode.get()):
                stacks_entry.config(state=tk.NORMAL)
            else:
                stacks_entry.config(state=tk.DISABLED)

            if TM_remove_mode.needs_dialog(mode.get()):
                dialog_entry.config(state=tk.NORMAL)
            else:
                dialog_entry.config(state=tk.DISABLED)

        def save():
            if name.get() and mode.get() and effects.get():
                if (not TM_remove_mode.needs_rounds(mode.get()) or rounds.get() > 0) and \
                   (not TM_remove_mode.needs_stacks(mode.get()) or stacks.get() > 0) and \
                   (not TM_remove_mode.needs_dialog(mode.get()) or dialog_text.get()):
                    if not TM_remove_mode.needs_rounds(mode.get()):
                        rounds.set(-1)
                    if not TM_remove_mode.needs_stacks(mode.get()):
                        stacks.set(-1)
                    if not TM_remove_mode.needs_dialog(mode.get()):
                        dialog_text.set("")
                    self.__accept_dialog(
                        (self.data[0], self.data[1], name.get(), rounds.get(),
                         stacks.get(), effects.get(),
                         TM_remove_mode.parse(mode.get()), dialog_text.get()))

        name = tk.StringVar(value=self.data[2])
        mode = tk.StringVar(value=self.data[6])
        rounds = tk.IntVar(value=self.data[3])
        stacks = tk.IntVar(value=self.data[4])
        effects = tk.StringVar(value=self.data[5])
        dialog_text = tk.StringVar(value=self.data[7])

        self.geometry("450x230")
        rounds_entry = tk.Entry(self,
                                textvariable=rounds,
                                width=ROUNDS_STATS_DELTA_ENTRY_WIDTH)
        stacks_entry = tk.Entry(self,
                                textvariable=stacks,
                                width=ROUNDS_STATS_DELTA_ENTRY_WIDTH)
        dialog_entry = tk.Entry(self,
                                textvariable=dialog_text,
                                width=EFFECT_DESCRIPTION_WIDTH)
        block_entries()

        tk.Label(self, text="Name").place(x=10, y=10)
        tk.Entry(self, textvariable=name).place(x=100, y=10)
        tk.Label(self, text="Mode").place(x=10, y=40)
        tk.OptionMenu(self,
                      mode,
                      *(TM_remove_mode.get_options()),
                      command=block_entries).place(x=100, y=35)
        tk.Label(self, text="Rounds").place(x=10, y=70)
        rounds_entry.place(x=60, y=70)
        tk.Label(self, text="Stacks").place(x=100, y=70)
        stacks_entry.place(x=150, y=70)
        tk.Label(self, text="Effect").place(x=10, y=100)
        tk.Entry(self, textvariable=effects,
                 width=EFFECT_DESCRIPTION_WIDTH).place(x=100, y=100)
        tk.Label(self, text="Dialog text").place(x=10, y=130)
        dialog_entry.place(x=100, y=130)
        tk.Label(
            self,
            text=
            "Hint: to instert current rounds/stack number in effect or dialog use character "
            + TM_effect.DESCRIPTION_REPLACE_WITH_ROUNDS_SIGN + '/' +
            TM_effect.DESCRIPTION_REPLACE_WITH_STACK_SIGN).place(x=10, y=160)
        tk.Button(self, text="Save", command=save).place(x=250, y=190)
        tk.Button(self, text="Cancel",
                  command=self.__reject_dialog).place(x=300, y=190)
    def __init__(self,
                 data,
                 slicename,
                 graphtype,
                 xvariable=None,
                 yvariablelist=None,
                 xsize=1280,
                 ysize=720):
        """__init__ constructor for PlotterWindow class

        Args:
            data (Pandas Dataframe): Dataframe used to create the plots
            slicename (string): name of column used to get slicekeys
            graphtype (string): graph type used to plot data. options = (standard)

            xvariable (string): name of column used as x variable in plot. Default None
            yvariablelist (list of strings): name/s of column/s used as y variable/s in plot. Max 3 entries. Default None
            xsize (int): Define width of tk window. Default 1280
            ysize (int): Define height of tk window Default 720
        """

        #attributes
        self.xsize = xsize
        self.ysize = ysize
        self.data = data
        self.xvariable = xvariable
        self.yvariablelist = yvariablelist
        self.graphtype = graphtype
        self.slicename = slicename

        #create the tk window
        self.window = tk.Tk()

        #stringvar for graphmenu
        self.currentslicekey = tk.StringVar()

        #get slicekeys from slicename column
        self.slicekeys = sorted((self.data[self.slicename].unique()))

        #Create frame in self.window for graphmenu and graphnamelabel
        self.graphmenuframe = tk.Frame(self.window)

        #create graphmenu and label
        self.graphmenu = tk.OptionMenu(
            self.graphmenuframe,
            self.currentslicekey,
            *self.slicekeys,
            command=lambda x: self._ongraphmenuchange())

        self.graphnamelabel = tk.Label(self.graphmenuframe, text="Pi=")
        #pack graphmenu and label
        self.graphnamelabel.pack(side=tk.LEFT)
        self.graphmenu.pack(side=tk.LEFT)
        #pack graphmenuframe
        self.graphmenuframe.pack()

        #create Figure and canvas
        self.figure = Figure()
        self.canvas = FigureCanvasTkAgg(self.figure, self.window)

        #add toolbar to canvas
        self.toolbar = NavigationToolbar2Tk(self.canvas, self.window)

        #pack canvas in self.window
        self.canvas.get_tk_widget().pack(side=tk.BOTTOM,
                                         fill=tk.BOTH,
                                         expand=True)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        #set window size
        self.window.geometry(str(self.xsize) + "x" + str(self.ysize))

        #call instance of DataPlotter
        self.plotter = DataPlotter(self.figure)
Beispiel #27
0
def explore_init():
    explore_page = tk.Tk()
    explore_page.wm_state('zoomed')

    explore_page.title('COVID-19 Research At a Glance')
    width, height = explore_page.winfo_screenwidth(
    ), explore_page.winfo_screenheight()
    explore_page.geometry('%dx%d+0+0' % (width, height))
    explore_page.configure(bg=bg_color)

    exframe = tk.Frame(explore_page)
    exframe.grid(column=0, row=0, sticky=('N', 'W', 'E', 'S'))
    exframe.configure(bg=bg_color)

    # Add home button
    home_b = tk.Button(exframe,
                       text="Home",
                       command=lambda: landing_load(explore_page))
    home_b.grid(row=1, column=3, sticky='E')

    # Query entry
    query_str = tk.StringVar(explore_page)
    query_e = tk.Entry(exframe,
                       textvariable=query_str,
                       width=50,
                       font=("Helvetica", 18))
    query_e.grid(row=1, column=2, sticky="W")

    # Dropdown search type
    search_type = tk.StringVar(explore_page)
    search_options = ['title', 'authors', 'publish_time', 'journal', 'keyword']
    search_type.set(search_options[0])
    search_d = tk.OptionMenu(exframe, search_type, *search_options)
    search_d.grid(row=2, column=1)

    # Table
    table = ttk.Treeview(exframe,
                         columns=('title', 'authors', 'publish_time',
                                  'journal', 'keyword'),
                         show='headings')
    for header in search_options:
        table.heading(header, text=header)
    ttk.Style().configure('Treeview', rowheight=30)

    def summary_info(event):
        df = find(table.item(
            table.selection()[0])['values'][0])  # grab csv entry
        l = df.values.tolist()[0]
        top = tk.Toplevel()
        top.wm_state('zoomed')
        top.title("About This Article")

        topframe = tk.Frame(top)
        topframe.grid(column=0, row=0, sticky=('N', 'W', 'E', 'S'))
        topframe.columnconfigure(2, weight=1)
        topframe.rowconfigure(9, weight=1)
        source_x = l[1]
        title = l[2]
        doi = l[3]
        abstract = l[4]
        publish_time = l[5]
        authors = l[6]
        journal = l[7]
        url = l[10]

        title_m = tk.Label(topframe, text="Title: " + title)
        title_m.grid(row=1, column=1)
        authors_m = tk.Label(topframe, text="Author(s): " + authors)
        authors_m.grid(row=2, column=1)
        publish_time_m = tk.Label(topframe, text="Published: " + publish_time)
        publish_time_m.grid(row=3, column=1)
        journal_m = tk.Label(topframe, text="Journal " + journal)
        journal_m.grid(row=4, column=1)
        source_x_m = tk.Label(topframe, text="Source: " + source_x)
        source_x_m.grid(row=5, column=1)
        doi_m = tk.Label(topframe, text="DOI: " + doi)
        doi_m.grid(row=6, column=1)
        # abstract_m = tk.Label(topframe, text="Abstract: " + abstract)
        # abstract_m.grid(row=7, column=1)
        url_m = tk.Label(topframe, text="URL: " + url)
        url_m.grid(row=8, column=1)

        close = tk.Button(top, text="Close", command=top.destroy)
        close.grid()
        top.mainloop()

    table.bind("<Double-1>", summary_info)

    # Search
    def search_callback(*args):
        table.delete(*table.get_children())
        df = search(search_type.get(), query_str.get())
        for index, x in df.iterrows():
            table.insert("", "end", values=(x[2], x[6], x[5], x[7]))
        table.grid(row=2, column=2)

    table.grid(row=2, column=2, columnspan=2, sticky='W')
    search_b = tk.Button(exframe, text="Search", command=search_callback)
    search_b.grid(row=1, column=2, sticky='E')

    # Run main loop
    explore_page.mainloop()
    def rotor_and_reflector_selection_controls(self):
        """Create dropdown menus for selecting rotors and reflector."""

        available = (md.ROTOR_I,
                     md.ROTOR_II,
                     md.ROTOR_III,
                     md.ROTOR_IV,
                     md.ROTOR_V,
                     md.ROTOR_VI,
                     md.ROTOR_VII,
                     md.ROTOR_VIII,
                     md.ROTOR_BETA,
                     md.ROTOR_GAMMA,
                     md.UKW_A,
                     md.UKW_B,
                     md.UKW_C,
                     md.UKW_B_THIN,
                     md.UKW_C_THIN)
        equipment = {r[2]: r for r in available}
        self.select_rotor = []
        self.rotor_vars = []

        # Help function for selecting rotors
        def change_rotor(i):
            """Return a function to place a new rotor at position i."""
            def f(*args):
                rp = self.gui.machine.box.rotors[i].ring_position
                wl = self.gui.machine.box.rotors[i].window_letter
                self.gui.machine.rotor_set[i] = equipment[
                                                    self.rotor_vars[i].get()
                                                    ]
                self.gui.machine.box.rotors[i] = Rotor(
                    self.gui.machine.box,
                    self.gui.machine.rotor_set[i],
                    rp, wl
                    )
                self.gui.box_int.update_all()
            return f

        # Create dropdown menus for selecting rotors
        self.rotor_label = tk.Label(self, text='Select rotors:',
                                    bg=DEFAULT_COLOR_SCHEME['global_bg'])
        self.rotor_label.grid(row=0, column=0, columnspan=3, sticky=tk.W)
        for i in range(len(self.gui.machine.box.rotors)):
            self.rotor_vars.append(tk.StringVar())
            self.rotor_vars[i].set(self.gui.machine.rotor_set[i][2])
            self.select_rotor.append(tk.OptionMenu(
                self,
                self.rotor_vars[i],
                *equipment.keys()
                ))
            self.select_rotor[i].configure(bg=DEFAULT_COLOR_SCHEME[
                                                'global_bg'
                                                ])
            self.select_rotor[i].grid(row=1, column=i*3, columnspan=3,
                                      sticky=tk.W+tk.E)
            self.rotor_vars[i].trace('w', callback=change_rotor(i))

        # Help function for selecting reflector
        def change_reflector(*args):
            self.gui.machine.reflector = equipment[self.reflector_var.get()]
            self.gui.machine.box.reflector = Reflector(
                self.gui.machine.box,
                self.gui.machine.reflector
                )
            self.gui.box_int.update_all()

        # Create dropdown menu for selecting reflector
        self.reflector_label = tk.Label(self, text='Select reflector:',
                                        bg=DEFAULT_COLOR_SCHEME['global_bg'])
        self.reflector_label.grid(row=5, column=0, columnspan=3, sticky=tk.W)
        self.reflector_var = tk.StringVar()
        self.reflector_var.set(self.gui.machine.reflector[2])
        self.select_reflector = tk.OptionMenu(
            self,
            self.reflector_var,
            *equipment.keys()
            )
        self.select_reflector.configure(bg=DEFAULT_COLOR_SCHEME['global_bg'])
        self.select_reflector.grid(row=6, column=0, columnspan=3,
                                   sticky=tk.W+tk.E)
        self.reflector_var.trace('w', callback=change_reflector)
Beispiel #29
0
    def _createwidgets(self):
        u"""Erstellt alle Widgets."""
        self.master.wm_title(_("RevPi Python PLC program"))
        self.master.wm_resizable(width=False, height=False)

        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        cpad = {"padx": 4, "pady": 2}
        # cpade = {"padx": 4, "pady": 2, "sticky": "e"}
        cpadw = {"padx": 4, "pady": 2, "sticky": "w"}
        # cpadwe = {"padx": 4, "pady": 2, "sticky": "we"}

        # Gruppe Programm
        prog = tkinter.LabelFrame(self)
        prog.columnconfigure(0, weight=1)
        prog["text"] = _("PLC python program")
        prog.grid(columnspan=2, pady=2, sticky="we")

        # Variablen vorbereiten
        self.var_picdown = tkinter.BooleanVar(prog)
        self.var_picup = tkinter.BooleanVar(prog)
        self.var_cleanup = tkinter.BooleanVar(prog)
        self.var_typedown = tkinter.StringVar(prog)
        self.var_typeup = tkinter.StringVar(prog)

        self.lst_typedown = [_("Files"), _("Zip archive"), _("TGZ archive")]
        self.lst_typeup = [
            _("Files"), _("Folder"), _("Zip archive"), _("TGZ archive")
        ]
        self.var_picdown.set(self.opt.get("picdown", False))
        self.var_picup.set(self.opt.get("picup", False))

        # Gespeicherte Werte übernehmen
        saved_val = self.opt.get("typedown", self.lst_typedown[0])
        self.var_typedown.set(
            saved_val if saved_val in self.lst_typedown else _("Files")
        )
        saved_val = self.opt.get("typeup", self.lst_typeup[0])
        self.var_typeup.set(
            saved_val if saved_val in self.lst_typeup else _("Files")
        )

        r = 0
        lbl = tkinter.Label(prog)
        lbl["text"] = _("Download PLC program as:")
        lbl.grid(column=0, row=r, **cpadw)
        opt = tkinter.OptionMenu(
            prog, self.var_typedown, command=self._evt_optdown,
            *self.lst_typedown
        )
        opt["width"] = 10
        opt.grid(column=1, row=r, **cpad)

        r = 1
        self.ckb_picdown = tkinter.Checkbutton(prog)
        self.ckb_picdown["text"] = _("include piCtory configuration")
        self.ckb_picdown["variable"] = self.var_picdown
        self.ckb_picdown.grid(column=0, row=r, **cpadw)

        btn = tkinter.Button(prog)
        btn["command"] = self.plcdownload
        btn["text"] = _("Download")
        btn.grid(column=1, row=r, **cpad)

        r = 2
        lbl = tkinter.Label(prog)
        lbl["text"] = _("Upload PLC program as:")
        lbl.grid(column=0, row=r, **cpadw)

        opt = tkinter.OptionMenu(
            prog, self.var_typeup, command=self._evt_optup,
            *self.lst_typeup
        )
        opt["state"] = self.xmlstate
        opt["width"] = 10
        opt.grid(column=1, row=r, **cpad)

        r = 3
        ckb = tkinter.Checkbutton(prog)
        ckb["state"] = self.xmlstate
        ckb["text"] = _("clean upload folder before upload")
        ckb["variable"] = self.var_cleanup
        ckb.grid(column=0, row=r, columnspan=2, **cpadw)

        r = 4
        self.ckb_picup = tkinter.Checkbutton(prog)
        self.ckb_picup["state"] = self.xmlstate
        self.ckb_picup["text"] = _("includes piCtory configuration")
        self.ckb_picup["variable"] = self.var_picup
        self.ckb_picup.grid(column=0, row=r, **cpadw)

        btn = tkinter.Button(prog)
        btn["command"] = self.plcupload
        btn["state"] = self.xmlstate
        btn["text"] = _("Upload")
        btn.grid(column=1, row=r, **cpad)

        # Gruppe piCtory
        picto = tkinter.LabelFrame(self)
        picto.columnconfigure(0, weight=1)
        picto["text"] = _("piCtory configuration")
        picto.grid(columnspan=2, pady=2, sticky="we")

        lbl = tkinter.Label(picto)
        lbl["text"] = _("Download piCtory configuration")
        lbl.grid(column=0, row=0, **cpadw)

        btn = tkinter.Button(picto)
        btn["command"] = self.getpictoryrsc
        btn["text"] = _("Download")
        btn.grid(column=1, row=0, **cpad)

        lbl = tkinter.Label(picto)
        lbl["text"] = _("Upload piCtory configuration")
        lbl.grid(column=0, row=1, **cpadw)

        btn = tkinter.Button(picto)
        btn["command"] = self.setpictoryrsc
        btn["state"] = self.xmlstate
        btn["text"] = _("Upload")
        btn.grid(column=1, row=1, **cpad)

        # Gruppe ProcImg
        proc = tkinter.LabelFrame(self)
        proc.columnconfigure(0, weight=1)
        proc["text"] = _("piControl0 process image")
        proc.grid(columnspan=2, pady=2, sticky="we")

        lbl = tkinter.Label(proc)
        lbl["text"] = _("Download process image dump")
        lbl.grid(column=0, row=0, **cpadw)

        btn = tkinter.Button(proc)
        btn["command"] = self.getprocimg
        btn["text"] = _("Download")
        btn.grid(column=1, row=0, **cpad)

        # Gruppe piControlReset
        picon = tkinter.LabelFrame(self)
        picon.columnconfigure(0, weight=1)
        picon["text"] = _("Reset piControl")
        picon.grid(columnspan=2, pady=2, sticky="we")

        lbl = tkinter.Label(picon)
        lbl["text"] = _("Execute piControlReset")
        lbl.grid(column=0, row=0, **cpadw)

        btn = tkinter.Button(picon)
        btn["command"] = self.picontrolreset
        btn["text"] = _("execute")
        btn.grid(column=1, row=0, **cpad)

        # Beendenbutton
        btn = tkinter.Button(self)
        btn["command"] = self._checkclose
        btn["text"] = _("Exit")
        btn.grid()
    def start(self):

        firebase = fb.FirebaseApplication("https://proyectopython2020a-d2866.firebaseio.com/", None)
        resultados_consulta = firebase.get('/proyectopython2020a-d2866/Usuario', '')
        flag_credenciales = False
        for documento in resultados_consulta:
            usuario = resultados_consulta[documento]
            if(documento == self.codigo_documento):
                self.nombre_usuario_var = usuario['nombre_usuario']
                self.correo = usuario['correo']
                self.fecha_nacimiento_usuario = usuario['fecha_nacimiento']
                self.pais_usuario = usuario['pais']

        familia_fuente = "Cambria"
        tamanio_fuente = 12
        color_botones = "#A74B94"
        color_ventana = "#4C2B64"
        color_titulo_principal = "#0F0D3E"
        color_texto = "#D8D5F4"

        ventana = tkinter.Tk()
        ventana.geometry("460x400")
        ventana.title("Perfil")
        ventana.resizable(False,False)
        ventana.config(background = color_ventana)
        self.center(ventana)

        titulo_principal = tkinter.Label(ventana, text="Wing Gundam Zero || Perfil", font=(familia_fuente,15), bg=color_titulo_principal, fg=color_texto)
        titulo_principal.pack(fill = tkinter.X)

        advertencia = tkinter.StringVar()
        label_advertencia = tkinter.Label(ventana, textvariable=advertencia, bg=color_ventana, fg="yellow")
        label_advertencia.pack()

        label_nombre_usuario = tkinter.Label(ventana, text="Nombre de Usuario: ", font=(familia_fuente,tamanio_fuente), bg=color_ventana, fg=color_texto)
        label_nombre_usuario.place(x = 30, y = 70)

        label_correo_electronico = tkinter.Label(ventana, text="Correo Electronico: ", font=(familia_fuente,tamanio_fuente), bg=color_ventana, fg=color_texto)
        label_correo_electronico.place(x = 30, y = 120)

        label_fecha_nacimiento = tkinter.Label(ventana, text="Fecha de Nacimiento: ", font=(familia_fuente,tamanio_fuente), bg=color_ventana, fg=color_texto)
        label_fecha_nacimiento.place(x = 30, y = 170)

        label_pais = tkinter.Label(ventana, text="Pais: ", font=(familia_fuente,tamanio_fuente), bg=color_ventana, fg=color_texto)
        label_pais.place(x = 30, y = 220)

        nombre_usuario = tkinter.StringVar()
        nombre_usuario.set(self.nombre_usuario_var)
        correo_electronico = tkinter.StringVar()
        correo_electronico.set(self.correo)
        fecha_nacimiento = tkinter.StringVar()
        fecha_nacimiento.set(self.fecha_nacimiento_usuario)
        pais = tkinter.StringVar()
        pais.set(self.pais_usuario)
        lista_paises = ["Afganistan", "Albania", "Alemania", "Andorra", "Angola", "Antigua y Barbuda", "Arabia Saudita", "Argelia", "Argentina", "Armenia", "Australia", "Austria", "Azerbaiyan", "Bahamas", "Banglades", "Barbados", "Barein", "Belgica", "Belice", "Benin", "Bielorrusia", "Birmania", "Bolivia", "Botsuana", "Brasil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Butan", "Cabo Verde", "Camboya", "Camerun", "Canada", "Catar", "Chad", "Chile", "China", "Chipre", "Ciudad del Vaticano", "Colombia", "Comoras", "Corea del Norte", "Corea del Sur", "Costa de Marfil", "Costa Rica", "Croacia", "Cuba", "Dinamarca", "Dominica", "Ecuador", "Egipto", "El Salvador", "Emiratos Arabes Unidos", "Eritrea", "Eslovaquia", "Eslovenia", "España", "Estados Unidos", "Estonia", "Etiopía", "Filipinas", "Finlandia", "Fiyi", "Francia", "Gabón", "Gambia", "Georgia", "Ghana", "Granada", "Grecia", "Guatemala", "Guyana", "Guinea", "Haiti", "Honduras", "Hungria", "India", "Indonesia", "Irak", "Iran", "Irlanda", "Islandia", "Isla de los Piratas", "Israel", "Italia", "Jamaica", "Japon", "Jordania", "Kazajistan", "Kenia", "Kirguistan", "Kiribati", "Kuwait", "Laos", "Lesoto", "Letonia", "Libano", "Liberia", "Libia", "Liechtenstein", "Lituania", "Luxemburgo", "Macedonia del Norte", "Madagascar", "Malasia", "Malaui", "Maldivas", "Mali", "Malta", "Marruecos", "Mauricio", "Mauritania", "Mexico", "Micronesia", "Moldavia", "Mordor", "Monaco", "Mongolia", "Montenegro", "Mozambique", "Namibia", "Nauru", "Nepal", "Nicaragua", "Níger", "Nigeria", "Noruega", "Nueva Zelanda", "Oman", "Paises Bajos", "Pakistan", "Palaos", "Panama", "Papua Nueva Guinea", "Paraguay", "Peru", "Polonia", "Portugal", "Reino Unido", "Republica Dominicana", "Ruanda", "Rumania", "Rusia", "Samoa", "San Marino", "Santa Lucia", "Senegal", "Serbia", "Seychelles", "Sierra Leona", "Singapur", "Siria", "Somalia", "Suazilandia", "Sudáfrica", "Sudán", "Sudán del Sur", "Suecia", "Suiza", "Surinam", "Tailandia", "Tanzania", "Takoshima", "Timor Oriental", "Togo", "Tonga", "Trinidad y Tobago", "Tunez", "Turkmenistán", "Turquía", "Tuvalu", "Ucrania", "Uganda", "Uruguay", "Uzbekistán", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Yibuti", "Zambia", "Zimbabue"]
        

        entry_nombre_usuario = tkinter.Entry(ventana, textvariable=nombre_usuario, width="30")
        nombre_usuario.trace("w", lambda *args: self.limitador(nombre_usuario, 10))
        entry_nombre_usuario.place(x = 250, y = 70)
        

        entry_correo_electronico = tkinter.Entry(ventana, textvariable=correo_electronico, width="30")
        entry_correo_electronico.place(x = 250, y = 120)
        

        entry_fecha_nacimiento = tkinter.Entry(ventana, textvariable=fecha_nacimiento, width="30")
        fecha_nacimiento.trace("w", lambda *args: self.limitador(fecha_nacimiento, 10))
        entry_fecha_nacimiento.place(x = 250, y = 170)
        
        options_paises = tkinter.OptionMenu(ventana, pais, *lista_paises)
        options_paises.place(x = 250, y = 220)

        boton_cerrar = tkinter.Button(ventana, text="Cerrar", font=(familia_fuente,tamanio_fuente), width="19", bg="#A74B94", fg=color_texto, command = lambda: self.cerrar(ventana))
        boton_cerrar.place(x = 30, y = 280)

        boton_actualizar = tkinter.Button(ventana, text="Actualizar Datos", font=(familia_fuente,tamanio_fuente), width="19", bg=color_botones, fg=color_texto, command = lambda: self.actualizar(nombre_usuario.get(), correo_electronico.get(), fecha_nacimiento.get(), pais.get(), advertencia, ventana))
        boton_actualizar.place(x = 250, y = 280)

        ventana.mainloop()