Python tkinter.Button() Examples

The following are 30 code examples of tkinter.Button(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter , or try the search function .
Example #1
Source File: window.py    From LPHK with GNU General Public License v3.0 8 votes vote down vote up
def popup(self, window, title, image, text, button_text, end_command=None):
        popup = tk.Toplevel(window)
        popup.resizable(False, False)
        if MAIN_ICON != None:
            if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
                dummy = None
                #popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
            else:
                popup.iconbitmap(MAIN_ICON)
        popup.wm_title(title)
        popup.tkraise(window)

        def run_end():
            popup.destroy()
            if end_command != None:
                end_command()

        picture_label = tk.Label(popup, image=image)
        picture_label.photo = image
        picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
        tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, padx=10, pady=10)
        tk.Button(popup, text=button_text, command=run_end).grid(column=1, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
Example #2
Source File: viewer.py    From networkx_viewer with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, main_window, msg='Please enter a node:'):
        tk.Toplevel.__init__(self)
        self.main_window = main_window
        self.title('Node Entry')
        self.geometry('170x160')
        self.rowconfigure(3, weight=1)

        tk.Label(self, text=msg).grid(row=0, column=0, columnspan=2,
                                      sticky='NESW',padx=5,pady=5)
        self.posibilities = [d['dataG_id'] for n,d in
                    main_window.canvas.dispG.nodes_iter(data=True)]
        self.entry = AutocompleteEntry(self.posibilities, self)
        self.entry.bind('<Return>', lambda e: self.destroy(), add='+')
        self.entry.grid(row=1, column=0, columnspan=2, sticky='NESW',padx=5,pady=5)

        tk.Button(self, text='Ok', command=self.destroy).grid(
            row=3, column=0, sticky='ESW',padx=5,pady=5)
        tk.Button(self, text='Cancel', command=self.cancel).grid(
            row=3, column=1, sticky='ESW',padx=5,pady=5)

        # Make modal
        self.winfo_toplevel().wait_window(self) 
Example #3
Source File: toolkit.py    From PickTrue with MIT License 6 votes vote down vote up
def __init__(self, master=None, store_name=None, **kwargs):
        super(FileBrowse, self).__init__(master=master, **kwargs)
        self.label_text = tk.StringVar()
        btn = tk.Button(self, text="下载到", command=self.choose_file)
        btn.pack(
            side=tk.LEFT,
        )

        tk.Label(self, textvariable=self.label_text).pack(
            side=tk.LEFT,
            fill=tk.X,
        )
        self.pack(fill=tk.X)

        self._store_name = store_name
        if store_name is not None:
            self._config = config_store
            save_path = self._config.op_read_path(store_name) or get_working_dir()
        else:
            self._config = None
            save_path = get_working_dir()

        self.label_text.set(
            save_path
        ) 
Example #4
Source File: lineSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 6 votes vote down vote up
def addLine(self, settingsList, dpsFrame):
        lineNumber = len(settingsList)
        settingsList.append({"transitionValue": "", "color": "#FFFFFF"})
        settingsList[lineNumber]["transitionValue"] = tk.StringVar()
        settingsList[lineNumber]["transitionValue"].set(str(100*lineNumber))
              
        removeButton = tk.Button(dpsFrame, text="X", command=lambda:self.removeLine(lineNumber, settingsList, dpsFrame))
        font = tkFont.Font(font=removeButton['font'])
        font.config(weight='bold')
        removeButton['font'] = font
        removeButton.grid(row=lineNumber, column="0")
        lineLabel = tk.Label(dpsFrame, text="Threshold when the line changes color:")
        lineLabel.grid(row=lineNumber, column="1")
        initialThreshold = tk.Entry(dpsFrame, textvariable=settingsList[lineNumber]["transitionValue"], width=10)
        initialThreshold.grid(row=lineNumber, column="2")
        initialLabel = tk.Label(dpsFrame, text="Color:")
        initialLabel.grid(row=lineNumber, column="3")
        colorButton = tk.Button(dpsFrame, text="    ", 
                                command=lambda:self.colorWindow(settingsList[lineNumber], colorButton), 
                                bg=settingsList[lineNumber]["color"])
        colorButton.grid(row=lineNumber, column="4") 
