class GUI: """For reciprocal space maps""" def __init__(self, master): self.file_path = None self.RSM = None #Defaul scale for RSM and Linescan is logarithmic self.rsm_scale = StringVar() self.rsm_scale.set("log") self.line_scale = StringVar() self.line_scale.set("log") #Default parameters for RSM self.rsm_parallel_lower = -0.01 self.rsm_parallel_upper = 0 self.rsm_normal_lower = 0.5 self.rsm_normal_upper = 0.52 #Default parameters for linescan self.origin_parallel = -0.0007 self.origin_normal = 0.51192 self.linescan_angle = 0.0 self.linescan_width = 0.000015 self.window_frame = Frame(master, bd=2, relief=GROOVE) self.fileselect_button = Button(self.window_frame, text="Select XRDML file", command=self.select_file) self.busy_label = Label(self.window_frame, text="") self.savebutton1 = Button(self.window_frame, text="Save RSM", command=lambda: self.savefigure(self.rsm_plot_figure)) self.savebutton2 = Button(self.window_frame, text="Save Linescan", command=lambda: self.savefigure(self.linescan_plot_figure)) self.rsm_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.rsm_label = Label(self.rsm_frame, text="Amerigo - RSM Viewer Space Map") self.rsm_parallel_lower_label = Label(self.rsm_frame, text="Lower q-parallel bound") self.rsm_parallel_lower_entry = Entry(self.rsm_frame) self.rsm_parallel_upper_label = Label(self.rsm_frame, text="Upper q-parallel bound") self.rsm_parallel_upper_entry = Entry(self.rsm_frame) self.rsm_normal_lower_label = Label(self.rsm_frame, text="Lower q-normal bound") self.rsm_normal_lower_entry = Entry(self.rsm_frame) self.rsm_normal_upper_label = Label(self.rsm_frame, text="Upper q-normal bound") self.rsm_normal_upper_entry = Entry(self.rsm_frame) self.rsm_sclae_linear = Radiobutton(self.rsm_frame, text="Linear", variable=self.rsm_scale, value="linear") self.rsm_sclae_log = Radiobutton(self.rsm_frame, text="Logarithmic", variable=self.rsm_scale, value="log") self.create_rsm_button = Button(self.rsm_frame, text="Create RSM", command=self.create_rsm) self.linescan_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.linescan_label = Label(self.linescan_frame, text="Line Scan") self.origin_parallel_label = Label(self.linescan_frame, text="Point of origin parallel coordinate") self.origin_normal_label = Label(self.linescan_frame, text="Point of origin normal coordinate") self.linescan_angle_label = Label(self.linescan_frame, text="Angle to parallel axis in degrees") self.linescan_width_label = Label(self.linescan_frame, text="Linescan thickness intervall") self.origin_parallel_entry = Entry(self.linescan_frame) self.origin_normal_entry = Entry(self.linescan_frame) self.linescan_angle_entry = Entry(self.linescan_frame) self.linescan_width_entry = Entry(self.linescan_frame) self.create_linescan_button = Button(self.linescan_frame, text="Create linescan", command=self.create_line_scan) self.line_scale_log = Radiobutton(self.linescan_frame, text="Logarithmic", variable=self.line_scale, value="log") self.line_scale_linear = Radiobutton(self.linescan_frame, text="Linear", variable=self.line_scale, value="linear") self.rsm_plot_frame = Frame(master, relief=GROOVE, bd=2) self.rsm_plot_figure = Figure() self.rsm_canvas = FigureCanvasTkAgg(self.rsm_plot_figure, master=self.rsm_plot_frame) self.rsm_toolbar = NavigationToolbar2TkAgg(self.rsm_canvas, self.rsm_plot_frame) self.rsm_toolbar.update() self.rsm_canvas.show() self.linescan_plot_frame = Frame(master, relief=GROOVE, bd=2) self.linescan_plot_figure = Figure() self.linescan_canvas = FigureCanvasTkAgg(self.linescan_plot_figure, master=self.linescan_plot_frame) self.linescan_toolbar = NavigationToolbar2TkAgg(self.linescan_canvas, self.linescan_plot_frame) self.linescan_toolbar.update() self.linescan_canvas.show() self.place_widgets() def place_widgets(self): self.window_frame.place(x=10, y=10, width=425, height=520) self.fileselect_button.place(x=5, y=5, width=415, height=25) self.savebutton1.place(x=5, y=485, height=25, width=205) self.savebutton2.place(x=215, y=485, height=25, width=200) self.rsm_frame.place(x=5, y=35, height=220, width=415) self.rsm_label.place(x=5, y=5, height=25, width=405) self.rsm_parallel_lower_label.place(x=5, y=35, height=25, width=200) self.rsm_normal_lower_label.place(x=5, y=65, height=25, width=200) self.rsm_parallel_upper_label.place(x=5, y=95, height=25, width=200) self.rsm_normal_upper_label.place(x=5, y=125, height=25, width=200) self.rsm_parallel_lower_entry.place(x=210, y=35, height=25, width=200) self.rsm_parallel_upper_entry.place(x=210, y=65, height=25, width=200) self.rsm_normal_lower_entry.place(x=210, y=95, height=25, width=200) self.rsm_normal_upper_entry.place(x=210, y=125, height=25, width=200) self.rsm_sclae_linear.place(x=5, y=155, height=25, width=200) self.rsm_sclae_log.place(x=210, y=155, height=25, width=200) self.create_rsm_button.place(x=5, y=185, height=25, width=405) self.linescan_frame.place(x=5, y=260, width=415, height=220) self.linescan_label.place(x=5, y=5, width=405, height=25) self.origin_parallel_label.place(x=5, y=35, width=200, height=25) self.origin_normal_label.place(x=5, y=65, width=200, height=25) self.linescan_angle_label.place(x=5, y=95, width=200, height=25) self.linescan_width_label.place(x=5, y=125, width=200, height=25) self.origin_parallel_entry.place(x=210, y=35, width=200, height=25) self.origin_normal_entry.place(x=210, y=65, width=200, height=25) self.linescan_angle_entry.place(x=210, y=95, width=200, height=25) self.linescan_width_entry.place(x=210, y=125, width=200, height=25) self.line_scale_linear.place(x=5, y=155, width=200, height=25) self.line_scale_log.place(x=210, y=155, width=200, height=25) self.create_linescan_button.place(x=5, y=185, width=405, height=25) self.rsm_plot_frame.place(x=440, y=10, width=480, height=520) self.rsm_canvas.get_tk_widget().place(x=5, y=5, height=470, width=470) self.linescan_plot_frame.place(x=925, y=10, width=480, height=520) self.linescan_canvas.get_tk_widget().place(x=5, y=5, height=470, width=470) def select_file(self): self.file_path = askopenfilename() self.busy_label.configure(text="Be patient, I have a lot of data to read") self.RSM = Reciprocal(self.file_path) self.RSM.readfile() self.RSM.refine_data() self.busy_label.configure(text="") def create_rsm(self): if self.RSM is not None: self.busy_label.configure(text="Busy! Plotting %s data points." % len(self.RSM.intensity)) if self.rsm_parallel_lower_entry.get() != "": self.rsm_parallel_lower = float(self.rsm_parallel_lower_entry.get()) if self.rsm_parallel_upper_entry.get() != "": self.rsm_parallel_upper = float(self.rsm_parallel_upper_entry.get()) if self.rsm_normal_lower_entry.get() != "": self.rsm_normal_lower = float(self.rsm_normal_lower_entry.get()) if self.rsm_normal_upper_entry.get() != "": self.rsm_normal_upper = float(self.rsm_normal_upper_entry.get()) x = self.RSM.q_parallel y = self.RSM.q_normal if self.rsm_scale == "linear": z = self.RSM.intensity else: z = self.RSM.log_intensity ax = self.rsm_plot_figure.gca() ax.clear() ax.tricontourf(x, y, z, 1000, cmap="gist_rainbow") ax.tricontour(x, y, z, 8, colors="black") ax.set_ylabel(r"$q_{\perp} [\AA^{-1}]$") ax.set_xlabel(r"$q_{\parallel} [\AA^{-1}]$") ax.set_xlim(self.rsm_parallel_lower, self.rsm_parallel_upper) ax.set_ylim(self.rsm_normal_lower, self.rsm_normal_upper) ax.axis("equal") self.rsm_plot_figure.subplots_adjust(left=0.2) self.rsm_canvas.draw() self.busy_label.configure(text="") else: self.busy_label.configure(text="Select XRDML file first!") def create_line_scan(self): if self.RSM is not None: self.busy_label.configure(text="Busy! Processing %s data points." % len(self.RSM.intensity)) if self.origin_parallel_entry.get() != "": self.origin_parallel = float(self.origin_parallel_entry.get()) if self.origin_normal_entry.get() != "": self.origin_normal = float(self.origin_normal_entry.get()) if self.linescan_angle_entry.get() != "": self.linescan_angle = float(self.linescan_angle_entry.get()) if self.linescan_width_entry.get() != "": self.linescan_width = float(self.linescan_width_entry.get()) line = self.RSM.create_line_scan(self.origin_parallel, self.origin_normal, self.linescan_angle, self.linescan_width) bx = self.linescan_plot_figure.gca() bx.clear() bx.plot(line[0], line[1], '-o') bx.set_xlim(-0.005, 0.005) bx.set_yscale(self.line_scale.get()) bx.set_ylabel("Counts") bx.set_xlabel(r"Distance from origin $[\AA]^{-1}$") self.linescan_canvas.draw() self.busy_label.configure(text="") else: self.busy_label.configure(text="Select XRDML file first!") def savefigure(self, figure): if figure: figure.savefig(self.file_path+"_picture.png")
def pack_material_listbox(self) -> None: choose_material_lable = Label(self.parent, text='Choose a material:', width=32, height=1, font="Courier 14") choose_material_lable.place(x=10, y=200) self.material_index = IntVar() self.radiobuttons = list() y = 190 self.materials = ['red_rubber', 'glass', 'mirrow', 'ivory'] for index, material in enumerate(self.materials): y += 50 temp_button = Radiobutton(self.parent, text=material, value=index, variable=self.material_index, padx=15, pady=10, width=27, justify=CENTER, font="Courier 14", state=ACTIVE) temp_button.place(x=10, y=y) self.radiobuttons.append(temp_button)
def __init__(self, master): self.master = master self.offset = 0 with open('videos1.txt', 'r') as v_file: self.videos = json.load(v_file) with open('result.txt', 'r') as r_file: self.result = json.load(r_file) self.current = self.videos[0] self.title_label = Label(self.master, text=emoji_pattern.sub( "", self.current['title']), font=Font(size=15, weight='bold'), wraplength=580, justify=LEFT) self.title_label.place(anchor=NW, x=10, y=10) self._get_poster() self.poster_label = Label(self.master, image=tk_image) self.poster_label.place(anchor=NW, x=10, y=100) tags = ', '.join(self.current['tag']) self.tag_label = Label(self.master, text=emoji_pattern.sub("", tags), wraplength=580, justify=LEFT) self.tag_label.place(anchor=NW, x=10, y=350) self.sexy_value = IntVar() self.sexy_value.set(self.result.get(self.current['id'], -1)) sexy_radio = Radiobutton(master, text="sexy", variable=self.sexy_value, value=1, command=self.set_sexy) not_sexy_radio = Radiobutton(master, text="not sexy", variable=self.sexy_value, value=0, command=self.set_not_sexy) sexy_radio.place(anchor=NW, x=200, y=600) not_sexy_radio.place(anchor=NW, x=300, y=600) self.save_button = Button(self.master, text="save", command=self.handle_save) self.save_button.place(anchor=NW, x=400, y=600) self.previous_button = Button(self.master, text="previous", command=self.handle_previous) self.previous_button.place(anchor=NW, x=10, y=650) self.page_label = Label(self.master, text=str(self.offset)) self.page_label.place(anchor=NW, x=290, y=650) self.next_button = Button(self.master, text="next", command=self.handle_next) self.next_button.place(anchor=NW, x=550, y=650)
def _build(self): self._input = Frame(master=self, width=450, height=250) option1 = Radiobutton(master=self._input, text=lang['gen_true'], variable=self._variable, value=1) option1.place(in_=self._input, x=10, y=10) option2 = Radiobutton(master=self._input, text=lang['gen_false'], variable=self._variable, value=0) option2.place(in_=self._input, x=10, y=40) if self._value is True: option1.select() pass else: option2.select() pass super()._build() pass
def place_radiobuttons(self) -> None: """Создание и размещение кнопочек выбора роли""" self.var = IntVar() if self.user == "Преподаватель": self.status = "Преподаватели" rad3 = Radiobutton( self, text="Оборудование", variable=self.var, value=4, font=("Arial Bold", 15), command=self.place_add_equipment_forms, ) rad3.place(x=30, y=70) elif self.user == "Начальник цикла": self.status = "Студент" rad0 = Radiobutton( self, text="Предметы", variable=self.var, value=1, font=("Arial Bold", 15), command=self.place_add_subjects_forms, ) rad0.place(x=30, y=40) rad2 = Radiobutton( self, text="Студенты", variable=self.var, value=3, font=("Arial Bold", 15), command=self.place_add_students_forms, ) rad2.place(x=30, y=70) elif self.user == "Начальник ВУЦ": self.status = "Студент" rad1 = Radiobutton( self, text="Преподаватели", variable=self.var, value=2, font=("Arial Bold", 15), command=self.place_add_teachers_forms, ) rad1.place(x=30, y=40) """ rad2 = Radiobutton( self, text="Студенты", variable=self.var, value=3, font=("Arial Bold", 15), command=self.place_add_students_forms, ) rad2.place(x=30, y=70) """ """
def rdbtns(self): val = 0 b = [] yp = 150 while val < 4: btn = Radiobutton(root, text="", variable=self.opt_selected, value=val + 1, font=("times", 14)) b.append(btn) btn.place(x=100, y=yp) val += 1 yp += 40 return b
def next(): nonlocal Nomer if Nomer < 99: Nomer += 1 l1 = 0.04 text_clear = ' ' * 210 for clear in range(6): labl_clear = Label(WindowTest, text=text_clear, bg='gray94') labl_clear.place(relx=0.01, rely=l1) l1 += 0.02 QuesLabel = Label(WindowTest, text=main_list[Nomer], bg='gray94', font=('Ariel', 14), justify=LEFT) QuesLabel.place(relx=0.03, rely=0.04, relwidth=0.94) rely1 = 0.25 r1 = 0.26 SI = search_index[Nomer] SI_T = search_index[Nomer] for clear in range(13): radb_clear = Label(WindowTest, text=text_clear, bg='gray94') radb_clear.place(relx=0.05, rely=r1) r1 += 0.02 for k in range(differ[Nomer]): SI += 1 val = (str(SI_T) + '@' + array2[SI]) radiobut = Radiobutton(WindowTest, text=array2[SI], activebackground='gray94', wraplength=1130, variable=var, value=val, bg='gray94', font=('Ariel', 14), command=rad_def) radiobut.place(relx=0.05, rely=rely1) rely1 += 0.05 else: pass
def create_radiobutton(self): P0, widget_dims, board_dims = self.board.get_geometry() x, y = P0 width, height = widget_dims board_width, board_height = board_dims x, y = x / board_width, y / board_height width, height = width / board_width, height / board_height button = Radiobutton(self.board) button.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") self.board.delete("line") items = [item for item in button.keys() if len(item) > 2] button.bind("<Enter>", lambda event: self.get_widget_info(button)) button.bind("<Leave>", lambda event: self.focus_out()) button.bind("<Button-3>", lambda event: self.modify(button, items)) self.manager.switch(button, items)
class SingleChoice(ExerciseFrame): def __init__(self, master, subject, font_name): super().__init__(master, subject, font_name) self.choosen = StringVar() self.init_widgets() def init_widgets(self): self._promopt_label = Label(self._input_frame, text="请选择:", font=self._my_font) self._promopt_label.place(x=10, y=7, anchor='nw') self.choice_A = Radiobutton(self._input_frame, variable=self.choosen, value='A', fg='blue', font=self._my_bold_font, text='A') self.choice_A.place(x=160, y=7, anchor='nw') self.choice_B = Radiobutton(self._input_frame, variable=self.choosen, font=self._my_bold_font, value='B', fg='blue', text='B') self.choice_B.place(x=240, y=7, anchor='nw') self.choice_C = Radiobutton(self._input_frame, variable=self.choosen, font=self._my_bold_font, value='C', fg='blue', text='C') self.choice_C.place(x=320, y=7, anchor='nw') self.choice_D = Radiobutton(self._input_frame, variable=self.choosen, font=self._my_bold_font, value='D', fg='blue', text='D') self.choice_D.place(x=400, y=7, anchor='nw') self.choosen.set('A') def _check(self, is_correct=False): answer_string = self.choosen.get() print("user click check and answer=", answer_string) is_correct = self.exercise.check(answer_string) super()._check(is_correct)
def place_radiobuttons(self) -> None: """Создание и размещение кнопочек выбора роли""" self.var = IntVar() self.status = "Студент" rad0 = Radiobutton( self, text="Cтудент", variable=self.var, value=1, font=("Arial Bold", 15), command=self.status_1, ) rad1 = Radiobutton( self, text="Преподаватель", variable=self.var, value=2, font=("Arial Bold", 15), command=self.status_2, ) rad2 = Radiobutton( self, text="Начальник цикла", variable=self.var, value=3, font=("Arial Bold", 15), command=self.status_3, ) rad3 = Radiobutton( self, text="Начальник ВУЦ", variable=self.var, value=4, font=("Arial Bold", 15), command=self.status_4, ) rad0.place(x=20, y=210) rad1.place(x=20, y=240) rad2.place(x=20, y=270) rad3.place(x=20, y=300)
rendicion_estado = Label(text="Estado", font=("Mono", 13), fg="#772E25", bg="#EDDDD4") rendicion_estado.place(x=40, y=400) opcionEstado = IntVar() opcionEstado_aprobado = Radiobutton(text="Aprobado", bg="#EDDDD4", variable=opcionEstado, value=1) opcionEstado_aprobado.place(x=160, y=403) opcionEstado_reprobado = Radiobutton(text="Reprobado", bg="#EDDDD4", variable=opcionEstado, value=2) opcionEstado_reprobado.place(x=250, y=403) # ------------------- RENDICIÓN EMPLEADO -------------------- rendicion_empleado = Label(text="Empleado", font=("Mono", 13), fg="#772E25", bg="#EDDDD4") rendicion_empleado.place(x=40, y=450)
class Drawer: @staticmethod def hover_bind_button(*buttons): for button in buttons: button.bind('<Enter>', lambda e, b=button: Drawer.on_hover(b), '+') button.bind('<Leave>', lambda e, b=button: Drawer.on_leave(b), '+') @staticmethod def on_hover(button): button['background'] = bh_color button['foreground'] = bfh_color @staticmethod def on_leave(button): button['background'] = b_color button['foreground'] = bf_color @staticmethod def show_start_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_login_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Вход") self.t_login_button.place(x=400, y=200, height=30, width=200) self.t_register_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Регистрация") self.t_register_button.place(x=400, y=250, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Выход") self.t_exit_button.place(x=400, y=300, height=30, width=200) Drawer.hover_bind_button(self.t_login_button, self.t_register_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def remove_start_menu(func): @wraps(func) def wrapper(self, **kwargs): for value in filter(lambda value: value.startswith('t_'), dir(self)): getattr(self, value).destroy() return func(self, **kwargs) return wrapper @staticmethod def show_login_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_login_label = Label(text='Логин', font=font_family) self.t_login_label.place(x=400, y=150, height=30, width=200) self.t_login_input = Entry(font=font_family) self.t_login_input.focus() self.t_login_input.place(x=400, y=200, height=30, width=200) self.t_password_label = Label(text='Пароль', font=font_family) self.t_password_label.place(x=400, y=250, height=30, width=200) self.t_password_input = Entry(show="*", font=font_family) self.t_password_input.place(x=400, y=300, height=30, width=200) self.t_submit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Войти") self.t_submit_button.place(x=400, y=400, height=30, width=200) self.t_cancel_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_cancel_button.place(x=400, y=450, height=30, width=200) Drawer.hover_bind_button(self.t_submit_button, self.t_cancel_button) return func(self, **kwargs) return wrapper @staticmethod def show_registration_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_login_label = Label(text='Логин', font=font_family) self.t_login_label.place(x=275, y=100, height=30, width=200) self.t_login_input = Entry(font=font_family) self.t_login_input.focus() self.t_login_input.place(x=525, y=100, height=30, width=200) self.t_password_label = Label(text='Пароль', font=font_family) self.t_password_label.place(x=275, y=150, height=30, width=200) self.t_password_input = Entry(font=font_family) self.t_password_input.place(x=525, y=150, height=30, width=200) self.t_email_label = Label(text='Почта', font=font_family) self.t_email_label.place(x=275, y=200, height=30, width=200) self.t_email_input = Entry(font=font_family) self.t_email_input.place(x=525, y=200, height=30, width=200) self.t_fn_label = Label(text='ФИО', font=font_family) self.t_fn_label.place(x=275, y=250, height=30, width=200) self.t_fn_input = Entry(font=font_family) self.t_fn_input.place(x=525, y=250, height=30, width=200) self.t_phone_label = Label(text='Телефон', font=font_family) self.t_phone_label.place(x=275, y=300, height=30, width=200) self.t_phone_input = Entry(font=font_family) self.t_phone_input.place(x=525, y=300, height=30, width=200) self.t_fax_label = Label(text='Факс', font=font_family) self.t_fax_label.place(x=275, y=350, height=30, width=200) self.t_fax_input = Entry(font=font_family) self.t_fax_input.place(x=525, y=350, height=30, width=200) self.t_submit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Зарегестрировать") self.t_submit_button.place(x=400, y=450, height=30, width=200) self.t_cancel_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_cancel_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_submit_button, self.t_cancel_button) return func(self, **kwargs) return wrapper @staticmethod def remove_prev_tags(func): @wraps(func) def wrapper(self, *args): for value in filter(lambda value: value.startswith('t_'), dir(self)): getattr(self, value).destroy() return func(self, *args) return wrapper @staticmethod def remove_promotion_buttons(func): @wraps(func) def wrapper(self, *args): for value in filter( lambda value: value.startswith('t_promotion') and (value.endswith('_button')), dir(self)): getattr(self, value).destroy() return func(self, *args) return wrapper @staticmethod def remove_input_and_labels(func): @wraps(func) def wrapper(self, *args): for value in filter( lambda value: value.startswith('t_') and (value.endswith('_input') or value.endswith('_label') and value != 't_total_sum_label'), dir(self)): getattr(self, value).destroy() return func(self, *args) return wrapper @staticmethod def show_admin_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_label = Label(text='Меню администратора', font=font_family) self.t_label.place(x=400, y=100, height=30, width=200) self.t_remove_users_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Удалить пользователей") self.t_remove_users_button.place(x=400, y=200, height=30, width=200) self.t_manage_goals_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Управление целями") self.t_manage_goals_button.place(x=400, y=250, height=30, width=200) self.t_manage_experts_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Управление экспертами") self.t_manage_experts_button.place(x=400, y=300, height=30, width=200) self.t_show_marks_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Просмотреть оценки") self.t_show_marks_button.place(x=400, y=350, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Выйти из акканута") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_manage_experts_button, self.t_manage_goals_button, self.t_remove_users_button, self.t_show_marks_button, self.t_exit_button) ret = func(self, **kwargs) return wrapper @staticmethod def show_manage_experts_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_label = Label(text='Управление экспертами', font=font_family) self.t_label.place(x=400, y=100, height=30, width=200) self.t_show_experts_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Просмотреть экспертов") self.t_show_experts_button.place(x=400, y=200, height=30, width=200) self.t_add_experts_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Добавить эксперта") self.t_add_experts_button.place(x=400, y=250, height=30, width=200) self.t_remove_experts_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Удалить эксперта") self.t_remove_experts_button.place(x=400, y=300, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_add_experts_button, self.t_show_experts_button, self.t_remove_experts_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_experts(func): @wraps(func) def wrapper(self, **kwargs): self.t_experts_list = Listbox(self.root, width=30, height=15, font=('times', 14)) self.t_experts_list.place(x=125, y=75) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def remove_accounts(func): @wraps(func) def wrapper(self, *args): self.t_accounts_list = Listbox(self.root, width=30, height=15, font=('times', 14)) self.t_accounts_list.place(x=365, y=75) self.t_remove_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Удалить") self.t_remove_button.place(x=400, y=450, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_remove_button, self.t_exit_button) return func(self, *args) return wrapper @staticmethod def show_manage_goals_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_label = Label(text='Управление целями', font=font_family) self.t_label.place(x=400, y=100, height=30, width=200) self.t_show_goals_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Просмотреть цели") self.t_show_goals_button.place(x=400, y=200, height=30, width=200) self.t_add_goals_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Добавить цель") self.t_add_goals_button.place(x=400, y=250, height=30, width=200) self.t_remove_goals_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Удалить цель") self.t_remove_goals_button.place(x=400, y=300, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_add_goals_button, self.t_show_goals_button, self.t_remove_goals_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_goals(func): @wraps(func) def wrapper(self, **kwargs): self.t_goals_list = Listbox(self.root, width=45, height=15, font=('times', 13)) self.t_goals_list.place(x=300, y=75) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def add_goal(func): @wraps(func) def wrapper(self, **kwargs): self.t_goal_label = Label(text='Введите цель', font=font_family, width=40) self.t_goal_label.place(x=325, y=200) self.t_goal_input = Entry(font=font_family, width=40) self.t_goal_input.place(x=325, y=250) self.t_submit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Добавить") self.t_submit_button.place(x=400, y=450, height=30, width=200) self.t_cancel_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_cancel_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_submit_button, self.t_cancel_button) return func(self, **kwargs) return wrapper @staticmethod def remove_goal(func): @wraps(func) def wrapper(self, **kwargs): self.t_goals_list = Listbox(self.root, width=45, height=15, font=('times', 13)) self.t_goals_list.place(x=300, y=75) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=550, height=30, width=200) self.t_remove_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Удалить") self.t_remove_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_remove_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_user_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_label = Label(text='Меню клиента', font=font_family) self.t_label.place(x=400, y=100, height=30, width=200) self.t_make_order_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Сделать заказ") self.t_make_order_button.place(x=400, y=200, height=30, width=200) self.t_my_orders_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Мои заказы") self.t_my_orders_button.place(x=400, y=250, height=30, width=200) self.t_my_account_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Аккаунт") self.t_my_account_button.place(x=400, y=300, height=30, width=200) self.t_leave_feedback_button = Button( self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Оставить отзыв о фирме ") self.t_leave_feedback_button.place(x=400, y=350, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Выйти из акканута") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_make_order_button, self.t_my_orders_button, self.t_my_account_button, self.t_leave_feedback_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_my_account(func): @wraps(func) def wrapper(self, **kwargs): self.t_label = Label(text='Мой аккаунт', font=font_family) self.t_label.place(x=400, y=50, height=30, width=200) self.t_login_label = Label(text='Логин', font=font_family) self.t_login_label.place(x=275, y=100, height=30, width=200) self.t_login_input = Entry(font=font_family) self.t_login_input.focus() self.t_login_input.place(x=525, y=100, height=30, width=200) self.t_password_label = Label(text='Пароль', font=font_family) self.t_password_label.place(x=275, y=150, height=30, width=200) self.t_password_input = Entry(font=font_family) self.t_password_input.place(x=525, y=150, height=30, width=200) self.t_email_label = Label(text='Почта', font=font_family) self.t_email_label.place(x=275, y=200, height=30, width=200) self.t_email_input = Entry(font=font_family) self.t_email_input.place(x=525, y=200, height=30, width=200) self.t_fn_label = Label(text='ФИО', font=font_family) self.t_fn_label.place(x=275, y=250, height=30, width=200) self.t_fn_input = Entry(font=font_family) self.t_fn_input.place(x=525, y=250, height=30, width=200) self.t_phone_label = Label(text='Телефон', font=font_family) self.t_phone_label.place(x=275, y=300, height=30, width=200) self.t_phone_input = Entry(font=font_family) self.t_phone_input.place(x=525, y=300, height=30, width=200) self.t_fax_label = Label(text='Факс', font=font_family) self.t_fax_label.place(x=275, y=350, height=30, width=200) self.t_fax_input = Entry(font=font_family) self.t_fax_input.place(x=525, y=350, height=30, width=200) self.t_edit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Изменить") self.t_edit_button.place(x=400, y=450, height=30, width=200) self.t_cancel_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_cancel_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_edit_button, self.t_cancel_button) return func(self, **kwargs) return wrapper @staticmethod def show_orders(func): @wraps(func) def wrapper(self, **kwargs): self.t_orders_list = Listbox(self.root, width=30, height=15, font=('times', 14)) self.t_orders_list.place(x=125, y=75) self.t_total_sum_label = Label(self.root) self.t_total_sum_label.place(x=125, y=450, height=30, width=100) self.t_delete_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Удалить") self.t_delete_button.place(x=400, y=450, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_delete_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def add_order(func): @wraps(func) def wrapper(self, **kwargs): # self.t_label = Label(text='Меню заказа', font=font_family) # self.t_label.place(x=400, y=50, height=30, width=200) self.t_platform_label = Label(text='Язык программирования', font=font_family) self.t_platform_label.place(x=275, y=100, height=30, width=200) self.t_platform_input = Entry(font=font_family) self.t_platform_input.focus() self.t_platform_input.place(x=525, y=100, height=30, width=300) self.t_deadline_label = Label(text='Срок выполнения', font=font_family) self.t_deadline_label.place(x=275, y=150, height=30, width=200) self.t_deadline_input = Entry(font=font_family) self.t_deadline_input.place(x=525, y=150, height=30, width=300) self.t_topic_label = Label(text='Тема', font=font_family) self.t_topic_label.place(x=275, y=200, height=30, width=200) self.t_topic_input = Entry(font=font_family) self.t_topic_input.place(x=525, y=200, height=30, width=300) self.t_description_label = Label(text='Описание', font=font_family) self.t_description_label.place(x=275, y=250, height=30, width=200) self.t_description_input = Text(font=font_family, height=12, width=33) self.t_description_input.place(x=525, y=250) self.t_promotion_label = Label(text='Продвижение сайта', font=font_family) self.t_promotion_label.place(x=275, y=400, height=30, width=200) self.is_promotion_enabled = BooleanVar(value=0) self.t_promotion_enabled_button = Radiobutton( text='Да', width=5, variable=self.is_promotion_enabled, value=0) self.t_promotion_enabled_button.place(x=310, y=450) self.t_promotion_disabled_button = Radiobutton( text='Нет', width=5, variable=self.is_promotion_enabled, value=1) self.t_promotion_disabled_button.place(x=380, y=450) self.t_make_order_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Сделать заказ") self.t_make_order_button.place(x=400, y=500, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=550, height=30, width=200) Drawer.hover_bind_button(self.t_make_order_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_order(func): @wraps(func) def wrapper(self, *args): self.t_platform_label = Label(text='Язык программирования', font=font_family) self.t_platform_label.place(x=450, y=100, height=30, width=200) self.t_platform_input = Entry(font=font_family) self.t_platform_input.place(x=700, y=100, height=30, width=240) self.t_deadline_label = Label(text='Срок выполнения', font=font_family) self.t_deadline_label.place(x=450, y=150, height=30, width=200) self.t_deadline_input = Entry(font=font_family) self.t_deadline_input.place(x=700, y=150, height=30, width=240) self.t_topic_label = Label(text='Тема', font=font_family) self.t_topic_label.place(x=450, y=200, height=30, width=200) self.t_topic_input = Entry(font=font_family) self.t_topic_input.place(x=700, y=200, height=30, width=240) self.t_description_label = Label(text='Описание', font=font_family) self.t_description_label.place(x=450, y=250, height=30, width=200) self.t_description_input = Text(font=font_family, background='#f0f0f0', foreground='#7f7186', height=12, width=26) self.t_description_input.place(x=700, y=250) self.t_promotion_label = Label(text='Продвижение сайта', font=font_family) self.t_promotion_label.place(x=450, y=300, height=30, width=200) self.is_promotion_enabled = BooleanVar(value=1) self.t_promotion_enabled_button = Radiobutton( text='Да', width=5, variable=self.is_promotion_enabled, value=1, state=DISABLED) self.t_promotion_enabled_button.place(x=485, y=350) self.t_promotion_disabled_button = Radiobutton( text='Нет', width=5, variable=self.is_promotion_enabled, value=0, state=DISABLED) self.t_promotion_disabled_button.place(x=565, y=350) return func(self, *args) return wrapper @staticmethod def add_feedbacks(func): @wraps(func) def wrapper(self, *args): self.t_first_label = Label(text='Удовлетворённость сайтом', font=font_family) self.t_first_label.place(x=350, y=50, height=30, width=300) self.t_first_input = Entry(font=font_family) self.t_first_input.place(x=350, y=100, height=30, width=300) self.t_second_label = Label(text='Качество выполнения', font=font_family) self.t_second_label.place(x=350, y=150, height=30, width=300) self.t_second_input = Entry(font=font_family) self.t_second_input.place(x=350, y=200, height=30, width=300) self.t_third_label = Label(text='Быстрота выполнения', font=font_family) self.t_third_label.place(x=350, y=250, height=30, width=300) self.t_third_input = Entry(font=font_family) self.t_third_input.place(x=350, y=300, height=30, width=300) self.t_forth_label = Label(text='Квалифицированность персонала', font=font_family) self.t_forth_label.place(x=350, y=350, height=30, width=300) self.t_forth_input = Entry(font=font_family) self.t_forth_input.place(x=350, y=400, height=30, width=300) self.t_make_feedback_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Оставить отзыв") self.t_make_feedback_button.place(x=400, y=500, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=550, height=30, width=200) Drawer.hover_bind_button(self.t_make_feedback_button, self.t_exit_button) return func(self, *args) return wrapper @staticmethod def show_expert_menu(func): @wraps(func) def wrapper(self, **kwargs): self.t_label = Label(text='Меню экспертов', font=font_family) self.t_label.place(x=400, y=100, height=30, width=200) self.t_expert_mark_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Оценка экспертов") self.t_expert_mark_button.place(x=400, y=200, height=30, width=200) self.t_show_feedbacks_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Просмотреть отзывы") self.t_show_feedbacks_button.place(x=400, y=250, height=30, width=200) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Выйти из аккаунта") self.t_exit_button.place(x=400, y=450, height=30, width=200) Drawer.hover_bind_button(self.t_expert_mark_button, self.t_show_feedbacks_button, self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_feedbacks(func): @wraps(func) def wrapper(self, **kwargs): self.t_feedbacks_list = Listbox(self.root, width=30, height=15, font=('times', 14)) self.t_feedbacks_list.place(x=125, y=75) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=500, height=30, width=200) Drawer.hover_bind_button(self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_feedback(func): @wraps(func) def wrapper(self, *args): self.t_first_label = Label(text='Удовлетворённость сайтом', font=font_family) self.t_first_label.place(x=430, y=100, height=30, width=250) self.t_first_input = Entry(font=font_family) self.t_first_input.place(x=700, y=100, height=30, width=240) self.t_second_label = Label(text='Качество выполнения', font=font_family) self.t_second_label.place(x=430, y=150, height=30, width=250) self.t_second_input = Entry(font=font_family) self.t_second_input.place(x=700, y=150, height=30, width=240) self.t_third_label = Label(text='Быстрота выполнения', font=font_family) self.t_third_label.place(x=430, y=200, height=30, width=250) self.t_third_input = Entry(font=font_family) self.t_third_input.place(x=700, y=200, height=30, width=240) self.t_forth_label = Label(text='Квалифицированность персонала', font=font_family) self.t_forth_label.place(x=430, y=250, height=30, width=250) self.t_forth_input = Entry(font=font_family) self.t_forth_input.place(x=700, y=250, height=30, width=240) return func(self, *args) return wrapper @staticmethod def draw_marks(func): @wraps(func) def wrapper(self, **kwargs): self.t_goals_list = Listbox(self.root, width=30, height=15, font=('times', 14)) self.t_goals_list.place(x=125, y=75) self.t_total_amount_label = Label(font=font_family) self.t_total_amount_label.place(x=125, y=430, width=273, height=20) self.t_scale_label = Label(font=font_family, text='Размер шкалы: 30') self.t_scale_label.place(x=125, y=460, width=273, height=20) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=550, height=30, width=200) Drawer.hover_bind_button(self.t_exit_button) return func(self, **kwargs) return wrapper @staticmethod def show_marks(func): @wraps(func) def wrapper(self, **kwargs): self.t_goals_list = Listbox(self.root, width=30, height=15, font=('times', 14)) self.t_goals_list.place(x=360, y=75) self.t_total_amount_label = Label(font=font_family) self.t_total_amount_label.place(x=360, y=470, width=273, height=20) self.t_exit_button = Button(self.root, background=b_color, foreground=bf_color, width=50, height=3, font=font_family, text="Назад") self.t_exit_button.place(x=400, y=550, height=30, width=200) Drawer.hover_bind_button(self.t_exit_button) return func(self, **kwargs) return wrapper
class GeoDemonstrator(Tk, GeoMixinTrans, GeoMixinHelp): # Konstruktor aplikacije def __init__(self): # Log poruka o pokretanju aplikacije print('Dobro došli u aplikaciju GeoDemonstrator!') # Pozivanje konstruktora roditeljske klase super().__init__() # Postavljanje naziva aplikacije self.title('GeoDemonstrator') # Inicijalizacija liste tačaka self.tačke = [] self.ttačke = [] # Inicijalizacija liste identifikatora # na platnu trenutno iscrtanih tačaka self.id_tač = [] # Inicijalizacija figure self.figura = None # Inicijalizacija transformacija iz platna # u iscrtani koordinatni sistem i obrnuto self.puk = Skal(1 / 7, -1 / 7) * Trans(-204, -132) self.kup = Trans(204, 132) * Skal(7, -7) # Inicijalizacija elemenata GKI self.init_gki() # Inicijalizacija elemenata GKI def init_gki(self): # Postavljanje veličine i pozicije prozora self.geometry('450x450+75+75') # Onemogućavanje promene veličine prozora, # pošto je Tk prilično plastičan, pa promene # ugrožavaju zamišljeni izgled aplikacije self.resizable(False, False) # Inicijalizacija glavnog menija self.init_meni() # Inicijalizacija platna self.init_platno() # Kontrola unosa tačaka self.init_unos() # Inicijalizacija glavnog menija def init_meni(self): # Pravljenje glavnog menija meni = Menu(self) # Postavljanje sporednog padajućeg menija self.umeni = Menu(meni) self.umeni.add_command(label='Zaključi unos', command=self.promena_unosa) self.umeni.add_command(label='Ispravi figuru', command=self.ispravi) self.umeni.add_command(label='Očisti platno', command=partial(self.novo_platno, True)) # Postavljanje glavnog menija i vezivanje # komandi za odgovarajuće funkcionalnosti meni.add_cascade(label='Opcije', menu=self.umeni) meni.add_command(label='Pomoć (H)', command=self.pomoć) meni.add_command(label='Info (G)', command=self.info) self.config(menu=meni) # Vezivanje tipki za akcije analogne # onima iz prethodno postavljenog menija; # od F1 se odustalo jer se ne ponaša kako # treba na operativnom sistemu Windows self.bind('<H>', self.pomoć) self.bind('<h>', self.pomoć) self.bind('<G>', self.info) self.bind('<g>', self.info) self.bind('<Escape>', self.kraj) # Vezivanje protokola zatvaranja prozora # za istu akciju kao za Kraj i Escape self.protocol('WM_DELETE_WINDOW', self.kraj) # Inicijalizacija platna def init_platno(self): # Pravljenje okvira za platno okvir_p = LabelFrame(self, text='Zakoračite u svet geometrijskih' ' transformacija', padx=10, pady=10) okvir_p.place(x=10, y=10, height=300, width=430) # Postavljanje platna unutar okvira self.platno = Canvas(okvir_p, height=261, width=405) self.platno.place(x=0, y=0) # Postavljanje koordinatnog sistema na platno; # slika nije lokalna promenljiva, pošto bi je u # tom slučaju 'pojeo' sakupljač otpadaka self.slika = self.učitaj_sliku('koord.gif') self.platno.create_image(203, 131, image=self.slika) # Vezivanje čuvanja tačke za klik na platno self.unos = True self.platno.bind('<Button-1>', self.dodaj_tačku) # Vezivanje promene unosa za desni klik, # a ispravljanja figure za srednji, prema # sugestiji asistenta, čime se dobija na # lakoći korišćenja, bez potrebe za menijem self.platno.bind('<Button-2>', self.ispravi) self.platno.bind('<Button-3>', self.promena_unosa) # Okvir za magični svet transformacija def init_unos(self): # Pravljenje okvira za elemente self.okvir_d = LabelFrame(self, text='Unosite tačke klikovima' ' po platnu', padx=10, pady=10) self.okvir_d.place(x=10, y=315, height=128, width=430) # Inicijalizacija polja sa transformacijama self.init_trans() # Oznake parametara koje korisnik unosi x_koord_labela = Label(self, text='x:') y_koord_labela = Label(self, text='y:') ugao_labela = Label(self, text='\u03b8:') # Postavljanje oznaka na prozor x_koord_labela.place(x=185, y=348) y_koord_labela.place(x=185, y=375) ugao_labela.place(x=185, y=403) # Polja za unos vrednosti transformacija self.x_koord = Entry(self, width=4, state='disabled') self.y_koord = Entry(self, width=4, state='disabled') self.ugao = Entry(self, width=4, state='disabled') # Postavljanje polja na prozor self.x_koord.place(x=200, y=348) self.y_koord.place(x=200, y=375) self.ugao.place(x=200, y=403) # Postavljanje ostalih elemenata self.init_centar() self.init_inverz() # Transformacijski okvir def init_trans(self): # Mapa za preslikavanje niske u # odgavarajuću klasu transformacije self.funkcije = { 'translacija': Trans, 'skaliranje': Skal, 'smicanje': Smic, 'rotacija': Rot, 'refleksija': Refl } # Pravljenje okvira za odabir transformacije okvir_t = LabelFrame(self, text='Izaberite transformaciju', padx=23, pady=7) okvir_t.place(x=18, y=337, height=95, width=158) # U zavisnosti od vrednosti var koju pročitamo iz # padajućeg menija, poziva se prava transformacija self.tr = StringVar(self) self.tr.set('') # Funkcija za praćenje promenljive; izveštava o odabiru # transformacije i kontroliše pristup poljima za unos # parametara u zavisnosti od odabira; nepakovana lista # argumenata *args je neophodna kako bi se prosledili # (i zanemarili) dodatni podaci o promeni odabira, slično # kao što npr. kolbek funkcije u GLUT-u obavezno primaju # koordinate događaja, iako one često nisu nužan podatak self.tr.trace( 'w', lambda *args: print('Odabrana transformacija:' ' {}.'.format(self.tr.get())) or self.kontrola( )) # Padajuća lista geometrijskih transformacija; # umesto dosad korišćene fje place za postavljanje # objekta na tačno određeno mesto na prozoru, ovde # se koristi pack, koji objekat optimalno spakuje # na raspoloživom prostoru; iz tog razloga je i # roditeljski element upravo transformacioni okvir, # u koji se pakuje, a ne self, kako je dosad bilo OptionMenu(okvir_t, self.tr, 'translacija', 'skaliranje', 'smicanje', 'rotacija', 'refleksija').pack(fill='x') # Dugme za pokretanje transformacije self.dugme_t = Button(okvir_t, text='Transformiši', command=self.transformiši, state='disabled') self.dugme_t.pack(fill='x') # Odabir centra transformacije def init_centar(self): # Promenljiva za praćenje self.centar = StringVar(self) self.centar.set(None) self.centar.trace( 'w', lambda *args: print('Odabran {}' ' za centar transformacije.'.format( self.centar.get())) if self.centar.get() != 'None' else None) # Oznaka za odabir centra odabir_centra = Label(self, text='Centar transformacije:') odabir_centra.place(x=265, y=330) # Dugme za transformaciju sa centrom # u koordinatnom početku self.radio1 = Radiobutton(self, text='centar platna', padx=3, variable=self.centar, value='centar platna', state='disabled', command=partial(self.kontrola, True)) self.radio1.place(x=242, y=350) # Dugme za transformaciju sa centrom # u centru mase (baricentru) figure self.radio2 = Radiobutton(self, text='centar mase', padx=3, variable=self.centar, value='centar mase', state='disabled', command=partial(self.kontrola, True)) self.radio2.place(x=242, y=370) # Dugme za transformaciju sa centrom # u korisnički unetoj tački self.radio3 = Radiobutton(self, text='uneta tačka', padx=3, variable=self.centar, value='korisnički unos', state='disabled', command=partial(self.kontrola, True)) self.radio3.place(x=242, y=390) # Oznake za unos centra transformacija t1_labela = Label(self, text='t1:') t2_labela = Label(self, text='t2:') # Postavljanje oznaka na prozor t1_labela.place(x=360, y=358) t2_labela.place(x=360, y=385) # Polja za unos centra transformacija self.t1_koord = Entry(self, width=4, state='disabled') self.t2_koord = Entry(self, width=4, state='disabled') # Postavljanje polja na prozor self.t1_koord.place(x=380, y=358) self.t2_koord.place(x=380, y=385) # Funkcija za praćenje inverza def init_inverz(self): self.inv = BooleanVar(self) self.inv.trace( 'w', lambda *args: print('Odabrana inverzna' ' transformacija.') if self.inv.get() else print('Odabrana klasična transformacija.')) # Dugme za odabir inverza self.inverz = Checkbutton(self, text='Invertuj promenu', variable=self.inv, state='disabled') self.inverz.place(x=262, y=410)
label_ape.place(x=5, y=100) entry_ape = Entry(root, width=35) entry_ape.place(x=100, y=100) label_edad = Label(root, text='Edad') label_edad.place(x=5, y=150) entry_edad = Entry(root, width=35) entry_edad.place(x=100, y=150) opcion = IntVar() rb1 = Radiobutton(root, text='Femenino', value='1', command=seleccionar, variable=opcion) rb1.place(x=5, y=200) rb2 = Radiobutton(root, text='Masculino', value='2', command=seleccionar, variable=opcion) rb2.place(x=100, y=200) label_d1 = Label(root, text='Disparo 1') label_d1.place(x=5, y=250) entry_d1 = Entry(root, width=35) entry_d1.place(x=100, y=250) label_d2 = Label(root, text='Disparo 2') label_d2.place(x=5, y=300) entry_d2 = Entry(root, width=35)
def update_gui(): global window window = Tk() window.geometry("500x500") window.title("Updating Information") global updateName, newName global updateRoll, newRoll global updateBranch, newBranch global updatePhone, newPhone global radbtn1, radbtn2, radbtn3, radbtn4, radbtn5, radbtn6, radbtn7, radbtn8 global radiobutton, radiobutton2 radiobutton = IntVar() radiobutton2 = IntVar() lblsay = Label(window, text="Hey User! Which Thing You Want To Update.....").place( x=5, y=5) radbtn1 = Radiobutton(window, variable=radiobutton, value=1, text="Name", command=radio1) radbtn1.place(x=30, y=30) lblnewname = Label(window, text="Enter New Name:", font="Arial 16").place(x=0, y=130) newName = Entry(window, state=DISABLED, font="Arial 16") newName.place(x=250, y=130) radbtn2 = Radiobutton(window, variable=radiobutton, value=2, text="Roll_No", command=radio2) radbtn2.place(x=130, y=30) lblnewroll = Label(window, text="Enter New Roll", font="Arial 16").place(x=0, y=170) newRoll = Entry(window, state=DISABLED, font="Arial 16") newRoll.place(x=250, y=170) radbtn3 = Radiobutton(window, variable=radiobutton, value=3, text="Branch", command=radio3) radbtn3.place(x=230, y=30) lblnewbranch = Label(window, text="Enter New Branch", font="Arial 16").place(x=0, y=210) newBranch = Entry(window, state=DISABLED, font="Arial 16") newBranch.place(x=250, y=210) radbtn4 = Radiobutton(window, variable=radiobutton, value=4, text="Phone", command=radio4) radbtn4.place(x=330, y=30) lblnewphone = Label(window, text="Enter New Phone", font="Arial 16").place(x=0, y=250) newPhone = Entry(window, state=DISABLED, font="Arial 16") newPhone.place(x=250, y=250) lblsay1 = Label( window, text="By Which Option You Want To Update......").place(x=5, y=55) radbtn5 = Radiobutton(window, variable=radiobutton2, value=1, text="By Name", command=radio5, state=DISABLED) radbtn5.place(x=30, y=80) lblname = Label(window, text="Enter Existing Name", font="Arial 16").place(x=0, y=290) updateName = Entry(window, state=DISABLED, font="Arial 16") updateName.place(x=250, y=290) radbtn6 = Radiobutton(window, variable=radiobutton2, value=2, text="By Roll_No", command=radio6, state=DISABLED) radbtn6.place(x=130, y=80) lblroll = Label(window, text="Enter Existing Roll", font="Arial 16").place(x=0, y=330) updateRoll = Entry(window, state=DISABLED, font="Arial 16") updateRoll.place(x=250, y=330) radbtn7 = Radiobutton(window, variable=radiobutton2, value=3, text="By Branch", command=radio7, state=DISABLED) radbtn7.place(x=230, y=80) lblbranch = Label(window, text="Enter Existing Branch", font="Arial 16").place(x=0, y=370) updateBranch = Entry(window, state=DISABLED, font="Arial 16") updateBranch.place(x=250, y=370) radbtn8 = Radiobutton(window, variable=radiobutton2, value=4, text="By Phone", command=radio8, state=DISABLED) radbtn8.place(x=330, y=80) lblphone = Label(window, text="Enter Existing Phone", font="Arial 16").place(x=0, y=410) updatePhone = Entry(window, state=DISABLED, font="Arial 16") updatePhone.place(x=250, y=410) btnSave = Button(window, text="Update Information", command=update) btnSave.place(x=40, y=470) btnback = Button(window, text="Back To Main Menu", command=onclick_update) btnback.place(x=240, y=470) window.mainloop()
class BoxWindow(object): '''工具窗口''' def __init__(self, main_window, config): '''初始化''' self.box_window = Toplevel() self.main_window = main_window self.config = config def boxwin_setup(self): self.box_window.title("百宝袋") if self.config.user_type == "Customer": self.box_window.geometry('550x210') #是x 不是* elif self.config.user_type == "Developer": self.box_window.geometry('550x350') self.box_window.iconbitmap("image/icon1.ico") self.box_window.resizable(width=False, height=False) #宽不可变, 高可变, 默认为True # 报文显示 # Label(self.box_window, text="Current File:", font=("Times", 10), width=10, height=2).place(x=10, y=20) Label(self.box_window, text="路由表", font=("楷体", 10), width=10, height=2).place(x=10, y=20) self.routetable_pathname_display = Label(self.box_window, text="请选择 <xxx_路由表提取>", bg="white", font=("楷体", 9), width=60, height=2) self.routetable_pathname_display.place(x=90, y=22) self.openfileimg = PhotoImage(file='image/open.png') self.routetable_select_buntton = Button( self.box_window, image=self.openfileimg, command=self.select_route_table_callback) # self.routetable_select_buntton = Button(self.box_window, text="选择路由表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=12, height=2, command=self.select_route_table_callback) self.routetable_select_buntton.place(x=480, y=22) # # PostBuild报文表 # self.msgtable_buntton = Button(self.box_window, text="PostBuild报文表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=20, height=2, command=self.postbuild_msg_table_callback) # self.msgtable_buntton.place(x=100, y=80) # # PostBuild信号表 # self.signal_buntton = Button(self.box_window, text="PostBuild报文表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=20, height=2, command=self.postbuild_sig_table_callback) # self.signal_buntton.place(x=300, y=80) # if self.config.user_type == "Developer": # # DTC配置表 # self.dtc_config_buntton = Button(self.box_window, text="DTC配置表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=20, height=2, command=self.dtc_cfg_table_callback) # self.dtc_config_buntton.place(x=100, y=140) # # 节点使能配置表 # self.node_enable_buntton = Button(self.box_window, text="节点使能配置表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=20, height=2, command=self.node_en_cfg_table_callback) # self.node_enable_buntton.place(x=300, y=140) # # 诊断请求 # self.diag_req_buntton = Button(self.box_window, text="诊断请求表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=20, height=2, command=self.diag_req_table_callback) # self.diag_req_buntton.place(x=100, y=200) # # 诊断响应 # self.diag_res_buntton = Button(self.box_window, text="诊断响应表", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=20, height=2, command=self.diag_res_table_callback) # self.diag_res_buntton.place(x=300, y=200) self.radio_var = IntVar() self.radio_var.set(1) self.msgtable_radio = Radiobutton(self.box_window, text='PostBuild报文表', font=("楷体", 9), variable=self.radio_var, value=1, command=self.radio_callback) self.msgtable_radio.place(x=100, y=80) self.signaltable_radio = Radiobutton(self.box_window, text='PostBuild信号表', font=("楷体", 9), variable=self.radio_var, value=2, command=self.radio_callback) self.signaltable_radio.place(x=300, y=80) if self.config.user_type == "Developer": self.dtc_config_radio = Radiobutton(self.box_window, text='DTC配置表', font=("楷体", 9), variable=self.radio_var, value=3, command=self.radio_callback) self.dtc_config_radio.place(x=100, y=140) self.node_enable_radio = Radiobutton(self.box_window, text='节点使能配置表', font=("楷体", 9), variable=self.radio_var, value=4, command=self.radio_callback) self.node_enable_radio.place(x=300, y=140) self.diag_req_radio = Radiobutton(self.box_window, text='诊断请求表', font=("楷体", 9), variable=self.radio_var, value=5, command=self.radio_callback) self.diag_req_radio.place(x=100, y=200) self.diag_res_radio = Radiobutton(self.box_window, text='诊断响应表', font=("楷体", 9), variable=self.radio_var, value=6, command=self.radio_callback) self.diag_res_radio.place(x=300, y=200) # # 帮助 # self.helpimg = PhotoImage(file='image/help.png') # self.help_button = Button(self.box_window,image=self.helpimg, command=self.help_callback) # # self.help_button = Button(self.box_window, text="帮助", bg="lightgreen", activebackground="gold", \ # # fg="black", activeforeground="black", font=("楷体", 9), width=12, height=2, command=self.help_callback) # if self.config.user_type == "Customer": # self.help_button.place(x=130, y=140) # elif self.config.user_type == "Developer": # self.help_button.place(x=130, y=280) # # 绑定鼠标移入事件 # self.help_button.bind("<Enter>", self.enter_help_area) # # 绑定鼠标移出事件 # self.help_button.bind("<Leave> ", self.leave_help_area) # 运行 self.runimg = PhotoImage(file='image/run.png') self.run_button = Button(self.box_window, image=self.runimg, command=self.run) # self.run_button = Button(self.box_window, text="运行", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=10, height=2, command=self.run) if self.config.user_type == "Customer": self.run_button.place(x=130, y=140) elif self.config.user_type == "Developer": self.run_button.place(x=130, y=280) # 绑定鼠标移入事件 self.run_button.bind("<Enter>", self.enter_run_area) # 绑定鼠标移出事件 self.run_button.bind("<Leave> ", self.leave_run_area) # 返回 self.backimg = PhotoImage(file='image/exit.png') self.back_button = Button(self.box_window, image=self.backimg, command=self.back_callback) # self.back_button = Button(self.box_window, text="返回", bg="lightgreen", activebackground="gold", \ # fg="black", activeforeground="black", font=("楷体", 9), width=12, height=2, command=self.back_callback) if self.config.user_type == "Customer": self.back_button.place(x=340, y=140) elif self.config.user_type == "Developer": self.back_button.place(x=340, y=280) # 绑定鼠标移入事件 self.back_button.bind("<Enter>", self.enter_back_area) # 绑定鼠标移出事件 self.back_button.bind("<Leave> ", self.leave_back_area) # 鼠标悬浮提示 self.pre_click_hint_val = StringVar() #窗体自带的文本,新建一个值 self.pre_click_hint = Label(self.box_window, textvariable=self.pre_click_hint_val, font=("楷体", 8), width=8, height=1) self.pre_click_hint.place_forget() def close_win_callback(self): '''点击X关闭窗口回调函数''' self.box_window.destroy() del (self.main_window.tool_if) def select_route_table_callback(self): '''选择路由表回调函数''' self.public_for_all = public4all.Public4All() self.public_for_all.get_file_pathname() # 如选择文件不为空字符串,修改Label显示内容;否则回至初始化显示状态 if self.public_for_all.pathname != "": self.routetable_pathname_display[ "text"] = self.public_for_all.pathname self.routetable_pathname_display["anchor"] = W else: self.routetable_pathname_display["text"] = "请选择 <xxx_路由表提取>" self.routetable_pathname_display["anchor"] = "center" del self.public_for_all def postbuild_msg_table_callback(self): '''生成postbuil工具所用报文表''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": msg = msg2pbmsg.MsgTableConvert() msg.pathname = self.public_for_all.pathname try: msg.main_pandas() messagebox.showinfo(title='提示', message='转换完成') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息或查看报文表是否关闭') else: messagebox.showinfo(title='提示', message='请选择路由表') def postbuild_sig_table_callback(self): '''生成postbuil工具所用信号表''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": sig = sig2pbsig.SignalTableConvert(self.config) sig.pathname = self.public_for_all.pathname try: sig.main_pandas() messagebox.showinfo(title='提示', message='转换完成') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息或查看报文表是否关闭') else: messagebox.showinfo(title='提示', message='请选择路由表') def dtc_cfg_table_callback(self): '''生成代码DTC配置表''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": dtc_cfg = dtccfg.DtcConfig() dtc_cfg.pathname = self.public_for_all.pathname try: dtc_cfg.main() messagebox.showinfo(title='提示', message='转换完成') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') else: messagebox.showinfo(title='提示', message='请选择路由表') def node_en_cfg_table_callback(self): '''生成代码节点配置表''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": msg_node_en = msgnode.MsgNodeEnable() msg_node_en.pathname = self.public_for_all.pathname try: msg_node_en.main() messagebox.showinfo(title='提示', message='转换完成') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') else: messagebox.showinfo(title='提示', message='请选择路由表') def diag_req_table_callback(self): '''生成诊断请求表''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": diag_req = diagreqmsgcfg.DiagReqTable() diag_req.pathname = self.public_for_all.pathname diag_msg = diagmsgcfg.DiagResTable() diag_msg.pathname = self.public_for_all.pathname try: diag_req.main() diag_msg.main_req() messagebox.showinfo(title='提示', message='转换完成') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') else: messagebox.showinfo(title='提示', message='请选择路由表') def diag_res_table_callback(self): '''生成诊断响应表(硬件转发)''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": diag_msg = diagmsgcfg.DiagResTable() diag_msg.pathname = self.public_for_all.pathname try: diag_msg.main_res() messagebox.showinfo(title='提示', message='转换完成') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') else: messagebox.showinfo(title='提示', message='请选择路由表') def radio_callback(self): '''单选按钮回调函数''' print(self.radio_var.get()) def run(self): '''运行按钮回调函数''' if hasattr(self, "public_for_all"): if self.public_for_all.pathname != "": val = self.radio_var.get() if val == 1 or val == 4 or val == 5 or val == 6: '''报文表转换,节点使能,诊断请求,诊断响应''' msg_checkerror = checkerror.MsgCheckError() msg_checkerror.pathName = self.public_for_all.pathname ret = msg_checkerror.main() if ret != False: messagebox.showinfo( title='提示', message='{} 第 {} 行,第 {} 列出错:{}'.format( ret[0], ret[1], ret[2], ret[3])) return elif val == 2: '''信号表转换''' sig_checkerror = checkerror.SignalCheckError() sig_checkerror.pathName = self.public_for_all.pathname ret = sig_checkerror.main() if ret != False: messagebox.showinfo( title='提示', message='{} 第 {} 行,第 {} 列出错:{}'.format( ret[0], ret[1], ret[2], ret[3])) return elif val == 3: '''DTC配置''' pass if val == 1: msg = msg2pbmsg.MsgTableConvert(self.config) msg.pathname = self.public_for_all.pathname try: msg.main_pandas() messagebox.showinfo(title='提示', message='PostBuild报文表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息或查看报文表是否关闭') elif val == 2: sig = sig2pbsig.SignalTableConvert(self.config) sig.pathname = self.public_for_all.pathname try: sig.main_pandas() messagebox.showinfo(title='提示', message='PostBuild信号表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息或查看报文表是否关闭') elif val == 3: dtc_cfg = dtccfg.DtcConfig() dtc_cfg.pathname = self.public_for_all.pathname try: dtc_cfg.main() messagebox.showinfo(title='提示', message='DTC配置表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') elif val == 4: msg_node_en = msgnode.MsgNodeEnable() msg_node_en.pathname = self.public_for_all.pathname try: msg_node_en.main() messagebox.showinfo(title='提示', message='节点使能配置表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') elif val == 5: if self.config.platInfo == "GAW1.2_NewPlatform": diag_req = diagreqmsgcfg.DiagReqTable() diag_req.pathname = self.public_for_all.pathname try: diag_req.main() messagebox.showinfo(title='提示', message='诊断请求表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') else: diag_msg = diagmsgcfg.DiagResTable() diag_msg.pathname = self.public_for_all.pathname try: diag_msg.main_req() messagebox.showinfo(title='提示', message='诊断请求表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') elif val == 6: if self.config.platInfo == "GAW1.2_NewPlatform": messagebox.showinfo(title='提示', message='新平台诊断响应报文不需要配置') else: diag_msg = diagmsgcfg.DiagResTable() diag_msg.pathname = self.public_for_all.pathname try: diag_msg.main_res() messagebox.showinfo(title='提示', message='诊断响应表生成成功') except: messagebox.showinfo(title='提示', message='转换出错,请检查表格信息') else: messagebox.showinfo(title='提示', message='请选择路由表') def enter_run_area(self, *args): '''鼠标悬浮''' self.pre_click_hint_val.set("运行") if self.config.user_type == "Customer": self.pre_click_hint.place(x=130, y=120) elif self.config.user_type == "Developer": self.pre_click_hint.place(x=130, y=260) def leave_run_area(self, *args): '''鼠标离开''' self.pre_click_hint.place_forget() def help_callback(self): '''帮助''' ret = messagebox.askquestion(title='Help', message='这么简单还需要帮助?!!!') if ret == "yes": messagebox.showinfo(title='Help', message='哈哈哈 逗你呢 并没有什么帮助') def enter_help_area(self, *args): '''鼠标悬浮''' self.pre_click_hint_val.set("帮助") if self.config.user_type == "Customer": self.pre_click_hint.place(x=130, y=120) elif self.config.user_type == "Developer": self.pre_click_hint.place(x=130, y=260) def leave_help_area(self, *args): '''鼠标离开''' self.pre_click_hint.place_forget() def back_callback(self): '''返回''' self.box_window.destroy() del (self.main_window.tool_if) def enter_back_area(self, *args): '''鼠标悬浮''' self.pre_click_hint_val.set("返回") if self.config.user_type == "Customer": self.pre_click_hint.place(x=340, y=120) elif self.config.user_type == "Developer": self.pre_click_hint.place(x=340, y=260) def leave_back_area(self, *args): '''鼠标离开''' self.pre_click_hint.place_forget()
class main(Frame): def check_number(self, a): if (a.isdigit() == True): if (int(a) >= 0 and int(a) <= 9): return True return False def getNameButtonClicked(self, event): text = self.main_input.get() mode = self.mode.get() if (self.check_number(text) == True): number = int(text) if (mode == 0): #print(getName(number)) self.output_label.configure(text=getName(number)) elif (mode == 1): #print(getName(bin(number))) self.output_label.configure(text=getName(bin(number))) elif (mode == 2): #print(getName(oct(number))) self.output_label.configure(text=getName(oct(number))) else: #print(getName(hex(number))) self.output_label.configure(text=getName(hex(number))) else: #print('Неверный ввод') self.output_label.configure(text='Неверный ввод') def __init__(self, master): self.master = master self.master.title('Задание 1') self.master.geometry('1245x510+70+70') self.master.minsize(width=1245, height=510) self.master.maxsize(width=1245, height=510) # Главное поле ввода self.main_input = Entry(self.master, width=20, bd=3, font='times 15') self.main_input.place(x=500, y=50) self.main_input_label = Label(self.master, text='Введите число от 0 до 9') self.main_input_label.place(x=500, y=25) # Кнопка "Вывести имя" self.get_name_button = Button(self.master, width=20, bd=3, font='times 15', text="Вывести имя") self.get_name_button.place(x=100, y=50) self.get_name_button.bind('<Button-1>', self.getNameButtonClicked) self.output_label = Label(self.master, text='Здесь будет отображен результат', fg='#FF6A00') self.output_label.place(x=500, y=100) # 0 - Обычный режим # 1 - bin # 2 - oct # 3 - hex self.mode = IntVar() # Радиокнопки self.radiobutton_1 = Radiobutton(text="Обычный режим", value=0, variable=self.mode) self.radiobutton_1.place(x=100, y=150) self.radiobutton_2 = Radiobutton(text="bin", value=1, variable=self.mode) self.radiobutton_2.place(x=100, y=190) self.radiobutton_3 = Radiobutton(text="oct", value=2, variable=self.mode) self.radiobutton_3.place(x=100, y=230) self.radiobutton_4 = Radiobutton(text="hex", value=3, variable=self.mode) self.radiobutton_4.place(x=100, y=270)
def main(self): # main frame self.root = Tk() self.root.geometry('500x450') self.root.title("Registration Form") # data binding self.USERNAME = StringVar(self.root) self.EMAIL = StringVar(self.root) self.PASSWORD = StringVar(self.root) self.GENDER = StringVar(self.root) self.UID = StringVar(self.root) # Registration form label_0 = Label(self.root, text="Registration form", width=20, font=("bold", 20)) label_0.place(x=90, y=53) # FullName label & entry label_1 = Label(self.root, text="Username *", width=20, font=("bold", 10)) label_1.place(x=80, y=130) entry_1 = Entry(self.root, textvariable=self.USERNAME) entry_1.place(x=240, y=130) # self.EMAIL label & entry label_2 = Label(self.root, text="Email *", width=20, font=("bold", 10)) label_2.place(x=68, y=180) entry_2 = Entry(self.root, textvariable=self.EMAIL) entry_2.place(x=240, y=180) # self.PASSWORD label & entry label_2_ = Label(self.root, text="Password *", width=20, font=("bold", 10)) label_2_.place(x=68, y=230) entry_2_ = Entry(self.root, textvariable=self.PASSWORD, show="*") entry_2_.place(x=240, y=230) # self.GENDER label & radio-box label_3 = Label(self.root, text="Gender", width=20, font=("bold", 10)) label_3.place(x=70, y=280) optionMale = Radiobutton(self.root, text="Male", padx=5, variable=self.GENDER, value=1) optionMale.place(x=235, y=280) optionFemale = Radiobutton(self.root, text="Female", padx=20, variable=self.GENDER, value=2) optionFemale.place(x=290, y=280) # Age label & entry label_4 = Label(self.root, text="Student ID *", width=20, font=("bold", 10)) label_4.place(x=70, y=330) entry_3 = Entry(self.root, textvariable=self.UID) entry_3.place(x=240, y=330) # Error label self.error_label = Label(self.root, width=60, font=("bold", 8)) self.error_label.place(x=65, y=370) # Submit button btn = Button(self.root, text='Submit', width=20, command=self.Register, bg='brown', fg='white') btn.place(x=180, y=400) # Login button btn_2 = Button(self.root, text='Login', width=10, command=self.navigate_to_login, bg='#0F0F0F', fg='#33FF33', borderwidth=0, font="Verdana 10 underline") btn_2.place(x=350, y=400) # theme color hacker self.root.config(bg="#0F0F0F") label_0.config(bg="#0F0F0F", fg="#33FF33") label_1.config(bg="#0F0F0F", fg="#33FF33") label_2.config(bg="#0F0F0F", fg="#33FF33") label_2_.config(bg="#0F0F0F", fg="#33FF33") label_3.config(bg="#0F0F0F", fg="#33FF33") label_4.config(bg="#0F0F0F", fg="#33FF33") entry_1.config(bg="#0F0F0F", fg="#33FF33", insertbackground="#33FF33") entry_3.config(bg="#0F0F0F", fg="#33FF33", insertbackground="#33FF33") entry_2.config(bg="#0F0F0F", fg="#33FF33", insertbackground="#33FF33") entry_2_.config(bg="#0F0F0F", fg="#33FF33", insertbackground="#33FF33") optionFemale.config(bg="#0F0F0F", fg="#33FF33") optionMale.config(bg="#0F0F0F", fg="#33FF33") btn.config(bg="#0F0F0F", fg="#FFFFFF", activebackground="#0F0F0F", activeforeground="#FFFFFF") self.error_label.config(bg="#0F0F0F") # it is use for display the registration form on the window self.root.mainloop() print("registration form seccussfully created...")
class SearchHelper: def __init__(self, searchframe): self.frame = searchframe # keyword entry largefont = ('Veranda', 24) self.ent_keyword = Entry(self.frame, width=40, relief='raised', font=largefont, bd=1) # todo <Return> and entry is not empty call search() self.but_search = Button( self.frame, text='Search', width=15, state='disable', font="Veranda 16", command=lambda: self.frame.search( 'http://cbrown686-test.apigee.net/cyberapi/articles?q=keywordtitlebody&title=' + self.ent_keyword.get() + '&body=' + self.ent_keyword.get())) self.var = IntVar() self.var.set(0) self.check_filter = Checkbutton(self.frame, text="Advanced Filter", onvalue=1, offvalue=0, variable=self.var, command=self.filter_op, font="Veranda 16") calltipwindow.createToolTip( self.check_filter, "Click here for options to narrow your search") calltipwindow.createToolTip( self.ent_keyword, "Enter a word or phrase here to search by.") self.ent_keyword.bind('<Escape>', self.clear_text) self.ent_keyword.bind( '<Key>', lambda event: self.callenable(event, 'DefaultSearch')) if self.var.get(): self.frame.searchButton(None) # filter stuff self.appearing_label = Label(searchframe, text='Appearing In:', background='#282828', font=15, foreground='#5DE0DC') self.box_value = StringVar() self.box = Combobox(searchframe, textvariable=self.box_value) calltipwindow.createToolTip( self.appearing_label, "Select where you want us to search " "for your provided search phrase.") calltipwindow.createToolTip( self.box, "Select where you want us to search " "for your provided search phrase.") self.box['values'] = ('Default', 'Title', 'Body', 'URL') self.box.current(0) self.box.bind('<<ComboboxSelected>>', self.setbaseurl) # author self.author_label = Label(searchframe, text='Author:', background='#282828', font=15, foreground='#5DE0DC') self.author_entry = Entry(searchframe, width=22, bd=2, background='#9A9A9A') calltipwindow.createToolTip( self.author_label, "Enter an author's first and/or last name (not case-sensitive).") calltipwindow.createToolTip( self.author_entry, "Enter an author's first and/or last name (not case-sensitive).") # subjectivity self.fsub_label = Label(searchframe, text='Subjectivity:', background='#282828', font=15, foreground='#5DE0DC') calltipwindow.createToolTip( self.fsub_label, "Choose an option here if you only want to see articles" " that are more objectively or subjectively written") self.var2 = IntVar() self.var2.set(1) self.fsub_nv = Radiobutton(searchframe, text="Don't Care", variable=self.var2, value=1, background='#282828', foreground='#5DE0DC') calltipwindow.createToolTip( self.fsub_nv, "Select this if you want all articles returned regarless of how they are written." ) self.fsub_gt = Radiobutton(searchframe, text='More Subjective', variable=self.var2, value=2, background='#282828', foreground='#5DE0DC') calltipwindow.createToolTip( self.fsub_gt, "Select this if you only want articles that are more subjectively written." ) self.fsub_lt = Radiobutton(searchframe, text='More Objective', variable=self.var2, value=3, background='#282828', foreground='#5DE0DC') calltipwindow.createToolTip( self.fsub_lt, "Select this if you only want articles that are more objectively written." ) # date self.fD_label = Label(searchframe, text='Date:', background='#282828', font=15, foreground='#5DE0DC') self.fD_format = Label(searchframe, text='00/00/0000', background='#282828', foreground='#BBBBBB') self.fD_format.configure(foreground='grey') self.fD_beinlab = Label(searchframe, text='From:', background='#282828', foreground='#BBBBBB') self.fD_endlab = Label(searchframe, text='To:', background='#282828', foreground='#BBBBBB') self.fD_ent = Entry(searchframe, width=10, bd=2, background='#9A9A9A') self.fD_ent.insert('end', '01/01/0001') self.fD_ent2 = Entry(searchframe, width=10, bd=2, background='#9A9A9A') self.fD_ent2.insert('end', strftime('%m/%d/%Y')) calltipwindow.createToolTip( self.fD_label, "Narrow your results to articles published in the dates here.") calltipwindow.createToolTip( self.fD_format, "Narrow your results to articles published in the dates here.") calltipwindow.createToolTip( self.fD_beinlab, "Narrow your results to articles published in the dates here.") calltipwindow.createToolTip( self.fD_endlab, "Narrow your results to articles published in the dates here.") calltipwindow.createToolTip(self.fD_ent, "Enter Start Date here.") calltipwindow.createToolTip(self.fD_ent2, "Enter End Date here.") # filter placements offset = 100 self.appearing_label.place(x=400, y=380 + offset) # appearing pick self.box.place(x=510, y=380 + offset) # author label self.author_label.place(x=400, y=405 + offset) # author entry self.author_entry.place(x=510, y=405 + offset) # subjectivity self.fsub_label.place(x=400, y=430 + offset) self.fsub_nv.place(x=510, y=430 + offset) self.fsub_gt.place(x=510, y=455 + offset) self.fsub_lt.place(x=510, y=480 + offset) # date self.fD_label.place(x=400, y=505 + offset) self.fD_format.place(x=445, y=507 + offset) self.fD_beinlab.place(x=510, width=45, y=505 + offset) self.fD_ent.place(x=555, width=65, y=505 + offset) self.fD_endlab.place(x=630, y=505 + offset) self.fD_ent2.place(x=660, width=65, y=505 + offset) # buttons self.but_search.place(relx=.505, rely=.6, anchor=W) # ENTRY BOX for keyword self.ent_keyword.place(relx=.5, rely=.5, anchor=CENTER) # check button self.check_filter.place(relx=.495, rely=.6, relheight=.059, anchor=E) self.hidefilters() #filter options populate uppon check box of Advanced search option def filter_op(self): if self.var.get() is 1: self.showfilters() else: self.hidefilters() def resetsearch(self): self.ent_keyword.destroy() self.but_search.destroy() self.check_filter.destroy() self.appearing_label.destroy() self.box.destroy() self.author_label.destroy() self.author_entry.destroy() self.fsub_label.destroy() self.fsub_nv.destroy() self.fsub_gt.destroy() self.fsub_lt.destroy() self.fD_label.destroy() self.fD_format.destroy() self.fD_ent.destroy() self.fD_beinlab.destroy() self.fD_endlab.destroy() self.fD_ent2.destroy() self.__init__(self.frame) def hidefilters(self): self.appearing_label.lower() self.box.lower() self.author_label.lower() self.author_entry.lower() self.fsub_label.lower() self.fsub_nv.lower() self.fsub_gt.lower() self.fsub_lt.lower() self.fD_label.lower() self.fD_format.lower() self.fD_ent.lower() self.fD_beinlab.lower() self.fD_endlab.lower() self.fD_ent2.lower() def showfilters(self): self.appearing_label.lift() self.box.lift() self.author_label.lift() self.author_entry.lift() self.fsub_label.lift() self.fsub_nv.lift() self.fsub_gt.lift() self.fsub_lt.lift() self.fD_label.lift() self.fD_format.lift() self.fD_ent.lift() self.fD_beinlab.lift() self.fD_endlab.lift() self.fD_ent2.lift() def showsearch(self): self.ent_keyword.lift() self.but_search.lift() self.check_filter.lift() if self.var.get(): self.showfilters() def hidesearch(self): self.ent_keyword.lower() self.but_search.lower() self.check_filter.lower() def setbaseurl(self, event): if self.box.current() is 0: self.but_search.config(command=lambda: self.frame.search( 'http://cbrown686-test.apigee.net/cyberapi/articles?q=keywordtitlebody&title=' + self.ent_keyword.get() + '&body=' + self.ent_keyword.get())) elif self.box.current() is 1: self.but_search.config(command=lambda: self.frame.search( 'http://cbrown686-test.apigee.net/cyberapi/articles?q=keywordtitle&title=' + self.ent_keyword.get())) elif self.box.current() is 2: self.but_search.config(command=lambda: self.frame.search( 'http://cbrown686-test.apigee.net/cyberapi/articles?q=bodyonly&body=' + self.ent_keyword.get())) elif self.box.current() is 3: self.but_search.config(command=lambda: self.frame.search( 'http://cbrown686-test.apigee.net/cyberapi/articles?q=uri&uripath=' + self.ent_keyword.get())) def addurlfilters(self, url): if self.var.get(): au = self.author_entry.get() au = au.replace(' ', '+') # var2 is the state of the radio check button if self.var2.get() == 2: url = url + '&author=' + au + '&sub=gt&sdate=' + self.fD_ent.get( ) + '&edate=' + self.fD_ent2.get() # print(url) elif self.var2.get() == 3: url = url + '&author=' + au + '&sub=gt&sdate=' + self.fD_ent.get( ) + '&edate=' + self.fD_ent2.get() else: url = url + '&author=' + au + '&sub=&sdate=' + self.fD_ent.get( ) + '&edate=' + self.fD_ent2.get() else: url = url + '&author=&sub=&sdate=01/01/0001&edate=' + strftime( '%m/%d/%Y') return url # Hitting escape when editing the ENTRY box will clear it and disable the search button from being able to be used. def clear_text(self): self.ent_keyword.delete(0, 'end') self.but_search.configure(state='disable') def callenable(self, event, searchtype): self.frame.after(100, lambda: self.enablesearch(event, searchtype)) # event bind when Return is entered after a title keyword is entered will enable the search button. def enablesearch(self, event, searchtype): string = '' if searchtype == 'DefaultSearch': string = self.ent_keyword.get() if string.strip() != '': self.but_search.configure(state='normal') else: self.but_search.configure(state='disabled')
class Grapfics(): def __init__(self): self.aut = '' self.root = Tk() self.root.state('zoomed') self.root.geometry( str(self.root.winfo_screenwidth() - 200) + 'x' + str(self.root.winfo_screenheight() - 200)) self.pb = ttk.Progressbar(self.root, orient=HORIZONTAL, length=200, mode='determinate') self.menu = Menu(self.root) self.menu.add_command(label="О программе", command=self.prog_menu) self.root.config(menu=self.menu) self.l_1 = Label(self.root, text="Авторизация в vk") self.l_2 = Label(self.root, text="Формат списка") self.l_3 = Label(self.root, text="Отчет") self.l_4 = Label(self.root, text="Вы не авторизованы") self.l_5 = Label(self.root, text="") self.en_1 = Entry(self.root) self.en_2 = Entry(self.root) self.pos_1 = IntVar() self.pos_1.set(0) self.rb_1 = Radiobutton( self.root, text="1. http://vk.com/groupID http://vk.com/userID", variable=self.pos_1, value=0) self.rb_2 = Radiobutton( self.root, text="1. http://vk.com/userID http://vk.com/groupID", variable=self.pos_1, value=1) pos_2 = IntVar() pos_2.set(0) self.rb_3 = Radiobutton(self.root, text="По участникам", variable=pos_2, value=0) self.rb_4 = Radiobutton(self.root, text="По группам", variable=pos_2, value=1) self.frame_1 = Frame(self.root) self.tex = Text(self.frame_1, width=60, height=35, font="Verdana 6", wrap=WORD) self.scr = Scrollbar(self.frame_1, command=self.tex.yview) self.tex.configure(yscrollcommand=self.scr.set) self.splitter = PanedWindow(self.root, orient=HORIZONTAL, height=500, width=800) self.frame_2 = Frame(self.splitter, width='20') self.table = Table(self.frame_2) self.table.pack(expand=YES, fill=BOTH) self.splitter.add(self.frame_2) self.scr.pack(side='right', fill='y') self.frame_1.place(x='20', y='205') self.tex.pack(fill='both') if os.path.exists('vk_config.v2.json'): with open('vk_config.v2.json', 'r') as t: q = json.load(t) for i in q.keys(): log = i tok = str(q).split("'access_token': '")[1].split("'")[0] self.vk = vk_api.VkApi(login=log, token=tok) self.vk.auth(token_only=True) self.l_4['text'] = self.vk.method( 'users.get')[0]['first_name'] + '\n' + self.vk.method( 'users.get')[0]['last_name'] self.b_1 = Button(self.root, text="Войти", command=self.au) self.b_2 = Button(self.root, text="Проверить вступления", width=20, command=self.k) self.b_3 = Button(self.root, text="Отчет", width=20, command=lambda: Otch().start()) self.b_4 = Button(self.root, text="Выход", command=self.ex) self.splitter.place(x='450', y='205') self.en_1.place(x='20', y='55') self.en_2.place(x='20', y='80') self.b_1.place(x='170', y='50') self.b_2.place(x='350', y='140') self.b_3.place(x='350', y='170') self.b_4.place(x='170', y='80') self.l_1.place(x='20', y='30') self.l_2.place(x='20', y='120') #self.l_3.place(x = '550', y = '120') self.l_4.place(x='220', y='55') self.rb_1.place(x='20', y='140') self.rb_2.place(x='20', y='160') #self.rb_3.place(x = '550', y = '140') #self.rb_4.place(x = '550', y = '160') self.pb.place(x='20', y='650') self.l_5.place(x='225', y='650') self.root.mainloop() def k(self): self.l_5['text'] = "" self.table.destroy() self.table = Table(self.frame_2) self.table.pack(expand=YES, fill=BOTH) if os.path.exists('vk_config.v2.json'): if requests.get( 'http://3.12.164.15/table/%s' % str(self.vk.method('users.get')[0]['id'])).text == 'True': x = threading.Thread(target=st, args=(self.pos_1.get(), self.tex.get('1.0', 'end'), self.vk, self.table, self.l_5, self.pb)) x.start() else: messagebox.showinfo( "Ошибка!", "К вашему аккаунту не привязан ключ для работы программы\nОбратитесь по ссылке: https://vk.com/id124569304" ) else: if requests.get( 'http://3.12.164.15/table/%s' % str(self.aut.vk_session.method('users.get')[0]['id']) ).text == 'True': x = threading.Thread(target=st, args=(self.pos_1.get(), self.tex.get('1.0', 'end'), self.aut.vk_session, self.table, self.l_5, self.pb)) x.start() else: messagebox.showinfo( "Ошибка!", "К вашему аккаунту не привязан ключ для работы программы\nОбратитесь по ссылке: https://vk.com/id124569304" ) def ex(self): if os.path.exists('vk_config.v2.json'): os.remove( os.path.join(os.path.abspath(os.path.dirname(__file__)), 'vk_config.v2.json')) self.l_4['text'] = "Вы не аторизованы" def au(self): if not os.path.exists('vk_config.v2.json'): self.aut = Authentication() self.aut.main(self.en_1.get(), self.en_2.get(), self.l_4) else: messagebox.showinfo( "Ошибка!", "Для повторной авторизации нужно выйти из нынешнего аккаунта") def prog_menu(self): self.pr = Tk() self.pr.geometry('500x150') self.l1_1 = Label( self.pr, text= "Программа сделана для осуществление проверки подписки пользователей\n\n Разработчик программы:\nvk - https://vk.com/id310539944\nПочта - [email protected]" ) self.l1_1.place(x='20', y='20') self.pr.mainloop()
bg="blue", fg="skyblue") button3.place(x=60, y=140, height=40, width=50) entry3 = Entry(window, width=20, bd=10) entry3.place(x=320, y=200) def myfunc3(): ids = int(entry3.get()) sql = "DELETE FROM customers1 WHERE id=%s" mycursor.execute(sql, (ids, )) mydb.commit() print("record successfully deleted") entry3.delete("0", "end") button4 = Button(window, text="delete user", bg="blue", fg="skyblue", command=myfunc3) button4.place(x=320, y=250, height=35, width=70) radiobutton1 = Radiobutton(window, text="hindi", variable=1) radiobutton2 = Radiobutton(window, text="englist", variable=2) radiobutton1.place(x=320, y=300) radiobutton2.place(x=320, y=340) window.mainloop()
def busqueda(): toor = Toplevel() # Creamos una ventana toor.title("Busqueda") # Titulo de la ventana toor.geometry("425x420") # Tamaño de la ventana parame = [] numoer = IntVar() def valor_boton(*argus): nume = numoer.get() if nume == 1: lisbo.delete(0, "end") vali = entra.get() if vali.isdigit(): bus_ord() else: lisbo.delete(0, "end") lisbo.insert(0, "Ingrese un numero de orden") elif nume == 2: lisbo.delete(0, "end") busqueda_g("apellido") elif nume == 3: vali = entra.get() if vali.isdigit(): lisbo.delete(0, "end") busqueda_g("telefono") else: lisbo.delete(0, "end") lisbo.insert(0, "Ingrese un numero de telefono") elif nume == 4: lisbo.delete(0, "end") busqueda_g("tipo") elif nume == 5: lisbo.delete(0, "end") busqueda_g("marca") else: lisbo.delete(0, "end") lisbo.insert(0, "Seleccione una opcion") def busqueda_g(parametro): lisbo.delete(0, "end") parame.clear() cadena = entra.get() namae = str(BaseDatos.select().order_by(BaseDatos.orden.desc()).get()) if not cadena: lisbo.delete(0, "end") lisbo.insert(0, "Seleccione una opcion") else: for i in range(1, int(namae) + 1): if parametro == "apellido": verili = BaseDatos.get(BaseDatos.orden == i).apellido elif parametro == "telefono": verili = BaseDatos.get(BaseDatos.orden == i).telefono elif parametro == "tipo": verili = BaseDatos.get(BaseDatos.orden == i).tipo elif parametro == "marca": verili = BaseDatos.get(BaseDatos.orden == i).marca else: lisbo.delete(0, "end") lisbo.insert(0, "Seleccione una opcion") if cadena in verili: parame.append("---------------------------") parame.append( "Otros: " + BaseDatos.get(BaseDatos.orden == i).otros, ) parame.append( "Falla: " + BaseDatos.get(BaseDatos.orden == i).falla, ) parame.append( "Modelo: " + BaseDatos.get(BaseDatos.orden == i).modelo, ) parame.append( "Marca: " + BaseDatos.get(BaseDatos.orden == i).marca, ) parame.append( "Tipo: " + BaseDatos.get(BaseDatos.orden == i).tipo, ) parame.append("Direccion: " + BaseDatos.get( BaseDatos.orden == i).direccion) parame.append( "Telefono: " + BaseDatos.get(BaseDatos.orden == i).telefono, ) parame.append( "Apellido: " + BaseDatos.get(BaseDatos.orden == i).apellido, ) parame.append( "Nombre: " + BaseDatos.get(BaseDatos.orden == i).nombre, ) parame.append( "Fecha: " + str(BaseDatos.get(BaseDatos.orden == i).fecha), ) parame.append("N° de Orden: " + str(i)) for item in parame: # Insertamos los items en un Listbox lisbo.insert(0, item) # valididar que el dato ingresado sea un numero y no este vacio def bus_ord(*argo): lisbo.delete(0, "end") vali = entra.get() if vali.isdigit(): lisbo.delete(0, "end") veri = entra.get() veril = BaseDatos.select().where(BaseDatos.orden == veri) if veril.exists(): insertar() else: lisbo.insert(0, "Orden de reparacion") lisbo.insert(1, " no encotrada.") else: lisbo.delete(0, "end") lisbo.insert(0, "Ingrese un numero") # creamos la lista y la insertamos en el listbox def insertar(): lisbo.delete(0, "end") parame.clear() cadena = entra.get() # Agregamos los elementos a la lista parame.append( "Otros: " + BaseDatos.get(BaseDatos.orden == cadena).otros, ) parame.append( "Falla: " + BaseDatos.get(BaseDatos.orden == cadena).falla, ) parame.append( "Modelo: " + BaseDatos.get(BaseDatos.orden == cadena).modelo, ) parame.append( "Marca: " + BaseDatos.get(BaseDatos.orden == cadena).marca, ) parame.append("Tipo: " + BaseDatos.get(BaseDatos.orden == cadena).tipo, ) parame.append("Direccion: " + BaseDatos.get(BaseDatos.orden == cadena).direccion) parame.append( "Telefono: " + BaseDatos.get(BaseDatos.orden == cadena).telefono, ) parame.append( "Apellido: " + BaseDatos.get(BaseDatos.orden == cadena).apellido, ) parame.append( "Nombre: " + BaseDatos.get(BaseDatos.orden == cadena).nombre, ) parame.append( "Fecha: " + str(BaseDatos.get(BaseDatos.orden == cadena).fecha), ) parame.append("N° de Orden: " + str(cadena)) for item in parame: # Insertamos los items en un Listbox lisbo.insert(0, item) # posicionamiento de los widget de tkinter texto = Label(toor, text="Buscar por:") texto.place(x=10, y=0) busq1 = Radiobutton(toor, text="Orden", value=1, variable=numoer) busq1.place(x=0, y=25) busq2 = Radiobutton(toor, text="Apellido", value=2, variable=numoer) busq2.place(x=70, y=25) busq3 = Radiobutton(toor, text="Telefono", value=3, variable=numoer) busq3.place(x=160, y=25) busq4 = Radiobutton(toor, text="Tipo", value=4, variable=numoer) busq4.place(x=250, y=25) busq5 = Radiobutton(toor, text="Marca", value=5, variable=numoer) busq5.place(x=310, y=25) entra = Entry(toor, width=10, bd=3) entra.place(x=150, y=50) boton = Button(toor, text="Aceptar", command=valor_boton) boton.place(x=155, y=80) boton.bind("<Return>", valor_boton) # Esto es para el enter lisbo = Listbox(toor, borderwidth=5, width=50, height=15) lisbo.place(x=5, y=120) toor.mainloop()
class Interfaz(object): def __init__(self, lista, app): self.vista1 = None self.btnCliente = None self.btnServidor = None self.vista2 = None self.lblTitulo = None self.lblMensaje = None self.lblIp = None self.txtMensaje = None self.txtIp = None self.btnEnviar = None self.uso = 0 self.cambio = False self.msj = None self.straux = None self.ip = None self.lista = lista self.app = app self.lblAlf = None self.rbError = None self.rbNoerror = None self.rbValue = None def initVista1(self): self.vista1 = tk.Tk() self.vista1.title("Tarea de Stack de Protocolos") self.vista1.geometry("400x200") self.vista1.resizable(0, 0) self.btnCliente = Button(self.vista1, text="Cliente", font=("Courier", 14, "bold"), command=lambda: self.initVista2(1)) self.btnCliente.config(bg="#ffffff", fg="#1d1d1d", width=24, height=2) self.btnCliente.place(x=65, y=40) self.btnServidor = Button(self.vista1, text="Servidor", font=("Courier", 14, "bold"), command=lambda: self.initVista2(2)) self.btnServidor.config(bg="#ffffff", fg="#1d1d1d", width=24, height=2) self.btnServidor.place(x=65, y=110) self.vista1.mainloop() def initVista2(self, uso): self.uso = uso self.vista1.destroy() self.vista2 = tk.Tk() self.vista2.title("Tarea de Stack de Protocolos") self.vista2.geometry("1000x750") self.vista2.resizable(0, 0) self.msj = StringVar(self.vista2) self.ip = StringVar(self.vista2) self.straux = StringVar(self.vista2) self.rbValue = StringVar(self.vista2) self.rbValue.set("1") if (uso == 1): self.mostrarVista2("Cliente") else: self.cambio = True self.mostrarVista2("Servidor") hilo = threading.Thread(target=self.initServidor) hilo.start() self.vista2.mainloop() def initServidor(self): self.app.recibirMensaje() def mostrarVista2(self, texto): #Encabezado self.lblTitulo = Label(self.vista2, text=texto, borderwidth=2, relief="groove") self.lblTitulo.config(bg="#ffffff", font=("Courier", 16, tkFont.BOLD), width=75, height=2) self.lblTitulo.place(x=10, y=10) #Etiqueta del encabezado del mensaje self.lblMensaje = Label(self.vista2, text="Mensaje a Enviar", borderwidth=2, relief="groove") self.lblMensaje.config(bg="#ffffff", font=("Courier", 15, tkFont.BOLD), width=20, height=2) self.lblMensaje.place(x=10, y=80) #Etiqueta del contenido del mensaje self.txtMensaje = Entry(self.vista2, textvariable=self.msj, borderwidth=3, relief="groove") self.txtMensaje.place(x=280, y=80, height=50, width=710) self.txtMensaje.config(state='disabled') #Etiqueta del encabezado de IP self.lblIp = Label(self.vista2, text="IP de destino", borderwidth=2, relief="groove") self.lblIp.config(bg="#ffffff", font=("Courier", 15, tkFont.BOLD), width=20, height=2) self.lblIp.place(x=10, y=150) #Text box de IP self.txtIp = Entry(self.vista2, textvariable=self.ip, borderwidth=3, relief="groove") self.txtIp.place(x=280, y=150, height=50, width=710) #Label alfabeto self.lblAlf = Label(self.vista2, text="", borderwidth=2, relief="groove") self.lblAlf.config(bg="#ffffff", width=45, height=3) self.lblAlf.place(x=10, y=690) #Boton para enviar el mensaje self.btnEnviar = Button(self.vista2, text="Enviar mensaje", font=("Courier", 14, "bold"), command=self.obtenerDatos) self.btnEnviar.config(bg="#ffffff", fg="#1d1d1d", width=24, height=2) self.btnEnviar.place(x=350, y=685) #botone teclas btnA = Button(self.vista2, text="A : Ʉ", command=lambda: self.escribirMensaje("A"), height=2, width=10) btnA.place(x=170, y=230) btnB = Button(self.vista2, text="B : ϐ", command=lambda: self.escribirMensaje("B"), height=2, width=10) btnB.place(x=250, y=230) btnC = Button(self.vista2, text="C : Ȼ", command=lambda: self.escribirMensaje("C"), height=2, width=10) btnC.place(x=330, y=230) btnD = Button(self.vista2, text="D : Δ", command=lambda: self.escribirMensaje("D"), height=2, width=10) btnD.place(x=410, y=230) btnE = Button(self.vista2, text="E : Ʃ", command=lambda: self.escribirMensaje("E"), height=2, width=10) btnE.place(x=490, y=230) btnF = Button(self.vista2, text="F : ƒ", command=lambda: self.escribirMensaje("F"), height=2, width=10) btnF.place(x=570, y=230) btnG = Button(self.vista2, text="G : Ƃ", command=lambda: self.escribirMensaje("G"), height=2, width=10) btnG.place(x=650, y=230) btnH = Button(self.vista2, text="H : Ħ", command=lambda: self.escribirMensaje("H"), height=2, width=10) btnH.place(x=730, y=230) btnI = Button(self.vista2, text="I : Ý", command=lambda: self.escribirMensaje("I"), height=2, width=10) btnI.place(x=170, y=280) btnJ = Button(self.vista2, text="J : ł", command=lambda: self.escribirMensaje("J"), height=2, width=10) btnJ.place(x=250, y=280) btnK = Button(self.vista2, text="K : ʞ", command=lambda: self.escribirMensaje("K"), height=2, width=10) btnK.place(x=330, y=280) btnL = Button(self.vista2, text="L : ȴ", command=lambda: self.escribirMensaje("L"), height=2, width=10) btnL.place(x=410, y=280) btnM = Button(self.vista2, text="M : μ", command=lambda: self.escribirMensaje("M"), height=2, width=10) btnM.place(x=490, y=280) btnN = Button(self.vista2, text="N : Ɲ", command=lambda: self.escribirMensaje("N"), height=2, width=10) btnN.place(x=570, y=280) btnO = Button(self.vista2, text="O : Φ", command=lambda: self.escribirMensaje("O"), height=2, width=10) btnO.place(x=650, y=280) btnP = Button(self.vista2, text="P : π", command=lambda: self.escribirMensaje("P"), height=2, width=10) btnP.place(x=730, y=280) btnQ = Button(self.vista2, text="Q : ϑ", command=lambda: self.escribirMensaje("Q"), height=2, width=10) btnQ.place(x=170, y=330) btnR = Button(self.vista2, text="R : ɻ", command=lambda: self.escribirMensaje("R"), height=2, width=10) btnR.place(x=250, y=330) btnS = Button(self.vista2, text="S : Ϟ", command=lambda: self.escribirMensaje("S"), height=2, width=10) btnS.place(x=330, y=330) btnT = Button(self.vista2, text="T : ʈ", command=lambda: self.escribirMensaje("T"), height=2, width=10) btnT.place(x=410, y=330) btnU = Button(self.vista2, text="U : Ʊ", command=lambda: self.escribirMensaje("U"), height=2, width=10) btnU.place(x=490, y=330) btnV = Button(self.vista2, text="V : ƛ", command=lambda: self.escribirMensaje("V"), height=2, width=10) btnV.place(x=570, y=330) btnW = Button(self.vista2, text="W : Ψ", command=lambda: self.escribirMensaje("W"), height=2, width=10) btnW.place(x=650, y=330) btnX = Button(self.vista2, text="X : ¤", command=lambda: self.escribirMensaje("X"), height=2, width=10) btnX.place(x=730, y=330) btnY = Button(self.vista2, text="Y : ɣ", command=lambda: self.escribirMensaje("Y"), height=2, width=10) btnY.place(x=170, y=380) btnZ = Button(self.vista2, text="Z : ζ", command=lambda: self.escribirMensaje("Z"), height=2, width=10) btnZ.place(x=250, y=380) btn0 = Button(self.vista2, text="0 : Ø", command=lambda: self.escribirMensaje("0"), height=2, width=10) btn0.place(x=330, y=380) btn1 = Button(self.vista2, text="1 : Ⅰ", command=lambda: self.escribirMensaje("1"), height=2, width=10) btn1.place(x=410, y=380) btn2 = Button(self.vista2, text="2 : Ⅱ", command=lambda: self.escribirMensaje("2"), height=2, width=10) btn2.place(x=490, y=380) btn3 = Button(self.vista2, text="3 : Ⅲ", command=lambda: self.escribirMensaje("3"), height=2, width=10) btn3.place(x=570, y=380) btn4 = Button(self.vista2, text="4 : Ⅳ", command=lambda: self.escribirMensaje("4"), height=2, width=10) btn4.place(x=650, y=380) btn5 = Button(self.vista2, text="5 : Ⅴ", command=lambda: self.escribirMensaje("5"), height=2, width=10) btn5.place(x=730, y=380) btn6 = Button(self.vista2, text="6 : Ⅵ", command=lambda: self.escribirMensaje("6"), height=2, width=10) btn6.place(x=170, y=430) btn7 = Button(self.vista2, text="7 : Ⅶ", command=lambda: self.escribirMensaje("7"), height=2, width=10) btn7.place(x=250, y=430) btn8 = Button(self.vista2, text="8 : Ⅷ", command=lambda: self.escribirMensaje("8"), height=2, width=10) btn8.place(x=330, y=430) btn9 = Button(self.vista2, text="9 : Ⅸ", command=lambda: self.escribirMensaje("9"), height=2, width=10) btn9.place(x=410, y=430) btn161 = Button(self.vista2, text="¡ : ↑", command=lambda: self.escribirMensaje("¡"), height=2, width=10) btn161.place(x=490, y=430) btn33 = Button(self.vista2, text="! : ↓", command=lambda: self.escribirMensaje("!"), height=2, width=10) btn33.place(x=570, y=430) btn63 = Button(self.vista2, text="? : ⌠", command=lambda: self.escribirMensaje("?"), height=2, width=10) btn63.place(x=650, y=430) btn191 = Button(self.vista2, text="¿ : ⌡", command=lambda: self.escribirMensaje("¿"), height=2, width=10) btn191.place(x=730, y=430) btnComa = Button(self.vista2, text="\" : °", command=lambda: self.escribirMensaje("\""), height=2, width=10) btnComa.place(x=170, y=480) btn35 = Button(self.vista2, text="# : ∞", command=lambda: self.escribirMensaje("#"), height=2, width=10) btn35.place(x=250, y=480) btn36 = Button(self.vista2, text="$ : †", command=lambda: self.escribirMensaje("$"), height=2, width=10) btn36.place(x=330, y=480) btn37 = Button(self.vista2, text="% : └", command=lambda: self.escribirMensaje("%"), height=2, width=10) btn37.place(x=410, y=480) btn38 = Button(self.vista2, text="& : ٨", command=lambda: self.escribirMensaje("&"), height=2, width=10) btn38.place(x=490, y=480) btn39 = Button(self.vista2, text="' : ῭", command=lambda: self.escribirMensaje("'"), height=2, width=10) btn39.place(x=570, y=480) btn40 = Button(self.vista2, text="( : ͼ", command=lambda: self.escribirMensaje("("), height=2, width=10) btn40.place(x=650, y=480) btn41 = Button(self.vista2, text=") : ͽ", command=lambda: self.escribirMensaje(")"), height=2, width=10) btn41.place(x=730, y=480) btn42 = Button(self.vista2, text="* : •", command=lambda: self.escribirMensaje("*"), height=2, width=10) btn42.place(x=170, y=530) btn43 = Button(self.vista2, text="+ : Ꞩ", command=lambda: self.escribirMensaje("+"), height=2, width=10) btn43.place(x=250, y=530) btn44 = Button(self.vista2, text=", : ˼", command=lambda: self.escribirMensaje(","), height=2, width=10) btn44.place(x=330, y=530) btn45 = Button(self.vista2, text="- : Ꝛ", command=lambda: self.escribirMensaje("-"), height=2, width=10) btn45.place(x=410, y=530) btn46 = Button(self.vista2, text=". : ᵨ", command=lambda: self.escribirMensaje("."), height=2, width=10) btn46.place(x=490, y=530) btn47 = Button(self.vista2, text="/ : ↙", command=lambda: self.escribirMensaje("/"), height=2, width=10) btn47.place(x=570, y=530) btn58 = Button(self.vista2, text=": : ჻", command=lambda: self.escribirMensaje(":"), height=2, width=10) btn58.place(x=650, y=530) btn59 = Button(self.vista2, text="; : ἰ", command=lambda: self.escribirMensaje(";"), height=2, width=10) btn59.place(x=730, y=530) btn61 = Button(self.vista2, text="= : ≈", command=lambda: self.escribirMensaje("="), height=2, width=10) btn61.place(x=170, y=580) btn64 = Button(self.vista2, text="@ : ⴋ", command=lambda: self.escribirMensaje("@"), height=2, width=10) btn64.place(x=250, y=580) btn91 = Button(self.vista2, text="[ : «", command=lambda: self.escribirMensaje("["), height=2, width=10) btn91.place(x=330, y=580) btnBarra = Button(self.vista2, text="\ : ↖", command=lambda: self.escribirMensaje("\\"), height=2, width=10) btnBarra.place(x=410, y=580) btn93 = Button(self.vista2, text="] : »", command=lambda: self.escribirMensaje("]"), height=2, width=10) btn93.place(x=490, y=580) btn95 = Button(self.vista2, text="_ : ˽", command=lambda: self.escribirMensaje("_"), height=2, width=10) btn95.place(x=570, y=580) btn123 = Button(self.vista2, text="{ : <", command=lambda: self.escribirMensaje("{"), height=2, width=10) btn123.place(x=650, y=580) btn124 = Button(self.vista2, text="| : ٧", command=lambda: self.escribirMensaje("|"), height=2, width=10) btn124.place(x=730, y=580) btn125 = Button(self.vista2, text="} : >", command=lambda: self.escribirMensaje("}"), height=2, width=10) btn125.place(x=330, y=630) btnEsp = Button(self.vista2, text=" ", command=lambda: self.escribirMensaje(" "), height=2, width=21) btnEsp.place(x=410, y=630) btnDel = Button(self.vista2, text="<-", command=lambda: self.escribirMensaje("<-"), height=2, width=10) btnDel.place(x=570, y=630) self.rbError = Radiobutton(self.vista2, font=("Courier", 16), text="Con error", variable=self.rbValue, value="0") self.rbError.place(x=650, y=710) self.rbNoerror = Radiobutton(self.vista2, font=("Courier", 16), text="Sin error", variable=self.rbValue, value="1") self.rbNoerror.place(x=650, y=670) def escribirMensaje(self, letra): if (letra != "<-"): self.straux.set(self.straux.get() + letra) txt = self.msj.get() txt += lista[letra] self.msj.set(txt) else: txt = self.msj.get() txt = txt[0:len(txt) - 1] self.msj.set(txt) txt = self.straux.get() self.straux.set(txt[0:len(txt) - 1]) self.lblAlf.configure(text=self.straux.get()) def obtenerDatos(self): print(self.rbValue.get()) if (self.uso == 1): if (self.msj.get() != "" and self.ip.get() != ""): if (messagebox.askyesno(message="Mensaje: " + self.msj.get() + "\nMensaje 2: " + self.straux.get() + "\nIP Destino: " + self.ip.get(), title="Confirmar")): self.cambiarModo(2) app.iniciarComunicacion(self.straux.get(), self.ip.get(), self.rbValue.get()) if (self.cambio == False): self.cambio = True self.app.recibirMensaje() else: messagebox.showerror( title="Error", message= "Debe llenar el campo de mensaje y el de ip de destino") else: messagebox.showerror( title="Error", message= "De momento se encuentra en modo servidor, no puede enviar mensajes" ) def cambiarModo(self, nuevo): self.uso = nuevo if (self.uso == 1): self.lblTitulo.configure(text="Cliente") else: self.lblTitulo.configure(text="Servidor") def recibirMsj(self, msj): self.msj.set("") self.straux.set("") for a in range(len(msj)): aux = self.lista[msj[a]] txt = self.msj.get() txt += aux self.msj.set(txt) txt = self.straux.get() txt += msj[a] self.straux.set(txt) self.lblAlf.configure(text=self.straux.get()) self.cambiarModo(1)
class Display_Frame(tkinter.Frame): def __init__(self, root): super().__init__(root, width=1000, height=1000) self.angles = [] self.units_radio_rad = Radiobutton(self, variable=display_settings.AngleUnits, text="radians", value=display_settings.UNITS_RADIANS) self.units_radio_rad.place(y=10, x=20) self.units_radio_deg = Radiobutton(self, variable=display_settings.AngleUnits, text="degrees", value=display_settings.UNITS_DEGREES) self.units_radio_deg.place(y=30, x=20) self.angle_labels = [] self.angle_boxes = [] self.grid_lines_CB = Checkbutton(self, variable=display_settings.ShowGrid, text="Show Grid") self.grid_numbers_CB = Checkbutton(self, variable=display_settings.ShowGridNumbers, text="Show Grid Numbers") self.arm_bounds_CB = Checkbutton(self, variable=display_settings.ShowArmBounds, text="Show Arm Bounds") self.angle_text_CB = Checkbutton(self, variable=display_settings.ShowAngleText, text="Show Angle Text") self.angle_arc_CB = Checkbutton(self, variable=display_settings.ShowAngleArc, text="Show Angle Arc") self.fit_arm_button = tkinter.Button(self, text="Fit Arm") elements = [self.grid_lines_CB, self.grid_numbers_CB, self.arm_bounds_CB, self.angle_text_CB, self.angle_arc_CB, self.fit_arm_button] for i in range(len(elements)): elements[i].place(x=200, y=10 + i * 20) def bind_canvas(self, canvas): self.units_radio_rad.config(command=lambda self=self: [self.refresh_angle_elements(), canvas.update()]) self.units_radio_deg.config(command=lambda self=self: [self.refresh_angle_elements(), canvas.update()]) self.grid_lines_CB.config(command=canvas.update) self.grid_numbers_CB.config(command=canvas.update) self.arm_bounds_CB.config(command=canvas.update) self.angle_text_CB.config(command=canvas.update) self.angle_arc_CB.config(command=canvas.update) self.fit_arm_button.config(command=canvas.scale_to_fit_arm) def refresh_angle_elements(self): angle_mult = 1 if display_settings.AngleUnits.get() == display_settings.UNITS_DEGREES: angle_mult = (180 / 3.14159) for i in range(len(self.angles)): self.angle_boxes[i].config(state="normal") self.angle_boxes[i].delete(0, tkinter.END) angle = round(self.angles[i] * angle_mult, 3) self.angle_boxes[i].insert(0, str(angle)) self.angle_boxes[i].config(state="disabled") def set_elements(self, angles): self.angles = angles while len(self.angle_boxes) < len(angles): self.add_angle_element() while len(self.angle_boxes) > len(angles): self.remove_angle_element() self.refresh_angle_elements() def add_angle_element(self): index = len(self.angle_boxes) y_val = 70 + index * 20 label = tkinter.Label(self, text="Angle "+str(index+1)+":") label.place(x=20, y=y_val) a_box = tkinter.Entry(self, width=10, justify="center") a_box.place(x=100, y=y_val) a_box.delete(0, tkinter.END) a_box.insert(0, "0.0") a_box.config(state="disabled") self.angle_labels.append(label) self.angle_boxes.append(a_box) def remove_angle_element(self): self.angle_labels[-1].destroy() self.angle_labels = self.angle_labels[:-1] self.angle_boxes[-1].destroy() self.angle_boxes = self.angle_boxes[:-1]
dir_field.place(x=160, y=70) # Кнопка для выбора директории с файлами btn_choice_dir = Button(root, text='...', height=1) btn_choice_dir.place(x=444, y=70) btn_choice_dir.bind("<Button-1>", read_files_from_directory) r_but = IntVar() r_but.set(5) r_but_replace = Radiobutton(root, text='Заменить', bg=bg_root_color, value=0, variable=r_but) r_but_replace['command'] = press_button_replace r_but_replace.place(x=90, y=120) r_but_del_begin_str = Radiobutton(root, text='Удалить с начала строки', bg=bg_root_color, value=1, variable=r_but) r_but_del_begin_str['command'] = press_button_delete r_but_del_begin_str.place(x=190, y=105) r_but_del_end_str = Radiobutton(root, text='Удалить с конца строки', bg=bg_root_color, value=2, variable=r_but) r_but_del_end_str['command'] = press_button_delete
def delete_gui(): global say say = Tk() say.geometry("540x450") lblTitle = Label(say, text="Delete Student Record", font="Arial 16") lblTitle.place(x=150, y=0) global existingName, existingRoll, existingPhone, existingBranch global v v = IntVar() global radbtn9, radbtn10, radbtn11, radbtn12 radbtn9 = Radiobutton(say, variable=v, value=1, text="By Name", font="Arial 14", command=rad1) radbtn10 = Radiobutton(say, variable=v, value=2, text="By Roll Number", font="Arial 14", command=rad2) radbtn11 = Radiobutton(say, variable=v, value=3, text="By Branch", font="Arial 14", command=rad3) radbtn12 = Radiobutton(say, variable=v, value=4, text="By Phone", font="Arial 14", command=rad4) radbtn9.place(x=10, y=30) radbtn10.place(x=120, y=30) radbtn11.place(x=290, y=30) radbtn12.place(x=420, y=30) lblDname = Label(say, text="Enter Your Name", font="Arial 14") lblDname.place(x=10, y=80) existingName = Entry(say, state=DISABLED, font="Arial 14") existingName.place(x=200, y=80) lblDroll = Label(say, text="Enter Your Roll_No", font="Arial 14") lblDroll.place(x=10, y=160) existingRoll = Entry(say, state=DISABLED, font="Arial 14") existingRoll.place(x=200, y=160) lblDbranch = Label(say, text="Enter Your Branch", font="Arial 14") lblDbranch.place(x=10, y=240) existingBranch = Entry(say, state=DISABLED, font="Arial 14") existingBranch.place(x=200, y=240) lblDphone = Label(say, text="Enter Your Phone", font="Arial 14") lblDphone.place(x=10, y=320) existingPhone = Entry(say, state=DISABLED, font="Arial 14") existingPhone.place(x=200, y=320) btnSave = Button(say, text="Delete Record", command=delete, font="Arial 16") btnSave.place(x=100, y=380) btnback = Button(say, text="Back To Main Menu", command=onclick_delete, font="Arial 16") btnback.place(x=300, y=380) say.mainloop()
def update_gui(): global update_existingName, newName global update_existingEmail, newEmail global update_existingPhone, newPhone global Rbtn1, Rbtn2, Rbtn3, Rbtn4, Rbtn5, Rbtn6 global radio, radio12 global update_window update_window = Tk() update_window.title("Updating Data") update_window.geometry("500x440") radio = IntVar() radio12 = IntVar() Lbl1 = Label(update_window, text="Hey User! What thing you want To Update?", font="Arial 16") Lbl1.place(x=5, y=5) Lbl8 = Label(update_window, text="From which option would you want to update !!", font="Arial 16") Lbl8.place(x=5, y=70) Lbl2 = Label(update_window, text="Enter New Name -> ", font="Arial 16").place(x=10, y=145) newName = Entry(update_window, width=22, font="Arial 14", state=DISABLED) newName.place(x=250, y=145) Lbl3 = Label(update_window, text="Enter New Email -> ", font="Arial 16").place(x=10, y=185) newEmail = Entry(update_window, width=22, font="Arial 14", state=DISABLED) newEmail.place(x=250, y=180) Lbl4 = Label(update_window, text="Enter New Phone -> ", font="Arial 16").place(x=10, y=225) newPhone = Entry(update_window, width=22, font="Arial 14", state=DISABLED) newPhone.place(x=250, y=225) Lbl5 = Label(update_window, text="Enter Existing Name -> ", font="Arial 16").place(x=10, y=265) update_existingName = Entry(update_window, width=22, font="Arial 14", state=DISABLED) update_existingName.place(x=250, y=265) Lbl6 = Label(update_window, text="Enter Existing Email -> ", font="Arial 16").place(x=10, y=305) update_existingEmail = Entry(update_window, width=22, font="Arial 14", state=DISABLED) update_existingEmail.place(x=250, y=305) Lbl7 = Label(update_window, text="Enter Existing Phone -> ", font="Arial 16").place(x=10, y=345) update_existingPhone = Entry(update_window, width=22, font="Arial 14", state=DISABLED) update_existingPhone.place(x=250, y=345) Rbtn1 = Radiobutton(update_window, text="Name", variable=radio, value=1, command=radio1, font="Arial 16") Rbtn1.place(x=0, y=35) Rbtn2 = Radiobutton(update_window, text="Email", variable=radio, value=2, command=radio2, font="Arial 16") Rbtn2.place(x=190, y=35) Rbtn3 = Radiobutton(update_window, text="Phone", variable=radio, value=3, command=radio3, font="Arial 16") Rbtn3.place(x=370, y=35) Rbtn4 = Radiobutton(update_window, text="By Name", variable=radio12, value=1, command=radio4, state=DISABLED, font="Arial 16") Rbtn4.place(x=0, y=100) Rbtn5 = Radiobutton(update_window, text="By Email", variable=radio12, value=2, command=radio5, state=DISABLED, font="Arial 16") Rbtn5.place(x=190, y=105) Rbtn6 = Radiobutton(update_window, text="By Phone", variable=radio12, value=3, command=radio6, state=DISABLED, font="Arial 16") Rbtn6.place(x=370, y=105) Btn8 = Button(update_window, text="Cancel", command=exit_update_window, font="Arial 16", width=9) Btn8.place(x=370, y=385) Btn9 = Button(update_window, text="Update Data", command=confirm_update, font="Arial 16", width=12) Btn9.place(x=208, y=385) Btn10 = Button(update_window, text="Back To Menu", command=onclick_update, font="Arial 16", width=12) Btn10.place(x=47, y=385) update_window.mainloop()
class TelaPontos(): #================================================================== #= Métodos que envolvem a criação e posicionamento de widgets #= na janela #================================================================== def __init__(self, janela, jAnterior): self.janela = janela self.jAnterior = jAnterior # Essas são as listas onde ficarão todos os pontos que serão # passados para a classe de ajuste de curvas. self.px = [] self.py = [] self.sx = [] self.sy = [] self.opt = IntVar() # Criação de widgets self.texto = Label(self.janela, text="Selecione o modo de entrada dos pontos.", bg="azure2") self.btn_fit = Button(self.janela, text="Ok", command=self.radio_choice, bg="LightSkyBlue4", width=5) self.btn_cancel = Button(self.janela, text="Voltar", command=self.voltar, bg="LightSkyBlue4") self.radio_escolha_arquivo = Radiobutton(self.janela, variable=self.opt, value=1, text="Arquivo", bg="azure2", width=14, anchor="w") self.radio_escolha_texto = Radiobutton(self.janela, variable=self.opt, value=2, text="Copiar do excel", bg="azure2", width=14, anchor="w") self.radio_inserir_pontos = Radiobutton(self.janela, variable=self.opt, value=3, text="Valores", bg="azure2", width=14, anchor="w") self.radio_inserir_pontos.select() self.tip = Label(self.janela, text="?", bg="LightSkyBlue4", width=3) #== Posicionamento de widgets self.redesenhar() ToolTip( self.tip, "Valores: Insere um ponto de cada vez\nArquivo: Lê um arquivo csv.\nCopiar do excel: Lê os valores copiados das tabelas de um arquivo Excel\n\nObs: Todos em todas as opções de entrada os pontos devem ser colocados\nno formato: X, Y, Erro de X, Erro de Y." ) ''' self.frm_upper.pack() self.frm_down.pack(side=BOTTOM) self.frm_radio.pack(side=RIGHT) self.radio_inserir_pontos.grid(row=0, column=3) self.radio_escolha_arquivo.grid(row=1, column=3) self.radio_escolha_texto.grid(row=2, column=3) self.btn_fit.grid(row=4, column=4) self.btn_cancel.grid(row=4, column=0) ''' #================================================================== #=Função para limpar a janela atual e chamar a janela dos gráficos. #=Os pontos lidos são passados para o construtor def proxJanelaGrafico(self): self.limparJanela() TelaGrafico(self.janela, self, self.px, self.sx, self.py, self.sy) #================================================================== def voltar(self): self.limparJanela() self.jAnterior.redesenhar() #================================================================== def redesenhar(self): # Posicionamento de widgets self.janela.geometry("325x300+400+200") self.texto.place(x=13, y=4) self.tip.place(x=287, y=4) tam = 90 self.radio_inserir_pontos.place(x=tam, y=30) self.radio_escolha_arquivo.place(x=tam, y=52) self.radio_escolha_texto.place(x=tam, y=74) self.btn_fit.place(x=161, y=260) self.btn_cancel.place(x=91, y=260) #================================================================== def limparJanela(self): # Limpando os widgets self.texto.place_forget() self.tip.place_forget() self.btn_fit.place_forget() self.btn_cancel.place_forget() self.texto.place_forget() self.radio_escolha_arquivo.place_forget() self.radio_escolha_texto.place_forget() self.radio_inserir_pontos.place_forget() #================================================================== #================================================================== #================================================================== #=Janela da caixa de texto. Nela, existe uma caixa de texto para onde #=os pontos devem ser copiados no formato x - erro x - y - erro y def get_by_text(self): top_txt = Toplevel() top_txt.resizable(False, False) top_txt.title("Pontos") top_txt.configure(background="azure2") #= Criação de widgets txt_entry = Text(top_txt) frm_btn = Frame(top_txt, bd=10, bg="azure2") btn_cancel = Button(frm_btn, text="Cancelar", command=top_txt.destroy, bg="LightSkyBlue4", width=5) #= Posicionamento de widgets txt_entry.pack() frm_btn.pack(side=BOTTOM) btn_cancel.pack(side=LEFT) #================================================================ #= Função que valida o conteúdo da Text Entry e recebe os pontos #= (chamada ao clicar no botão) def get_pontos(): self.txt_pontos = txt_entry.get("1.0", END) try: self.px, self.py, self.sx, self.sy = ler_excel( self.txt_pontos) #método ler_excel do módulo reader top_txt.destroy() self.proxJanelaGrafico() except ValueError: messagebox.showwarning("Erro!", "Valores inseridos incorretamente") #============================== #= Criação & posicionamento Button(frm_btn, text="OK", command=get_pontos, bg="LightSkyBlue4", width=5).pack(side=RIGHT) #================================================================== # Função para criar um novo conjunto de entradas para os pontos e erros def append_labels(self, janela): self.labels.append(Label(janela, text="X", background="azure2")) self.labels[-1].grid(row=self.tam, column=0) self.labels.append(Label(janela, text="Y", background="azure2")) self.labels[-1].grid(row=self.tam, column=2) self.labels.append(Label(janela, text="Erro X", background="azure2")) self.labels[-1].grid(row=self.tam, column=4) self.labels.append(Label(janela, text="Erro Y", background="azure2")) self.labels[-1].grid(row=self.tam, column=6) #================================================== self.inserts.append(Entry(janela, width=10)) self.inserts[-1].grid(row=self.tam, column=1) self.inserts.append(Entry(janela, width=10)) self.inserts[-1].grid(row=self.tam, column=3) self.inserts.append(Entry(janela, width=10)) self.inserts[-1].grid(row=self.tam, column=5) self.inserts.append(Entry(janela, width=10)) self.inserts[-1].grid(row=self.tam, column=7) self.tam += 1 #====================================================== #= Função que itera pelas caixas de texto recebidas #= e passa todos os pontos e erros para as listas #= de pontos e erros def salvar_pontos(self): try: self.px, self.py, self.sx, self.sy = validar_pontos(self.inserts) self.proxJanelaGrafico() self.top_pontos.destroy() except ValueError: messagebox.showwarning("Erro!", "Valores inseridos incorretamente") #self.top_pontos.destroy() #====================================================== #= Janela onde os pontos serão inseridos manualmente def janela_Inserir_Pontos(self): self.top_pontos = Toplevel(bd=10) self.top_pontos.resizable(False, False) self.top_pontos.title("Pontos") self.top_pontos.configure(background="azure2") self.tam = 0 self.labels = [] self.inserts = [] #= Criação de widgets frame_pontos = Frame(self.top_pontos, height=300, width=500, bd=10, background="azure2") btn_add = Button(self.top_pontos, text="Adicionar ponto", bg="LightSkyBlue4") btn_cancel = Button(self.top_pontos, text="Cancelar", command=self.top_pontos.destroy, bg="LightSkyBlue4", width=5) btn_add["command"] = partial(self.append_labels, frame_pontos) btn_ok = Button(self.top_pontos, text="Ok", command=self.salvar_pontos, bg="LightSkyBlue4", width=5) #= Posicionamento de widgets frame_pontos.pack(side=BOTTOM) btn_add.pack(side=RIGHT) btn_ok.pack(side=LEFT) btn_cancel.pack(side=LEFT) #= Cria o primeiro conjunto de entradas self.append_labels(frame_pontos) #================================================================== #= Função que define qual método de inserção será chamado, depenendo #= do radio button selecionado def radio_choice(self): if (self.opt.get() == 1): self.get_File() elif (self.opt.get() == 2): self.get_by_text() elif (self.opt.get() == 3): self.janela_Inserir_Pontos() #================================================================== #= Função para o método através do arquivo csv. Abre uma caixa que #= solicita um arquivo e passa seu caminho para a função ler_csv #= do módulo reader. def get_File(self): filename = filedialog.askopenfilename(filetypes=[("arquivo csv", "*.csv")]) if filename: self.px, self.py, self.sx, self.sy = ler_csv(filename) self.proxJanelaGrafico()
def delete_gui(): global delete_existingName, delete_existingEmail, delete_existingPhone global Rbtn7, Rbtn8, Rbtn9 global radio13 global delete_window delete_window = Tk() delete_window.title("Deleting Data") delete_window.geometry("500x258") radio13 = IntVar() Lbl1 = Label(delete_window, text="Please Select Deletion Option", font="Arial 16") Lbl1.pack() Lbl2 = Label(delete_window, text="Enter Existing Name -> ", font="Arial 16").place(x=10, y=80) delete_existingName = Entry(delete_window, width=22, font="Arial 14", state=DISABLED) delete_existingName.place(x=250, y=80) Lbl3 = Label(delete_window, text="Enter Existing Email -> ", font="Arial 16").place(x=10, y=120) delete_existingEmail = Entry(delete_window, width=22, font="Arial 14", state=DISABLED) delete_existingEmail.place(x=250, y=120) Lbl4 = Label(delete_window, text="Enter Existing Phone -> ", font="Arial 16").place(x=10, y=160) delete_existingPhone = Entry(delete_window, width=22, font="Arial 14", state=DISABLED) delete_existingPhone.place(x=250, y=160) Rbtn7 = Radiobutton(delete_window, text="By Name", variable=radio13, value=1, font="Arial 16", command=radio7) Rbtn7.place(x=0, y=40) Rbtn8 = Radiobutton(delete_window, text="By Email", variable=radio13, value=2, font="Arial 16", command=radio8) Rbtn8.place(x=190, y=40) Rbtn9 = Radiobutton(delete_window, text="By Phone", variable=radio13, value=3, font="Arial 16", command=radio9) Rbtn9.place(x=370, y=40) Btn11 = Button(delete_window, text="Cancel", command=exit_delete_window, font="Arial 16", width=9) Btn11.place(x=370, y=200) Btn12 = Button(delete_window, text="Delete", command=confirm_delete, font="Arial 16", width=9) Btn12.place(x=245, y=200) Btn13 = Button(delete_window, text="Back To Menu", command=onclick_delete, font="Arial 16", width=12) Btn13.place(x=85, y=200) delete_window.mainloop()
resolution_label = Label(tab1, text="Video Resolution:", font=DisFont, bg="#520B00", fg="white") resolution_label.place(x=75, y=160) R1 = Radiobutton(tab1, text="Mp4 720", cursor='hand2', font=SubFont, variable=Rvideo, value=1, command=get_fetch, bg="#520B00", fg="white") R1.place(x=80, y=200) R2 = Radiobutton(tab1, text="Mp4 360px", cursor='hand2', font=SubFont, variable=Rvideo, value=2, command=get_fetch, bg="#520B00", fg="white") R2.place(x=80, y=240) R3 = Radiobutton(tab1, text="3gp 144px", cursor='hand2', font=SubFont, variable=Rvideo,
def createPracticalGUI(carbonSelection): global win global frame global var2 global var3 global var4 global var5 global var global dh global radiovar global radiovar2 global radiovar3 if (frame != None): frame.destroy() # variables set for validation var = tk.StringVar() var2 = tk.StringVar() var3 = tk.StringVar() var4 = tk.StringVar() var5 = tk.StringVar() radiovar = tk.IntVar() radiovar2 = tk.IntVar() radiovar3 = tk.IntVar() def calculation(carbonNames): global var global var2 global var3 global var4 global var5 global radiovar global radiovar2 global radiovar3 global textbox try: # assign varaible to every input for calculation in the end massWater = float(var.get()) temperatureBefore = float(var2.get()) temperatureAfter = float(var3.get()) massBefore = float(var4.get()) massAfter = float(var5.get()) # connect to the database conn = sqlite3.connect('Theoretical_Method.db') c = conn.cursor() # molar mass molarMass = c.execute( "SELECT Molar_mass FROM Theoretical WHERE Hydrocarbon = ?", carbonSelection).fetchone()[0] print(molarMass) # mass of water # have radiobuttons for the units # if kilogram given multiply by 1000 to get grams if radiovar.get() == 1: massWaterGram = massWater * 1000 else: massWaterGram = massWater textbox.insert(tk.END, "Molar Mass of Hydrocarbon: ") textbox.insert(tk.END, molarMass) textbox.insert(tk.END, "\nMass of water: ") textbox.insert(tk.END, massWaterGram) textbox.insert(tk.END, " grams") #temperature temperatureDifference = (temperatureAfter - temperatureBefore) textbox.insert(tk.END, "\nTemperature difference: ") textbox.insert(tk.END, temperatureDifference) textbox.insert(tk.END, " Kelvin") #spirit burner # have radiobuttons for the units # if kilogram given multiply by 1000 to get grams if radiovar2.get() == 1: massBurnerBeforeGram = massBefore * 1000 else: massBurnerBeforeGram = massBefore if radiovar3.get() == 1: massBurnerAfterGram = massAfter * 1000 else: massBurnerAfterGram = massAfter # difference in mass burner before and after # if the mass before is greater than the mass after: before - after # if the mass after is greater than the mass before: after - before if massBurnerBeforeGram > massBurnerAfterGram: massDifference = (massBurnerBeforeGram - massBurnerAfterGram) else: massDifference = (massBurnerAfterGram - massBurnerBeforeGram) textbox.insert(tk.END, "\nDifference in mass of spirit burner: ") textbox.insert(tk.END, massDifference) textbox.insert(tk.END, " grams") #Calculating Mole # use the molar mass from the database and the difference in mass calculated above find the mole moles = (massDifference / molarMass) textbox.insert( tk.END, "\nMoles (difference in mass of spirit burner/molar mass): ") textbox.insert(tk.END, moles) textbox.insert(tk.END, " moles") # calculate enery transferred using Q = mcDeltaT energyTransferredQ = ( (massWaterGram * 4.184 * temperatureDifference) / 1000.0) textbox.insert(tk.END, "\nEnergy transferred: ") textbox.insert(tk.END, energyTransferredQ) textbox.insert(tk.END, "kJ") enthalpyChange = energyTransferredQ / moles textbox.insert(tk.END, "\nEnthalpy change of combustion: ") textbox.insert(tk.END, enthalpyChange) textbox.insert(tk.END, "kJ/mol") with open("Answer.txt", "w") as answer: answer.write(str(enthalpyChange)) # find out if exothermic or endothermic reaction if enthalpyChange > 0: textbox.insert(tk.END, "\n\nThis reaction is Endothermic") textbox.configure(state="disabled") else: textbox.insert(tk.END, "\n\nThis reaction is Exothermic") textbox.configure(state="disabled") except ValueError: pass #create new frame frame = Frame(win, bg="lawn green") titleLbl = Label(frame, text="Practical method", fg="black", bg="lawn green", font=("Comic Sans MS", 20)) titleLbl.pack() lbl = Label(frame, text="Enter mass of water", fg="black", font=("Comic Sans MS", 10)) lbl.configure(background='lime green') lbl.pack() TextEntry = Entry(frame, bd=5, textvariable=var) TextEntry.pack() TextEntry.bind( "<FocusOut>", lambda evt: practicalValidate(evt, TextEntry.get( ))) # when return key (enter key) is pressed the value will be checked # VALIDATION - make sure the units are correct rb = Radiobutton(frame, text="kilograms", fg="black", bg="lime green", font=("Comic Sans MS", 10), variable=radiovar, value=1) rb.place(x=600, y=55) rb1 = Radiobutton(frame, text="grams", fg="black", bg="lime green", font=("Comic Sans MS", 10), variable=radiovar, value=2) rb1.place(x=700, y=55) lb2 = Label(frame, text="Temperature of water before", fg="black", font=("Comic Sans MS", 10)) lb2.configure(background='lime green') lb2.pack() TextEntry2 = Entry(frame, bd=5, textvariable=var2) TextEntry2.pack() TextEntry2.bind("<FocusOut>", lambda evt: practicalValidate(evt, TextEntry2.get())) lb3 = Label(frame, text="Temperature of water after", fg="black", font=("Comic Sans MS", 10)) lb3.configure(background='lime green') lb3.pack() TextEntry3 = Entry(frame, bd=5, textvariable=var3) TextEntry3.pack() TextEntry3.bind("<FocusOut>", lambda evt: practicalValidate(evt, TextEntry3.get())) lb4 = Label(frame, text="Mass of spirit burner before", fg="black", font=("Comic Sans MS", 10)) lb4.configure(background='lime green') lb4.pack() TextEntry4 = Entry(frame, bd=5, textvariable=var4) TextEntry4.pack() TextEntry4.bind("<FocusOut>", lambda evt: practicalValidate(evt, TextEntry4.get())) radiovar2 = tk.IntVar() rb3 = Radiobutton(frame, text="kilograms", fg="black", bg="lime green", font=("Comic Sans MS", 10), variable=radiovar2, value=1) rb3.place(x=600, y=210) rb4 = Radiobutton(frame, text="grams", fg="black", bg="lime green", font=("Comic Sans MS", 10), variable=radiovar2, value=2) rb4.place(x=700, y=210) lb5 = Label(frame, text="Mass of spirit burner after", fg="black", font=("Comic Sans MS", 10)) lb5.configure(background='lime green') lb5.pack() radiovar3 = tk.IntVar() rb3 = Radiobutton(frame, text="kilograms", fg="black", bg="lime green", font=("Comic Sans MS", 10), variable=radiovar3, value=1) rb3.place(x=600, y=250) rb4 = Radiobutton(frame, text="grams", fg="black", bg="lime green", font=("Comic Sans MS", 10), variable=radiovar3, value=2) rb4.place(x=700, y=250) TextEntry5 = Entry(frame, bd=5, textvariable=var5) TextEntry5.pack() TextEntry5.bind("<FocusOut>", lambda evt: practicalValidate(evt, TextEntry5.get())) global textbox textbox = Text(frame, width=100, height=10) textbox.pack() button = Button(frame, text="Submit", command=lambda: calculation(carbonSelection), height=2, width=8, state='disabled', fg="black", bg="lime green", font=("Comic Sans MS", 10)) button.pack() button2 = Button(frame, text="Canvas", command=canvas, height=2, width=8, state='disabled', fg="black", bg="lime green", font=("Comic Sans MS", 10)) button2.pack() btnHome = Button(frame, text="Home", command=createMainMenuGUI, height=2, width=8, fg="black", bg="green4", font=("Comic Sans MS", 10)) btnHome.pack(padx=10, pady=0, side=RIGHT) var.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) var2.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) var3.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) var4.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) var5.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) radiovar.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) radiovar2.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) radiovar3.trace( "w", lambda *args: submitButton(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button)) var.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) var2.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) var3.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) var4.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) var5.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) radiovar.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) radiovar2.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) radiovar3.trace( "w", lambda *args: submitButton1(var.get(), var2.get(), var3.get( ), var4.get(), var5.get(), radiovar.get(), radiovar2.get(), radiovar3.get(), button, button2)) frame.pack()