CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

Align content in CTKButtons

Open DomGravante opened this issue 2 years ago • 3 comments

Please consider adding another flag in the creation of CTKButtons to allow for the text and image to be aligned. I've attached an image below of the benefits to adding this optional flag. I personally think this looks a lot more clean and more professional, and could be a great option for users looking keep text looking clean and oriented. CTKButton_Align

It could just be an optional flag, like: button1 = ctk.CTkButton(self.frame, text ="Start Program", image=self.listIcon), compound="left", align_content="w") button2 = ctk.CTkButton(self.frame, text ="Save", image=self.saveIcon), compound="right", align_content="e")

I went to manually add it and submit a pull request, since it seems like a pretty easy replacement of some of the sticky arguments in the button's draw method, but I found myself having some issues with the alignment. I think the best and simplest way is to have the image_label and text_label masters be a separate frame, which can be oriented as needed. I almost have it working and will submit it in a pull request when done.

Any thoughts?

DomGravante avatar Jun 07 '22 16:06 DomGravante

I will have a look at this!

TomSchimansky avatar Jun 09 '22 07:06 TomSchimansky

Good Morning... is this problem now solved ? If yes.. what ist the special word ? align_content ?? at the moment not integrated in the current version..

austrianadrian avatar Aug 17 '22 05:08 austrianadrian

It's not solved yet, but I will do it in the next days. The pull request provided by @DomGravante was not sufficient, because it destroyed other functionality, but I will try to do it...

TomSchimansky avatar Aug 17 '22 09:08 TomSchimansky

With version 5.0.0 I added the anchorand border_spaing option, the text and image can now be aligned in the button.

TomSchimansky avatar Dec 01 '22 11:12 TomSchimansky