Example #5
Source File: ch1-6.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self):
        super().__init__()
        self.title("Hello Tkinter")
        self.label_text = tk.StringVar()
        self.label_text.set("My Name Is: ")

        self.name_text = tk.StringVar()

        self.label = tk.Label(self, textvar=self.label_text)
        self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=10)

        self.name_entry = tk.Entry(self, textvar=self.name_text)
        self.name_entry.pack(fill=tk.BOTH, expand=1, padx=20, pady=20)

        hello_button = tk.Button(self, text="Say Hello", command=self.say_hello)
        hello_button.pack(side=tk.LEFT, padx=(20, 0), pady=(0, 20))

        goodbye_button = tk.Button(self, text="Say Goodbye", command=self.say_goodbye)
        goodbye_button.pack(side=tk.RIGHT, padx=(0, 20), pady=(0, 20)) 
Example #6
Source File: components.py    From SEM with MIT License 6 votes vote down vote up
def __init__(self, root, main_window, button_opt):
        ttk.Frame.__init__(self, root)
        
        self.root = root
        self.main_window = main_window
        self.current_files = None
        self.button_opt = button_opt
        
        # define options for opening or saving a file
        self.file_opt = options = {}
        options['defaultextension'] = '.txt'
        options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
        options['initialdir'] = os.path.expanduser("~")
        options['parent'] = root
        options['title'] = 'Select files to annotate.'
        
        self.file_selector_button = ttk.Button(self.root, text=u"select file(s)", command=self.filenames)
        self.label = ttk.Label(self.root, text=u"selected file(s):")
        self.fa_search = tkinter.PhotoImage(file=os.path.join(self.main_window.resource_dir, "images", "fa_search_24_24.gif"))
        self.file_selector_button.config(image=self.fa_search, compound=tkinter.LEFT)
        
        self.scrollbar = ttk.Scrollbar(self.root)
        self.selected_files = tkinter.Listbox(self.root, yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.selected_files.yview) 
Example #7
Source File: ch4.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self):
        super().__init__()
        self.title("Blackjack")
        self.geometry("800x640")
        self.resizable(False, False)

        self.bottom_frame = tk.Frame(self, width=800, height=140, bg="red")
        self.bottom_frame.pack_propagate(0)

        self.hit_button = tk.Button(self.bottom_frame, text="Hit", width=25, command=self.hit)
        self.stick_button = tk.Button(self.bottom_frame, text="Stick", width=25, command=self.stick)

        self.next_round_button = tk.Button(self.bottom_frame, text="Next Round", width=25, command=self.next_round)
        self.quit_button = tk.Button(self.bottom_frame, text="Quit", width=25, command=self.destroy)

        self.new_game_button = tk.Button(self.bottom_frame, text="New Game", width=25, command=self.new_game)

        self.bottom_frame.pack(side=tk.BOTTOM, fill=tk.X)

        self.game_screen = GameScreen(self, bg="white", width=800, height=500)
        self.game_screen.pack(side=tk.LEFT, anchor=tk.N)
        self.game_screen.setup_opening_animation() 
Example #8
Source File: downloader.py    From PickTrue with MIT License 6 votes vote down vote up
def build_buttons(self):
        btn_args = dict(
            height=1,
        )
        btn_group = tk.Frame(self)

        buttons = [
            tk.Button(
                btn_group,
                text=text,
                command=command,
                **btn_args
            )
            for text, command in (
                ("开始下载", self.start_download),
                ("停止下载", self.stop_download),
                ("打开下载文件夹", self.open_download_folder),
            )
        ]

        for index, btn in enumerate(buttons):
            btn.grid(column=index, row=0, sticky=tk.N)

        btn_group.pack(fill=tk.BOTH, expand=1)
        return btn_group 
