Ejemplo n.º 1
0
    def __init__(self, image_title, content, uploader, url, templates,
                 commonsconflict=0):
        """Initializer."""
        # Check if `Tkinter` wasn't imported
        if isinstance(Tkinter, ImportError):
            raise Tkinter

        super(TkdialogIC, self).__init__()
        self.root = Tkinter.Tk()
        # "%dx%d%+d%+d" % (width, height, xoffset, yoffset)
        # Always appear the same size and in the bottom-left corner
        self.root.geometry('600x200+100-100')
        self.root.title(image_title)
        self.changename = ''
        self.skip = 0
        self.url = url
        self.uploader = 'Unknown'
        # uploader.decode('utf-8')
        scrollbar = Tkinter.Scrollbar(self.root, orient=Tkinter.VERTICAL)
        label = Tkinter.Label(self.root, text='Enter new name or leave blank.')
        imageinfo = Tkinter.Label(self.root, text='Uploaded by {}.'.format(
            uploader))
        textarea = Tkinter.Text(self.root)
        textarea.insert(Tkinter.END, content.encode('utf-8'))
        textarea.config(state=Tkinter.DISABLED,
                        height=8, width=40, padx=0, pady=0,
                        wrap=Tkinter.WORD, yscrollcommand=scrollbar.set)
        scrollbar.config(command=textarea.yview)
        self.entry = Tkinter.Entry(self.root)

        self.templatelist = Tkinter.Listbox(self.root, bg='white', height=5)

        for template in templates:
            self.templatelist.insert(Tkinter.END, template)
        autoskip_button = Tkinter.Button(self.root, text='Add to AutoSkip',
                                         command=self.add2_auto_skip)
        browser_button = Tkinter.Button(self.root, text='View in browser',
                                        command=self.open_in_browser)
        skip_button = Tkinter.Button(self.root, text='Skip',
                                     command=self.skip_file)
        ok_button = Tkinter.Button(self.root, text='OK', command=self.ok_file)

        # Start grid
        label.grid(row=0)
        ok_button.grid(row=0, column=1, rowspan=2)
        skip_button.grid(row=0, column=2, rowspan=2)
        browser_button.grid(row=0, column=3, rowspan=2)

        self.entry.grid(row=1)

        textarea.grid(row=2, column=1, columnspan=3)
        scrollbar.grid(row=2, column=5)
        self.templatelist.grid(row=2, column=0)

        autoskip_button.grid(row=3, column=0)
        imageinfo.grid(row=3, column=1, columnspan=4)
