Changing ttk Button Height in Python

后端 未结 4 734
-上瘾入骨i
-上瘾入骨i 2020-12-15 23:15

This seems like a silly question, but is it possible to change the height of a ttk button manually?

Something like button = tkinter.Button(frame, text=\'hi\',

4条回答
  •  囚心锁ツ
    2020-12-15 23:22

    Just an example, as @Bryan said, "For example, you can pack the button into a frame", I did it like this:

    import Tkinter as tk
    import ttk
    
    class MyButton(ttk.Frame):
        def __init__(self, parent, height=None, width=None, text="", command=None, style=None):
            ttk.Frame.__init__(self, parent, height=height, width=width, style="MyButton.TFrame")
    
            self.pack_propagate(0)
            self._btn = ttk.Button(self, text=text, command=command, style=style)
            self._btn.pack(fill=tk.BOTH, expand=1)
    

提交回复
热议问题