Example #9
Source File: downloader.py    From PickTrue with MIT License 6 votes vote down vote up
def build_buttons(self):
        btn_args = dict(
            height=1,
        )
        btn_group = tk.Frame(self)

        buttons = [
            tk.Button(
                btn_group,
                text=text,
                command=command,
                **btn_args
            )
            for text, command in (
                ("开始下载", self.start_download),
                ("停止下载", self.stop_download),
                ("打开下载文件夹", self.open_download_folder),
            )
        ]

        for index, btn in enumerate(buttons):
            btn.grid(column=index, row=0, sticky=tk.N)

        btn_group.pack(fill=tk.BOTH, expand=1)
        return btn_group 
Example #10
Source File: Emotion Recognition.py    From Emotion-Recognition-Using-SVMs with MIT License 6 votes vote down vote up
def record_result(self, smile=True):
        print "Image", self.index + 1, ":", "Happy" if smile is True else "Sad"
        self.results[str(self.index)] = smile



# ===================================
# Callback function for the buttons
# ===================================
## smileCallback()              : Gets called when "Happy" Button is pressed
## noSmileCallback()            : Gets called when "Sad" Button is pressed
## updateImageCount()           : Displays the number of images processed
## displayFace()                : Gets called internally by either of the button presses
## displayBarGraph(isBarGraph)  : computes the bar graph after classification is completed 100%
## _begin()                     : Resets the Dataset & Starts from the beginning
## _quit()                      : Quits the Application
## printAndSaveResult()         : Save and print the classification result
## loadResult()                 : Loading the previously stored classification result
## run_once(m)                  : Decorator to allow functions to run only once 
Example #11
Source File: client.py    From The-chat-room with MIT License 6 votes vote down vote up
def video_invite_window(message, inviter_name):
    invite_window = tkinter.Toplevel()
    invite_window.geometry('300x100')
    invite_window.title('Invitation')
    label1 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text=inviter_name)
    label1.pack()
    label2 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text='invites you to video chat!')
    label2.pack()

    def accept_invite():
        invite_window.destroy()
        video_accept(message[message.index('INVITE') + 6:])

    def refuse_invite():
        invite_window.destroy()

    Refuse = tkinter.Button(invite_window, text="Refuse", command=refuse_invite)
    Refuse.place(x=60, y=60, width=60, height=25)
    Accept = tkinter.Button(invite_window, text="Accept", command=accept_invite)
    Accept.place(x=180, y=60, width=60, height=25) 
Example #12
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 6 votes vote down vote up
def create_inputs(self):
    settings = list(self.camera.settings_dict.keys())
    settings.sort(key=lambda e: str(type(self.camera.settings[e].limits)))
    self.scales = {}
    self.radios = {}
    self.checks = {}
    i = 0
    for i,k in enumerate(settings):
      s = self.camera.settings[k]
      if type(s.limits) == tuple:
        self.create_scale(s,i)
      elif type(s.limits) == bool:
        self.create_check(s,i)
      elif type(s.limits) == dict:
        self.create_radio(s,i)
    self.lower_frame = tk.Frame()
    self.lower_frame.grid(column=1,row=i+3)
    self.apply_button = tk.Button(self.lower_frame,text="Apply",
                                  command=self.apply_settings)
    self.apply_button.pack()
    #self.apply_button.grid(column=1,row=i+3) 
Example #13
Source File: client-test2.py    From The-chat-room with MIT License 6 votes vote down vote up
def video_invite_window(message, inviter_name):
    invite_window = tkinter.Toplevel()
    invite_window.geometry('300x100')
    invite_window.title('Invitation')
    label1 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text=inviter_name)
    label1.pack()
    label2 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text='invites you to video chat!')
    label2.pack()

    def accept_invite():
        invite_window.destroy()
        video_accept(message[message.index('INVITE') + 6:])

    def refuse_invite():
        invite_window.destroy()

    Refuse = tkinter.Button(invite_window, text="Refuse", command=refuse_invite)
    Refuse.place(x=60, y=60, width=60, height=25)
    Accept = tkinter.Button(invite_window, text="Accept", command=accept_invite)
    Accept.place(x=180, y=60, width=60, height=25) 
