def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.menu = tk.Menu(self.window)
        self.filemenu = tk.Menu(self.menu)
        self.menu.add_cascade(label="file", menu=self.filemenu)
        self.editmenu = tk.Menu(self.menu)
        self.menu.add_cascade(label="edit", menu=self.editmenu)
        self.submenu = tk.Menu(self.filemenu)
        self.filemenu.add_cascade(label="import", menu=self.submenu)

        self.filemenu.add_command(label="New", command=self.do_job())
        self.filemenu.add_command(label="Open", command=self.do_job())
        self.filemenu.add_command(label="Save", command=self.do_job())
        self.filemenu.add_command(label="exit", command=self.quit)

        self.editmenu.add_command(label="cut", command=self.do_job())
        self.editmenu.add_command(label="copy", command=self.do_job())
        self.editmenu.add_command(label="paste", command=self.do_job())
        self.window.config(menu=self.menu)

        self.quit_button = Button(self.window, text="Quit", width=10, height=1)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=260, anchor="s")
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.var1 = tk.BooleanVar(value=False)
        self.check_button_01 = tk.Checkbutton(self.window,
                                              text='python',
                                              variable=self.var1,
                                              onvalue=True,
                                              offvalue=False,
                                              command=self.update_text)
        self.check_button_01.pack()
        self.check_button_01.place(x=200, y=100, anchor="n")

        self.var2 = tk.BooleanVar(value=False)
        self.check_button_02 = tk.Checkbutton(self.window,
                                              text='C++',
                                              variable=self.var2,
                                              onvalue=True,
                                              offvalue=False,
                                              command=self.update_text)
        self.check_button_02.pack()
        self.check_button_02.place(x=200, y=150, anchor="n")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=280, anchor="s")
