예제 #1
0
    def haoi_entries(self):

        default_user_key = StringVar()
        default_user_key.set(config.global_config.haoiUser)
        default_software_key = StringVar()
        default_software_key.set(config.global_config.haoiRebate)

        lf = LabelFrame(self, text='haoi')
        ul = Label(lf, text='user key:')
        ue = Entry(lf, textvariable=default_user_key)
        rl = Label(lf, text='software key:')
        re = Entry(lf, textvariable=default_software_key)

        ul.config(width=10, anchor=W, justify=LEFT)
        ue.config(width=53,
                  validate='key',
                  validatecommand=(lf.register(self.creator('haoiUser')),
                                   '%P'))
        rl.config(
            width=10,
            anchor=W,
            justify=LEFT,
        )
        re.config(width=53,
                  validate='key',
                  validatecommand=(lf.register(self.creator('haoiRebate')),
                                   '%P'))

        ul.grid(row=0, column=0, sticky=N + W, padx=(10, 10), pady=(10, 0))
        ue.grid(row=0, column=1, sticky=N + W, padx=(0, 10), pady=(10, 0))
        rl.grid(row=1, column=0, sticky=N + W, padx=(10, 10), pady=(0, 10))
        re.grid(row=1, column=1, sticky=N + W, padx=(0, 10), pady=(0, 10))

        return lf
예제 #2
0
    def twocaptcha_entries(self):

        default_user_key = StringVar()
        default_user_key.set(config.global_config.twocaptchaKey)

        lf = LabelFrame(self, text='2captcha')
        ul = Label(lf, text='user key:')
        ue = Entry(lf, textvariable=default_user_key)

        ul.config(width=10, anchor=W, justify=LEFT)
        ue.config(width=53,
                  validate='key',
                  validatecommand=(lf.register(self.creator('twocaptchaKey')),
                                   '%P'))
        ul.grid(row=0, column=0, sticky=N + W, padx=(10, 10), pady=(10, 10))
        ue.grid(row=0, column=1, sticky=N + W, padx=(0, 10), pady=(10, 10))

        return lf