Example #14
Source File: base.py    From mentalist with MIT License 6 votes vote down vote up
def add_attr(self, attr_name, right_label_text=None, *args):
        '''Add attr to the lower frame with a '-' button & title
        
        attr_name: title to be shown on the left side
        right_label_text: label string to be shown on the right side, which is
                          a word count or 'Calculating...'
        '''
        if len(self.attrs) == 0:
            self.lower_frame = Frame(self)
            self.lower_frame.pack(side="bottom", fill="both")
        attr = LabeledFrame(self.lower_frame, title=attr_name)
        btn_add_file = Tk.Button(attr, text=' - ')
        btn_add_file.pack(fill="both", side="left", padx=10, pady=5)
        btn_add_file.bind("<ButtonRelease-1>", partial(self.on_remove_attr, attr))
        lb_base_files = Tk.Label(attr, text=attr_name)
        lb_base_files.pack(fill="both", side="left", padx=10, pady=10)
        
        if right_label_text is not None:
            attr.right_label = Tk.Label(attr, text=right_label_text, font=('Helvetica', '10', 'italic'))
            attr.right_label.pack(fill="both", side="right", padx=10, pady=10)
        else:
            attr.right_label = None
        
        attr.pack(side="top", fill="both")
        self.attrs.append(attr) 
Example #15
Source File: tk.py    From Jtyoui with MIT License 6 votes vote down vote up
def ui():
    root = tkinter.Tk()
    root.title('PDF和照片互转器')  # 标题
    root.resizable(width=False, height=False)  # 防止大小调整
    canvas = tkinter.Canvas(root, width=450, height=320, highlightthickness=0)  # 创建画布
    photo = tkinter.PhotoImage(file=file_zip_path + os.sep + 'pdf.png')  # 获取背景图片的网络连接
    canvas.create_image(225, 160, image=photo)

    select_dir_button = tkinter.Button(root, text="选择照片文件夹", command=select_dir, bg='yellow')  # 创建按钮
    select_pdf_button = tkinter.Button(root, text="选择PDF文件", command=select_pdf, bg='green')
    click_button = tkinter.Button(root, text="点击执行", command=start, bg='blue')

    select_dir_button.pack()  # 启动按钮
    select_pdf_button.pack()
    click_button.pack()

    canvas.create_window(240, 120, width=100, height=30, window=select_dir_button)  # 将按钮创建到画布
    canvas.create_window(240, 190, width=100, height=30, window=select_pdf_button)
    canvas.create_window(240, 260, width=100, height=30, window=click_button)
    canvas.pack()  # 启动画布
    root.mainloop()  # 主程序循环 
Example #16
Source File: workflowcreator.py    From CEASIOMpy with Apache License 2.0 6 votes vote down vote up
def __init__(self, master=None, **kwargs):

        tk.Frame.__init__(self, master, **kwargs)
        self.pack(fill=tk.BOTH)

        self.Options = WorkflowOptions()

        space_label = tk.Label(self, text=' ')
        space_label.grid(column=0, row=0)

        # Input CPACS file
        self.label = tk.Label(self, text='  Input CPACS file')
        self.label.grid(column=0, row=1)

        self.path_var = tk.StringVar()
        self.path_var.set(self.Options.cpacs_path)
        value_entry = tk.Entry(self, textvariable=self.path_var, width= 45)
        value_entry.grid(column=1, row=1)

        self.browse_button = tk.Button(self, text="Browse", command=self._browse_file)
        self.browse_button.grid(column=2, row=1, pady=5)

        # Notebook for tabs
        self.tabs = ttk.Notebook(self)
        self.tabs.grid(column=0, row=2, columnspan=3,padx=10,pady=10)

        self.TabPre = Tab(self, 'Pre')
        self.TabOptim = Tab(self, 'Optim')
        self.TabPost = Tab(self, 'Post')

        self.tabs.add(self.TabPre, text=self.TabPre.name)
        self.tabs.add(self.TabOptim, text=self.TabOptim.name)
        self.tabs.add(self.TabPost, text=self.TabPost.name)

        # General buttons
        self.close_button = tk.Button(self, text='Save & Quit', command=self._save_quit)
        self.close_button.grid(column=2, row=3) 