Exemple #3
0
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.var0 = tk.StringVar(value="")
        self.radio_button_01 = tk.Radiobutton(self.window,
                                              text='Option A',
                                              variable=self.var0,
                                              value='A',
                                              command=self.update_text)
        self.radio_button_01.pack()
        self.radio_button_01.place(x=200, y=100, anchor="n")
        self.radio_button_02 = tk.Radiobutton(self.window,
                                              text='Option B',
                                              variable=self.var0,
                                              value='B',
                                              command=self.update_text)
        self.radio_button_02.pack()
        self.radio_button_02.place(x=200, y=150, anchor="n")

        self.var1 = tk.StringVar(value="")
        self.radio_button_03 = tk.Radiobutton(self.window,
                                              text='Option C',
                                              variable=self.var1,
                                              value='C',
                                              command=self.update_text)
        self.radio_button_03.pack()
        self.radio_button_03.place(x=200, y=200, anchor="n")
        self.var2 = tk.StringVar(value="")
        self.radio_button_04 = tk.Radiobutton(self.window,
                                              text='Option D',
                                              variable=self.var2,
                                              value='D',
                                              command=self.update_text)
        self.radio_button_04.pack()
        self.radio_button_04.place(x=200, y=250, anchor="n")

        self.panel.set_text(
            f"var0: {self.var0.get()}, var1: {self.var1.get()}, var2: {self.var2.get()}"
        )

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=380, anchor="s")
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window, bg="red", font=("Arial", 12), width=30, height=3)
        self.panel.pack()
        self.panel.place(x=200, y=80, anchor="n")
        
        self.button = Button(self.window, text="Ok", width=10, height=2)
        self.button.set("command", self.click_button())
        self.button.pack()
        self.button.place(x=20, y=280, anchor="sw")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=380, y=280, anchor="se")
    def __init__(self):
        self.window = self.build_window()

        self.canvas = tk.Canvas(self.window, height=200, width=200)
        self.canvas.place(x=200, y=0, anchor="n")
        x0, y0, x1, y1= 50, 50, 80, 80
        self.canvas.create_line(x0, y0, x1, y1)
        self.canvas.create_oval(x0, y0, x1, y1, fill='red')
        self.canvas.create_arc(x0+30, y0+30, x1+30, y1+30, start=0, extent=180)
        self.canvas.create_rectangle(100, 30, 100+20, 30+20)
        self.canvas.pack()

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=280, anchor="s")
Exemple #6
0
    def __init__(self):
        self.window = self.build_window()

        optionlist = [
            "showinfo", "showwarning", "showerror", "askyesno",
            "askretrycancel", "askquestion", "askokcancel"
        ]
        self.optionmenu = Optionmenu(self.window, optionlist)
        self.optionmenu.pack()
        self.optionmenu.place(x=200, y=40, anchor="n")

        self.button = Button(self.window, text="Ok", width=10, height=2)
        self.button.set("command", self.click_button)
        self.button.pack()
        self.button.place(x=200, y=120, anchor="n")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=200, anchor="n")
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.var1 = tk.BooleanVar(value=False)
        self.check_button_01 = tk.Checkbutton(self.window,
                                              text='python',
                                              variable=self.var1,
                                              onvalue=True,
                                              offvalue=False,
                                              command=self.update_text)
        self.check_button_01.pack()
        self.check_button_01.place(x=200, y=100, anchor="n")

        self.var2 = tk.BooleanVar(value=False)
        self.check_button_02 = tk.Checkbutton(self.window,
                                              text='C++',
                                              variable=self.var2,
                                              onvalue=True,
                                              offvalue=False,
                                              command=self.update_text)
        self.check_button_02.pack()
        self.check_button_02.place(x=200, y=150, anchor="n")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=280, anchor="s")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def update_text(self):
        if self.var1.get() and self.var2.get():
            text = "both"
        elif self.var1.get():
            text = "python"
        elif self.var2.get():
            text = "C++"
        else:
            text = "Neither"
        self.panel.set_text(text)
        return

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
Exemple #8
0
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.listbox = Listbox(self.window, ["A", "B", "C", "D"], height=4)
        self.listbox.pack()
        self.listbox.place(x=200, y=80, anchor="n")

        self.button = Button(self.window, text="Ok", width=10, height=1)
        self.button.set("command", self.click_button)
        self.button.pack()
        self.button.place(x=200, y=220, anchor="s")

        self.quit_button = Button(self.window, text="Quit", width=10, height=1)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=260, anchor="s")
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.menu = tk.Menu(self.window)
        self.filemenu = tk.Menu(self.menu)
        self.menu.add_cascade(label="file", menu=self.filemenu)
        self.editmenu = tk.Menu(self.menu)
        self.menu.add_cascade(label="edit", menu=self.editmenu)
        self.submenu = tk.Menu(self.filemenu)
        self.filemenu.add_cascade(label="import", menu=self.submenu)

        self.filemenu.add_command(label="New", command=self.do_job())
        self.filemenu.add_command(label="Open", command=self.do_job())
        self.filemenu.add_command(label="Save", command=self.do_job())
        self.filemenu.add_command(label="exit", command=self.quit)

        self.editmenu.add_command(label="cut", command=self.do_job())
        self.editmenu.add_command(label="copy", command=self.do_job())
        self.editmenu.add_command(label="paste", command=self.do_job())
        self.window.config(menu=self.menu)

        self.quit_button = Button(self.window, text="Quit", width=10, height=1)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=260, anchor="s")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def do_job(self):
        cnt = 0

        def fn():
            nonlocal cnt
            cnt += 1
            self.panel.set_text(f"op num: {cnt}")
            return

        return fn

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.canvas = tk.Canvas(self.window, height=200, width=200)
        self.canvas.place(x=200, y=0, anchor="n")
        x0, y0, x1, y1= 50, 50, 80, 80
        self.canvas.create_line(x0, y0, x1, y1)
        self.canvas.create_oval(x0, y0, x1, y1, fill='red')
        self.canvas.create_arc(x0+30, y0+30, x1+30, y1+30, start=0, extent=180)
        self.canvas.create_rectangle(100, 30, 100+20, 30+20)
        self.canvas.pack()

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=280, anchor="s")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def click_button(self):
        status = False
        def fn():
            nonlocal status
            if not status:
                self.panel.set_text("hello world!")
                self.panel.set("bg", "green")
            else:
                self.panel.set_text("")
                self.panel.set("bg", "red")
            status = not status
            return
        return fn

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
Exemple #11
0
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.listbox = Listbox(self.window, ["A", "B", "C", "D"], height=4)
        self.listbox.pack()
        self.listbox.place(x=200, y=80, anchor="n")

        self.button = Button(self.window, text="Ok", width=10, height=1)
        self.button.set("command", self.click_button)
        self.button.pack()
        self.button.place(x=200, y=220, anchor="s")

        self.quit_button = Button(self.window, text="Quit", width=10, height=1)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=260, anchor="s")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def click_button(self):
        idx = self.listbox.component.curselection()
        selection = self.listbox.component.get(idx) if idx else "null"
        self.panel.set_text(f"your choice is {selection}")
        return

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window, bg="red", font=("Arial", 12), width=30, height=3)
        self.panel.pack()
        self.panel.place(x=200, y=80, anchor="n")
        
        self.button = Button(self.window, text="Ok", width=10, height=2)
        self.button.set("command", self.click_button())
        self.button.pack()
        self.button.place(x=20, y=280, anchor="sw")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=380, y=280, anchor="se")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def click_button(self):
        status = False
        def fn():
            nonlocal status
            if not status:
                self.panel.set_text("hello world!")
                self.panel.set("bg", "green")
            else:
                self.panel.set_text("")
                self.panel.set("bg", "red")
            status = not status
            return
        return fn

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
Exemple #13
0
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=0, anchor="n")

        self.var0 = tk.StringVar(value="")
        self.radio_button_01 = tk.Radiobutton(self.window,
                                              text='Option A',
                                              variable=self.var0,
                                              value='A',
                                              command=self.update_text)
        self.radio_button_01.pack()
        self.radio_button_01.place(x=200, y=100, anchor="n")
        self.radio_button_02 = tk.Radiobutton(self.window,
                                              text='Option B',
                                              variable=self.var0,
                                              value='B',
                                              command=self.update_text)
        self.radio_button_02.pack()
        self.radio_button_02.place(x=200, y=150, anchor="n")

        self.var1 = tk.StringVar(value="")
        self.radio_button_03 = tk.Radiobutton(self.window,
                                              text='Option C',
                                              variable=self.var1,
                                              value='C',
                                              command=self.update_text)
        self.radio_button_03.pack()
        self.radio_button_03.place(x=200, y=200, anchor="n")
        self.var2 = tk.StringVar(value="")
        self.radio_button_04 = tk.Radiobutton(self.window,
                                              text='Option D',
                                              variable=self.var2,
                                              value='D',
                                              command=self.update_text)
        self.radio_button_04.pack()
        self.radio_button_04.place(x=200, y=250, anchor="n")

        self.panel.set_text(
            f"var0: {self.var0.get()}, var1: {self.var1.get()}, var2: {self.var2.get()}"
        )

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=380, anchor="s")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x400")
        return window

    def update_text(self):
        self.panel.set_text(
            f"var0: {self.var0.get()}, var1: {self.var1.get()}, var2: {self.var2.get()}"
        )
        return

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
Exemple #14
0
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        optionlist = [
            "showinfo", "showwarning", "showerror", "askyesno",
            "askretrycancel", "askquestion", "askokcancel"
        ]
        self.optionmenu = Optionmenu(self.window, optionlist)
        self.optionmenu.pack()
        self.optionmenu.place(x=200, y=40, anchor="n")

        self.button = Button(self.window, text="Ok", width=10, height=2)
        self.button.set("command", self.click_button)
        self.button.pack()
        self.button.place(x=200, y=120, anchor="n")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=200, y=200, anchor="n")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def click_button(self):
        command = self.optionmenu.get()
        if command == "showinfo":
            tk.messagebox.showinfo(title="showinfo",
                                   message="show information")
        elif command == "showwarning":
            tk.messagebox.showwarning(title="showwarning",
                                      message="show warning")
        elif command == "showerror":
            tk.messagebox.showerror(title="showerror", message="show error")
        elif command == "askyesno":
            tk.messagebox.askyesno(title="askyesno", message="ask yes no")
        elif command == "askretrycancel":
            tk.messagebox.askretrycancel(title="askretrycancel",
                                         message="ask retry cancel")
        elif command == "askquestion":
            tk.messagebox.askquestion(title="askquestion",
                                      message="ask question")
        elif command == "askokcancel":
            tk.messagebox.askokcancel(title="askokcancel",
                                      message="ask ok cancel")
        return

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()
class UserInterface:
    def __init__(self):
        self.window = self.build_window()

        self.panel = Indicator(self.window,
                               font=("Arial", 12),
                               width=30,
                               height=3)
        self.panel.pack()
        self.panel.place(x=200, y=80, anchor="n")

        self.entry = Entry(self.window, show="*")
        self.entry.pack()
        self.entry.place(x=200, y=160, anchor="n")

        self.button = Button(self.window, text="Ok", width=10, height=2)
        self.button.set("command", self.click_button)
        self.button.pack()
        self.button.place(x=20, y=280, anchor="sw")

        self.quit_button = Button(self.window, text="Quit", width=10, height=2)
        self.quit_button.set("command", self.quit)
        self.quit_button.pack()
        self.quit_button.place(x=380, y=280, anchor="se")

    def build_window(self):
        window = tk.Tk()
        window.title("user interface")
        window.geometry("400x300")
        return window

    def click_button(self):
        self.panel.set_text(self.entry.get())
        pass

    def quit(self):
        self.window.quit()
        return

    def run(self):
        self.window.mainloop()