Exemple #1
0
def set_logo(self):

    script_dir, __ = split(__file__)
    if not script_dir:
        script_dir = "."

    png_logo_file = join(script_dir, "logo.png")

    try:
        # see: https://stackoverflow.com/questions/18537918/set-window-icon
        try:
            icon = PhotoImage(file=png_logo_file)
        except:
            # Some versions of Tkinter do not support PNG. Use GIF instead.
            gif_logo_file = join(script_dir, "logo.gif")
            icon = PhotoImage(file=gif_logo_file)

        self.tk.call("wm", "iconphoto", self._w, icon)
    except:
        global reported

        if reported:
            return

        print(_("Cannot set window icon").get())
        print_exc()
        reported = True
    def initialize_style():
        style = Style()
        global images
        images = (
            PhotoImage("img_close", data='''
                R0lGODlhCAAIAMIBAAAAADs7O4+Pj9nZ2Ts7Ozs7Ozs7Ozs7OyH+EUNyZWF0ZWQg
                d2l0aCBHSU1QACH5BAEKAAQALAAAAAAIAAgAAAMVGDBEA0qNJyGw7AmxmuaZhWEU
                5kEJADs=
                '''),
            PhotoImage("img_closeactive", data='''
                R0lGODlhCAAIAMIEAAAAAP/SAP/bNNnZ2cbGxsbGxsbGxsbGxiH5BAEKAAQALAAA
                AAAIAAgAAAMVGDBEA0qNJyGw7AmxmuaZhWEU5kEJADs=
                '''),
            PhotoImage("img_closepressed", data='''
                R0lGODlhCAAIAMIEAAAAAOUqKv9mZtnZ2Ts7Ozs7Ozs7Ozs7OyH+EUNyZWF0ZWQg
                d2l0aCBHSU1QACH5BAEKAAQALAAAAAAIAAgAAAMVGDBEA0qNJyGw7AmxmuaZhWEU
                5kEJADs=
            ''')
        )
    
        style.element_create("close", "image", "img_close",
            ("active", "pressed", "!disabled", "img_closepressed"),
            ("active", "!disabled", "img_closeactive"),
            border = 8,
            sticky = ''
        )
        style.layout("CloseButtonNotebook",
            [("CloseButtonNotebook.client", {"sticky": "nswe"})]
        )
        style.layout("CloseButtonNotebook.Tab",
[
    ("CloseButtonNotebook.tab", {
        "sticky": "NEWS", 
        "children": [
            ("CloseButtonNotebook.padding", {
                "side": "top", 
                "sticky": "NEWS",
                "children": [
                    ("CloseButtonNotebook.focus",
{
    "side": "top", 
    "sticky": "NEWS",
    "children": [
        ("CloseButtonNotebook.label", {"side": "left", "sticky": ''}),
        ("CloseButtonNotebook.close", {"side": "left", "sticky": ''}),
    ]
}
                    )
                ]
            })
        ]
    })
]
    )
Exemple #3
0
 def __init__(self, image, initialField, initialText):
     frm = Frame(root)
     frm.config(background="white")
     self.image = PhotoImage(format="gif", data=images[image.upper()])
     self.imageDimmed = PhotoImage(format="gif", data=images[image])
     self.img = Label(frm)
     self.img.config(borderwidth=0)
     self.img.pack(side="left")
     self.fld = Text(frm, **fieldParams)
     self.initScrollText(frm, self.fld, initialField)
     frm = Frame(root)
     self.txt = Text(frm, **textParams)
     self.initScrollText(frm, self.txt, initialText)
     for i in range(2):
         self.txt.tag_config(colors[i], background=colors[i])
         self.txt.tag_config("emph" + colors[i], foreground=emphColors[i])
def set_icon(root):
    # https://stackoverflow.com/a/11180300
    icon = os.path.join(os.path.dirname(__file__), 'icon.gif')
    try:
        img = PhotoImage(file=icon)
        root.tk.call('wm', 'iconphoto', root._w, '-default', img)
    except TclError:
        from traceback import print_exc
        print_exc()
Exemple #5
0
    def __init__(self):
        Tk.__init__(self)

        self.title("Android Synchronizer")

        try:
            ico = PhotoImage(file = join(dirname(__file__), "logo.gif"))
            self.tk.call("wm", "iconphoto", self._w, ico)
        except Exception as e:
            print("Failed to set icon: %s" % e)

        self._server = None

        self.rowconfigure(0, weight = 1)
        self.columnconfigure(0, weight = 1)