Example #17
Source File: arduino_basics.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def create_widgets(self, **kwargs):
    """
    Widgets shown:
    - an Input text, to enter what to write on serial port.
    - a submit label, to show previous command submitted.
    - a submit button.
    """

    self.input_txt = tk.Entry(self,
                              width=self.total_width * 5 / 10,
                              font=tkFont.Font(
                                size=kwargs.get("fontsize", 13)))
    self.submit_label = tk.Label(self, text='',
                                 width=1,
                                 font=tkFont.Font(
                                   size=kwargs.get("fontsize", 13)))
    self.submit_button = tk.Button(self,
                                   text='Submit',
                                   command=self.update_widgets,
                                   width=int(self.total_width * 0.5 / 10),
                                   font=tkFont.Font(
                                     size=kwargs.get("fontsize", 13)))

    self.input_txt.bind('<Return>', self.update_widgets)
    self.input_txt.bind('<KP_Enter>', self.update_widgets)

    # Positioning
    self.input_txt.grid(row=0, column=0, sticky=tk.W)
    self.submit_label.grid(row=0, column=1)
    self.submit_button.grid(row=0, column=2, sticky=tk.E) 
Example #18
Source File: adder.py    From mentalist with MIT License 5 votes vote down vote up
def open_special_dlg(self):
        '''Open a popup for selecting special characters
        '''
        self.special_dlg = Tk.Toplevel()
        self.special_dlg.withdraw()
        self.special_dlg.title('Select Special Characters')
        self.special_dlg.resizable(width=False, height=False)
        frame = Tk.Frame(self.special_dlg)
        lb = Tk.Label(frame, text='Select Special Characters'.format(self.title))
        lb.pack(fill='both', side='top')

        box = Tk.Frame(frame)
        self.chk_special = []
        max_column_checks = 15
        for v, val in enumerate(SPECIAL_CHARACTERS):
            var = Tk.IntVar()
            tmp = Tk.Checkbutton(box, text=val, relief=Tk.FLAT, variable=var)
            self.chk_special.append(var)
            tmp.grid(row=v % max_column_checks, column=v // max_column_checks,
                     sticky='W', padx=10)
        box.pack(fill='both', side='top', padx=30, pady=20)

        # Ok and Cancel buttons
        btn_box = Tk.Frame(frame)
        btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_special)
        btn_cancel.pack(side='right', padx=10, pady=20)
        btn_ok = Tk.Button(btn_box, text='Ok', command=self.on_ok_special_dlg)
        btn_ok.pack(side='left', padx=10, pady=20)
        btn_box.pack()
        frame.pack(fill='both', padx=60, pady=10)
        
        center_window(self.special_dlg, self.main.master)
        self.special_dlg.focus_set() 
Example #19
Source File: videoextensoConfig.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def create_window(self):
    Camera_config.create_window(self)
    self.img_label.bind('<1>', self.start_select)
    self.img_label.bind('<B1-Motion>', self.update_box)
    self.img_label.bind('<ButtonRelease-1>', self.stop_select)
    self.save_length_button = tk.Button(self.lower_frame,text="Save L0",
                                        command=self.save_length)
    # self.save_length_button.grid(
    #   column=1,row=len(self.camera.settings_dict)+4)
    self.save_length_button.pack() 