Ejemplo n.º 2
0
    def __init__(self, fields):
        """Initializer.

        fields:
            imagepage, description, date, source, author, licensetemplate,
            categories
        """
        # Check if `Tkinter` wasn't imported
        if isinstance(Tkinter, ImportError):
            raise Tkinter

        self.root = Tkinter.Tk()
        # "%dx%d%+d%+d" % (width, height, xoffset, yoffset)
        # Always appear the same size and in the bottom-left corner
        # FIXME : Base this on the screen size or make it possible for the user
        # to configure this

        # Get all the relevant fields
        super().__init__()
        for name in self.fieldnames:
            setattr(self, name, fields.get(name))

        self.skip = False

        # Start building the page
        self.root.geometry('1500x400+100-100')
        self.root.title(self.filename)

        self.url = self.imagepage.permalink()
        self.scrollbar = Tkinter.Scrollbar(self.root, orient=Tkinter.VERTICAL)

        self.old_description = Tkinter.Text(self.root)
        self.old_description.insert(Tkinter.END,
                                    self.imagepage.get().encode('utf-8'))
        self.old_description.config(state=Tkinter.DISABLED,
                                    height=8, width=140, padx=0, pady=0,
                                    wrap=Tkinter.WORD,
                                    yscrollcommand=self.scrollbar.set)

        self.scrollbar.config(command=self.old_description.yview)

        self.old_description_label = Tkinter.Label(
            self.root, text='The old description was : ')
        self.new_description_label = Tkinter.Label(
            self.root, text='The new fields are : ')
        self.filename_label = Tkinter.Label(self.root, text='Filename : ')
        self.information_description_label = Tkinter.Label(
            self.root, text='Description : ')
        self.information_date_label = Tkinter.Label(self.root, text='Date : ')
        self.information_source_label = Tkinter.Label(self.root,
                                                      text='Source : ')
        self.information_author_label = Tkinter.Label(self.root,
                                                      text='Author : ')
        self.information_permission_label = Tkinter.Label(self.root,
                                                          text='Permission : ')
        self.information_other_versions_label = Tkinter.Label(
            self.root, text='Other versions : ')

        self.information_licensetemplate_label = Tkinter.Label(
            self.root, text='License : ')
        self.information_categories_label = Tkinter.Label(
            self.root, text='Categories : ')

        self.filename_field = Tkinter.Entry(self.root)
        self.information_description = Tkinter.Entry(self.root)
        self.information_date = Tkinter.Entry(self.root)
        self.information_source = Tkinter.Entry(self.root)
        self.information_author = Tkinter.Entry(self.root)
        self.information_permission = Tkinter.Entry(self.root)
        self.information_other_versions = Tkinter.Entry(self.root)
        self.information_licensetemplate = Tkinter.Entry(self.root)
        self.information_categories = Tkinter.Entry(self.root)

        self.field_width = 120

        self.filename_field.config(width=self.field_width)
        self.information_description.config(width=self.field_width)
        self.information_date.config(width=self.field_width)
        self.information_source.config(width=self.field_width)
        self.information_author.config(width=self.field_width)
        self.information_permission.config(width=self.field_width)
        self.information_other_versions.config(width=self.field_width)
        self.information_licensetemplate.config(width=self.field_width)
        self.information_categories.config(width=self.field_width)

        self.filename_field.insert(0, self.filename)
        self.information_description.insert(0, self.description)
        self.information_date.insert(0, self.date)
        self.information_source.insert(0, self.source)
        self.information_author.insert(0, self.author)
        self.information_permission.insert(0, self.permission)
        self.information_other_versions.insert(0, self.other_versions)
        self.information_licensetemplate.insert(0, self.licensetemplate)
        self.information_categories.insert(0, self.categories)

        self.browser_button = Tkinter.Button(self.root,
                                             text='View in browser',
                                             command=self.open_in_browser)
        self.skip_button = Tkinter.Button(self.root, text='Skip',
                                          command=self.skipFile)
        self.ok_button = Tkinter.Button(self.root, text='OK',
                                        command=self.ok_file)

        # Start grid
        self.old_description_label.grid(row=0, column=0, columnspan=3)

        self.old_description.grid(row=1, column=0, columnspan=3)
        self.scrollbar.grid(row=1, column=3)
        self.new_description_label.grid(row=2, column=0, columnspan=3)

        # All the labels for the new fields
        self.filename_label.grid(row=3, column=0)
        self.information_description_label.grid(row=4, column=0)
        self.information_date_label.grid(row=5, column=0)
        self.information_source_label.grid(row=6, column=0)
        self.information_author_label.grid(row=7, column=0)
        self.information_permission_label.grid(row=8, column=0)
        self.information_other_versions_label.grid(row=9, column=0)
        self.information_licensetemplate_label.grid(row=10, column=0)
        self.information_categories_label.grid(row=11, column=0)

        # The new fields
        self.filename_field.grid(row=3, column=1, columnspan=3)
        self.information_description.grid(row=4, column=1, columnspan=3)
        self.information_date.grid(row=5, column=1, columnspan=3)
        self.information_source.grid(row=6, column=1, columnspan=3)
        self.information_author.grid(row=7, column=1, columnspan=3)
        self.information_permission.grid(row=8, column=1, columnspan=3)
        self.information_other_versions.grid(row=9, column=1, columnspan=3)
        self.information_licensetemplate.grid(row=10, column=1, columnspan=3)
        self.information_categories.grid(row=11, column=1, columnspan=3)

        # The buttons at the bottom
        self.ok_button.grid(row=12, column=3, rowspan=2)
        self.skip_button.grid(row=12, column=2, rowspan=2)
        self.browser_button.grid(row=12, column=1, rowspan=2)