CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

cannot increase the size of combobox without it glitching out?

Open nejofs opened this issue 3 years ago • 9 comments

Here is an image of how the combo boxes are glitched: image

I have used pretty average code but i am not using a grid just a normal x and y coordinates:

from tkinter import *
from tkinter.ttk import Progressbar
from tkinter.ttk import Combobox
from tkinter.ttk import Notebook
from tkinter.ttk import Treeview
from PIL import Image, ImageTk
import tkinter.font
import tkinter.messagebox
import customtkinter



class Widget1():
    def __init__(self, parent):
        self.gui(parent)

    def gui(self, parent):
        if parent == 0:
            self.w1 = Tk()
            self.w1.geometry('500x450')
        else:
            self.w1 = Frame(parent)
            self.w1.place(x = 0, y = 0, width = 500, height = 450)
        self.combo1 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 16), cursor = "arrow", state = "normal")
        self.combo1.place(x = 180, y = 330, width = 250, height = 52)
        self.combo2 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 16), cursor = "arrow", state = "normal")
        self.combo2.place(x = 80, y = 260, width = 350, height = 62)
        self.combo3 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 16), cursor = "arrow", state = "normal")
        self.combo3.place(x = 170, y = 130, width = 110, height = 80)
        self.combo4 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 12), cursor = "arrow", state = "normal")
        self.combo4.place(x = 50, y = 50, width = 360, height = 40)

if __name__ == '__main__':
    a = Widget1(0)
    a.w1.mainloop()

Does anyone know how to resize a combo box?

nejofs avatar Jan 22 '23 19:01 nejofs

You have to pass the width and height arguments to the constructor of the widget, not the place method. I have never seen that you can also pass them to the place method and I don't know why it behaves different then, but I will prevent this possibility in the next version.

TomSchimansky avatar Jan 22 '23 20:01 TomSchimansky

And if i need to use relwidth in plase()? I use that way: for k, nxt in self.smb_compress_method.children.items(): if k == '!entry': val = nxt.grid_info() val['padx'] = (6, 100) nxt.grid(val)

davidrf72 avatar Mar 03 '23 22:03 davidrf72

@TomSchimansky I also experienced this problem with CTK v5.1.2 when using weights in a grid (and sticking to "NSEW" to fill the cell).

from customtkinter import CTk, CTkComboBox
from typing import Any


class Window(CTk):
    """
    ComboBox issue showcase
    """

    __test_combobox: CTkComboBox

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)
        self.geometry("500x200")

        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)

        self.__test_combobox = CTkComboBox(self, values=["a", "b", "c"])

        self.__test_combobox.grid(row=0, column=0, sticky="NSEW")


if __name__ == '__main__':
    win = Window()
    win.mainloop()

image

LukasKrah avatar Mar 29 '23 12:03 LukasKrah

self.__test_combobox.grid(row=0, column=0, sticky="NSEW")

You're telling the widget to fill the whole window with this, you most likely just want to do.

self.__test_combobox.grid(row=0, column=0, sticky="EW")

if you really need to change the height of it pass it to the constructor of the widget.

self.__test_combobox = CTkComboBox(self, values=["a", "b", "c"], height=50)

ElectricCandlelight avatar Mar 29 '23 12:03 ElectricCandlelight

@ElectricCandlelight Thanks for your answer. I already thought of this solution. But what if i want a dynamic height?

LukasKrah avatar Mar 30 '23 07:03 LukasKrah

Out of curiosity why would you need it to be taller than standard height? I can't think of a situation were it would be beneficial for it to be taller than the standard height since it only displays one line of text.

I actually think it's possible to do it without it glitching out. Will post an example once I get a chance.

ElectricCandlelight avatar Mar 30 '23 09:03 ElectricCandlelight

'class Widget1(): def init(self, parent): self.gui(parent)

def gui(self, parent):
    if parent == 0:
        self.w1 = Tk()
        self.w1.geometry('500x450')
    else:
        self.w1 = Frame(parent)
        self.w1.place(x = 0, y = 0, width = 500, height = 450)
    self.combo1 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 16), cursor = "arrow", state = "normal", width = 250, height = 52)
    self.combo1.place(x = 180, y = 330)
    self.combo2 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 16), cursor = "arrow", state = "normal", width = 350, height = 62)
    self.combo2.place(x = 80, y = 260)
    self.combo3 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 16), cursor = "arrow", state = "normal", width = 110, height = 80)
    self.combo3.place(x = 170, y = 130)
    self.combo4 = customtkinter.CTkComboBox(self.w1, font = ("Helvetica Neue", 12), cursor = "arrow", state = "normal", width = 360, height = 40)
    self.combo4.place(x = 50, y = 50)'

Screenshot (22) made some code changes added the height and width attributes in CTkcomboBox() instead for place()

dishant440 avatar Jun 05 '23 06:06 dishant440

how to limit the value of option menu?

sineshawl avatar Feb 26 '24 14:02 sineshawl

Hiii, I have almost the same problem. I use the relwidth and relheight. And it does the same thing. Did anyone figure this out yet? Capture pokazene

kikos311 avatar Jul 02 '24 15:07 kikos311