Example #20
Source File: photoboothapp.py    From OpenCV-Python-Tutorial with MIT License 5 votes vote down vote up
def __init__(self, vs, outputPath):
        # store the video stream object and output path, then initialize
        # the most recently read frame, thread for reading frames, and
        # the thread stop event
        self.vs = vs
        self.outputPath = outputPath
        self.frame = None
        self.thread = None
        self.stopEvent = None

        # initialize the root window and image panel
        self.root = tki.Tk()
        self.panel = None

        # create a button, that when pressed, will take the current
        # frame and save it to file
        btn = tki.Button(self.root, text="Snapshot!",
                         command=self.takeSnapshot)
        btn.pack(side="bottom", fill="both", expand="yes", padx=10,
                 pady=10)

        # start a thread that constantly pools the video sensor for
        # the most recently read frame
        self.stopEvent = threading.Event()
        self.thread = threading.Thread(target=self.videoLoop, args=())
        self.thread.start()

        # set a callback to handle when the window is closed
        self.root.wm_title("PyImageSearch PhotoBooth")
        self.root.wm_protocol("WM_DELETE_WINDOW", self.onClose) 
Example #21
Source File: environment.py    From reinforcement-learning-kr with MIT License 5 votes vote down vote up
def _build_canvas(self):
        canvas = tk.Canvas(self, bg='white',
                           height=HEIGHT * UNIT,
                           width=WIDTH * UNIT)
        # 버튼 초기화
        iteration_button = Button(self, text="Evaluate",
                                  command=self.evaluate_policy)
        iteration_button.configure(width=10, activebackground="#33B5E5")
        canvas.create_window(WIDTH * UNIT * 0.13, HEIGHT * UNIT + 10,
                             window=iteration_button)
        policy_button = Button(self, text="Improve",
                               command=self.improve_policy)
        policy_button.configure(width=10, activebackground="#33B5E5")
        canvas.create_window(WIDTH * UNIT * 0.37, HEIGHT * UNIT + 10,
                             window=policy_button)
        policy_button = Button(self, text="move", command=self.move_by_policy)
        policy_button.configure(width=10, activebackground="#33B5E5")
        canvas.create_window(WIDTH * UNIT * 0.62, HEIGHT * UNIT + 10,
                             window=policy_button)
        policy_button = Button(self, text="reset", command=self.reset)
        policy_button.configure(width=10, activebackground="#33B5E5")
        canvas.create_window(WIDTH * UNIT * 0.87, HEIGHT * UNIT + 10,
                             window=policy_button)

        # 그리드 생성
        for col in range(0, WIDTH * UNIT, UNIT):  # 0~400 by 80
            x0, y0, x1, y1 = col, 0, col, HEIGHT * UNIT
            canvas.create_line(x0, y0, x1, y1)
        for row in range(0, HEIGHT * UNIT, UNIT):  # 0~400 by 80
            x0, y0, x1, y1 = 0, row, HEIGHT * UNIT, row
            canvas.create_line(x0, y0, x1, y1)

        # 캔버스에 이미지 추가
        self.rectangle = canvas.create_image(50, 50, image=self.shapes[0])
        canvas.create_image(250, 150, image=self.shapes[1])
        canvas.create_image(150, 250, image=self.shapes[1])
        canvas.create_image(250, 250, image=self.shapes[2])

        canvas.pack()

        return canvas 
Example #22
Source File: demo.py    From OpenCV-Python-Tutorial with MIT License 5 votes vote down vote up
def __init__(self, text, url_callback = None):
        self.text = text
        self.text.tag_config("link", foreground="blue", underline=1)
        self.text.tag_bind("link", "<Enter>", self._enter)
        self.text.tag_bind("link", "<Leave>", self._leave)
        self.text.tag_bind("link", "<Button-1>", self._click)

        self.url_callback = url_callback
        self.reset() 