예제 #3
0
파일: GUI.py 프로젝트: jorgemb/lotimg
    def create_objects(self):
        top = self.winfo_toplevel()

        # Menu
        menu_top = Menu(top)
        top["menu"] = menu_top

        menu_top.add_command(label="About...")

        # Image line
        form_general = Frame(self, padx=10, pady=10)
        form_general.grid(row=0, column=0)

        # Original names
        form_initial_data = LabelFrame(form_general,
                                       text="Images",
                                       padx=10,
                                       pady=5)
        form_initial_data.grid(column=0, row=0, rowspan=2, sticky=N + S)

        initial_scroll_y = Scrollbar(form_initial_data, orient=VERTICAL)
        initial_scroll_y.grid(column=2, row=0, rowspan=5, sticky=N + S)

        self.model_initial_names = StringVar(self)
        self.widget_initial_names = Listbox(
            form_initial_data,
            height=27,
            width=35,
            activestyle="dotbox",
            listvariable=self.model_initial_names,
            selectmode=EXTENDED,
            yscrollcommand=initial_scroll_y.set)
        self.widget_initial_names.grid(column=0,
                                       row=0,
                                       rowspan=5,
                                       columnspan=2,
                                       sticky=N + S + W + E)

        initial_scroll_y["command"] = self.widget_initial_names.yview
        self.widget_initial_names.bind("<Double-Button-1>", self.select_name)
        self.widget_initial_names.bind("<<ListboxSelect>>", self.preview)

        button_up = Button(form_initial_data,
                           image=self.resources["up"],
                           command=self.name_up)
        button_up.grid(column=3, row=1, sticky=N + S)

        button_down = Button(form_initial_data,
                             image=self.resources["down"],
                             command=self.name_down)
        button_down.grid(column=3, row=3, sticky=N + S)

        button_add = Button(form_initial_data,
                            image=self.resources["add"],
                            command=self.add_file_names)
        button_add.grid(column=0, row=5, sticky=W + E)

        button_delete = Button(form_initial_data,
                               image=self.resources["delete"],
                               command=self.remove_file_names)
        button_delete.grid(column=1, row=5, sticky=W + E)

        # Preview
        form_preview = LabelFrame(form_general,
                                  text="Preview",
                                  padx=10,
                                  pady=5)
        form_preview.grid(column=1,
                          row=0,
                          columnspan=2,
                          sticky=N + S + W + E,
                          padx=10)

        form_preliminary = Frame(form_preview)
        form_preliminary.grid(column=1, row=0, sticky=N + S + W + E)

        self.canvas_view = Canvas(form_preliminary,
                                  width=256,
                                  height=256,
                                  bg="white",
                                  cursor="crosshair")
        self.canvas_view.grid(sticky=N + S + W + E)

        # Final names
        form_final_names = Frame(form_preview)
        form_final_names.grid(column=2, row=0, sticky=N + S + W + E)

        final_scroll_y = Scrollbar(form_final_names)
        final_scroll_y.grid(column=1, row=0, sticky=N + S)

        self.model_final_names = StringVar()
        self.widget_final_names = Listbox(form_final_names,
                                          height=18,
                                          width=35,
                                          activestyle="dotbox",
                                          listvariable=self.model_final_names,
                                          selectmode=SINGLE,
                                          yscrollcommand=final_scroll_y.set)
        self.widget_final_names.grid(column=0, row=0, sticky=N + W + E)
        final_scroll_y["command"] = self.widget_final_names.yview

        self.widget_final_names.bind("<Double-Button-1>", self.select_name)
        self.widget_final_names.bind("<<ListboxSelect>>", self.preview)

        # Options line
        form_options = Frame(form_general)
        form_options.grid(row=1, column=1, columnspan=2, sticky=E + W, padx=10)

        # ..dimensions
        self.model_width = StringVar()
        self.model_height = StringVar()
        form_dimensions = LabelFrame(form_options,
                                     text="Dimensions (0 = no change)",
                                     padx=10,
                                     pady=10)
        form_dimensions.grid(row=0, column=1, sticky=N + S + W + E, padx=5)
        self.vcmd = (form_dimensions.register(self.event_on_validate), "%S",
                     "%P")

        label_width = Label(form_dimensions, text="Width")
        label_width.grid(column=0, row=1, sticky=W)

        entry_width = Entry(form_dimensions,
                            validate="key",
                            validatecommand=self.vcmd,
                            textvariable=self.model_width,
                            justify=RIGHT)
        entry_width.grid(column=1, row=1, sticky=E + W)
        entry_width.insert(END, "0")

        label_height = Label(form_dimensions, text="Height")
        label_height.grid(column=0, row=2, sticky=W)

        entry_height = Entry(form_dimensions,
                             validate="key",
                             validatecommand=self.vcmd,
                             textvariable=self.model_height,
                             justify=RIGHT)
        entry_height.grid(column=1, row=2, sticky=E + W)
        entry_height.insert(END, "0")

        # .. formats
        form_formats = LabelFrame(form_options,
                                  text="Formats",
                                  padx=10,
                                  pady=10)
        form_formats.grid(row=0, column=0, rowspan=2, sticky=N + S + E + W)

        formats = ["No change", "JPG", "GIF", "BMP", "PNG", "TIFF"]
        self.selected_format = StringVar(value="No change")

        for n in range(len(formats)):
            radio_format = Radiobutton(form_formats,
                                       text=formats[n],
                                       value=formats[n],
                                       variable=self.selected_format)
            radio_format.grid(row=n + 1, column=0, sticky=W)

        # .. name change
        self.validate = (form_dimensions.register(self.event_validate_rule),
                         "%P")
        form_names = LabelFrame(form_options, text="Names", padx=10, pady=10)
        form_names.grid(row=1, column=1, sticky=N + S + E + W, padx=5)

        self.selected_name = IntVar(value=0)
        radio_nochange = Radiobutton(form_names,
                                     text="No change",
                                     value=0,
                                     variable=self.selected_name,
                                     command=self.rule_change)
        radio_nochange.grid(row=1, column=0, columnspan=2, sticky=W)

        radio_name_only = Radiobutton(form_names,
                                      text="Name + N",
                                      value=1,
                                      variable=self.selected_name,
                                      command=self.rule_change)
        radio_name_only.grid(row=2, column=0, sticky=W)

        self.entry_name_only = Entry(form_names,
                                     width=10,
                                     validate="key",
                                     validatecommand=self.validate)
        self.entry_name_only.grid(row=2, column=1, sticky=W + E)

        radio_rule = Radiobutton(form_names,
                                 text="Rule",
                                 value=2,
                                 variable=self.selected_name,
                                 command=self.rule_change)
        radio_rule.grid(row=3, column=0, sticky=W)
        self.button_change = Button(form_names,
                                    text="Change",
                                    command=self.custom_rule)
        self.button_change.grid(row=3, column=1, sticky=W + E)

        self.entry_name_only["state"] = DISABLED
        self.button_change["state"] = DISABLED

        # ..directory
        form_directory = LabelFrame(form_options,
                                    text="Destination",
                                    padx=10,
                                    pady=10)
        form_directory.grid(row=0, column=2, sticky=N + S + W)

        button_directory = Button(form_directory,
                                  image=self.resources["dir"],
                                  command=self.choose_directory)
        button_directory.grid(row=0, column=0, sticky=N + S + E + W)

        self.label_selected_directory = Label(form_directory,
                                              text="<Directory not chosen>",
                                              width=25,
                                              anchor=W)
        self.label_selected_directory.grid(row=0, column=1, stick=W + E)

        # .. convert
        self.button_convert = Button(form_options,
                                     image=self.resources["convert_d"],
                                     state=DISABLED,
                                     height=91,
                                     command=self.convert_images)
        self.button_convert.grid(row=1, column=2, sticky=E + W + S)