Example #23
Source File: example.py    From Traffic-Signs-and-Object-Detection with GNU General Public License v3.0 5 votes vote down vote up
def add_zoom_button(self, text, sign):

        button = tk.Button(self.canvas, text=text, width=1, command=lambda:self.zoom(sign))
        return button 
Example #24
Source File: example.py    From Traffic-Signs-and-Object-Detection with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):

        tk.Tk.__init__(self)

        self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT))
        self.title('GooMPy')

        self.canvas = tk.Canvas(self, width=WIDTH, height=HEIGHT)

        self.canvas.pack()

        self.bind("<Key>", self.check_quit)
        self.bind('<B1-Motion>', self.drag)
        self.bind('<Button-1>', self.click)

        self.label = tk.Label(self.canvas)

        self.radiogroup = tk.Frame(self.canvas)
        self.radiovar = tk.IntVar()
        self.maptypes = ['roadmap', 'terrain', 'satellite', 'hybrid']
        self.add_radio_button('Road Map',  0)
        self.add_radio_button('Terrain',   1)
        self.add_radio_button('Satellite', 2)
        self.add_radio_button('Hybrid',    3)

        self.zoom_in_button  = self.add_zoom_button('+', +1)
        self.zoom_out_button = self.add_zoom_button('-', -1)

        self.zoomlevel = ZOOM

        maptype_index = 0
        self.radiovar.set(maptype_index)

        self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE)

        self.restart() 
Example #25
Source File: map-creator.py    From rpg-text with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.variables = defaultdict(tk.StringVar)
        self.exits_var = [tk.IntVar() for i in range(4)]
        for var in self.exits_var:
            var.set(1)

        self.exits_frame = tk.Frame(self)
        self.form_entries = OrderedDict()
        self.form_labels = OrderedDict()
        self.form_exits = OrderedDict()
        self.form_entries_names = ('Location Name', 'Description', 'NPCs', 'Icon', "Submaps")
        self.exits_names = ('N', 'S', 'E', 'W')
        self.position_variable = tk.StringVar()
        self.position_variable.set('(0, 0)')
        self.position_label_lbl = tk.Label(self, text='Position : ')
        self.position_label = tk.Label(self, textvariable=self.position_variable)
        for entry in self.form_entries_names:
            self.form_labels[entry] = tk.Label(self, text=entry + ' :')
            if not entry == 'Description':
                self.form_entries[entry] = tk.Entry(self, textvariable=self.variables[entry], width=20)
            else:
                self.form_entries[entry] = tk.Text(self, width=20)
        for i, ext in enumerate(self.exits_names):
            self.form_exits[ext + '_label'] = tk.Label(self.exits_frame, text=ext + " :")
            self.form_exits[ext + '_checkbox'] = tk.Checkbutton(self.exits_frame, variable=self.exits_var[i])
        self.exits_label = tk.Label(self, text='Exits :')
        self.save_button = tk.Button(self, text='Save', command=self.save_btn)
        self.setup_ui() 
Example #26
Source File: map-creator.py    From rpg-text with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for i in range(0, 513, 16):
            self.create_line(0, i, 512, i, fill='grey')
            self.create_line(i, 0, i, 512, fill='grey')
        self.cursor = self.create_rectangle((0, 0, 16, 16))
        self.selected_position = (0, 0)
        self.bind('<Button-1>', self.on_click) 
Example #27
Source File: overviewSettings.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        tk.Toplevel.__init__(self)
        
        self.wm_attributes("-topmost", True)
        self.wm_title("PyEveLiveDPS Overview Settings Warning")
        try:
            self.iconbitmap(sys._MEIPASS + '\\app.ico')
        except Exception:
            try:
                self.iconbitmap("app.ico")
            except Exception:
                pass
        self.geometry("575x175")
        self.update_idletasks()
        self.columnconfigure(1, weight=1)
        self.rowconfigure(0, weight=1)
        
        warningText = "\nWARNING:\n\n" + \
                      "If you use custom EVE overview settings or you use an overview pack like Z-S, SaraShawa, etc.\n" + \
                      "You need to import your overview settings into PELD.\n\n" + \
                      "You can access these settings from the character menu at any time."

        tk.Label(self, image="::tk::icons::warning").grid(column="0", row="0", rowspan="90", padx="15")
        tk.Label(self, text=warningText, anchor='w', justify=tk.LEFT).grid(column="1", row="0", sticky="w")

        tk.Frame(self, height="20", width="10").grid(row="99", column="1", columnspan="5")
        
        buttonFrame = tk.Frame(self)
        buttonFrame.grid(row="100", column="0", columnspan="5")
        okButton = tk.Button(buttonFrame, text="  Open overview settings  ", command=self.openSettings)
        okButton.grid(row="0", column="0")
        tk.Frame(buttonFrame, height="1", width="30").grid(row="0", column="1")
        cancelButton = tk.Button(buttonFrame, text="  I am using default EVE overview settings  ", command=self.useDefault)
        cancelButton.grid(row="0", column="2")
        
        tk.Frame(self, height="20", width="10").grid(row="101", column="1", columnspan="5") 
Example #28
Source File: base_words.py    From mentalist with MIT License 5 votes vote down vote up
def open_string_popup(self, type_):
        '''Custom string input popup window
        type_: the name to appear in labels ('Base Words')
        '''
        self.string_popup = Tk.Toplevel()
        self.string_popup.withdraw()
        self.string_popup.title('Input Custom String ({})'.format(type_))
        self.string_popup.resizable(width=False, height=False)
        frame = Tk.Frame(self.string_popup)
        lb = Tk.Label(frame, text='Input Custom String - {}'.format(self.title))
        lb.pack(fill='both', side='top')

        box = Tk.Frame(frame)
        lb1 = Tk.Label(box, text='String: ')
        lb1.pack(side='left', padx=5)
        self.entry_string = Tk.Entry(box, width=25)
        self.entry_string.pack(side='left')
        box.pack(fill='both', side='top', padx=30, pady=20)

        btn_box = Tk.Frame(frame)
        btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_string_popup)
        btn_cancel.pack(side='right', padx=10, pady=20)
        btn_ok = Tk.Button(btn_box, text='Ok', command=partial(self.on_ok_string_popup, type_))
        btn_ok.pack(side='left', padx=10, pady=20)
        btn_box.pack()
        frame.pack(fill='both', padx=10, pady=10)
        
        center_window(self.string_popup, self.main.master)
        self.string_popup.focus_set() 
Example #29
Source File: base_words.py    From mentalist with MIT License 5 votes vote down vote up
def __init__(self, controller, master, node, add_file_command):
        self.controller = controller
        self.master = master
        self.node = node
        
        button = Tk.Button(master, text='Fix...')
        button.pack(side='right')
        button.bind("<ButtonRelease-1>", partial(self.on_ok_locate_file, add_file_command))
    
        label = Tk.Label(master, text='Missing file', foreground="red")
        label.pack(side='right')
        
        self.string_popup = None 
Example #30
Source File: base.py    From mentalist with MIT License 5 votes vote down vote up
def add_remove_button(self):
        '''Creates the button for removing the node
        '''
        btn_add_file = Tk.Button(self.upper_frame, text=' - ')
        btn_add_file.pack(fill="both", side="right", padx=10, pady=5)
        btn_add_file.bind("<ButtonRelease-1>", partial(self.main.on_remove_node, self))

        btn_add_file = Tk.Button(self.upper_frame, text=' ↑ ')
        btn_add_file.pack(fill="both", side="right", padx=10, pady=5)
        btn_add_file.bind("<ButtonRelease-1>", partial(self.main.move_node, self, 'up'))

        btn_add_file = Tk.Button(self.upper_frame, text=' ↓ ')
        btn_add_file.pack(fill="both", side="right", padx=10, pady=5)
        btn_add_file.bind("<ButtonRelease-1>", partial(self.main.move_node, self, 'down'))