PyQt4: How to make Icon bigger than QPushButton? (Pixmap Buttons) - python

I am struggling on making a Pixmap button, since there was no other option (That i knew) i tried using QIcon.
The picture that i wanted as button, was not fully square, i wanted to only show the pixmap, but with it still having a button function (Signals connecting to slots, etc.).
When i tried to make the Icons size equal to button, Icon would go up and it wouldn't fit in at all, and button would show outside of icon.
So the Question is:
How can i make icon greater than a QPushButton? so only icon would show and it would still have icon functions.
If this is over Icon borders, then is it any other way making Pixmap buttons?

You can simply use css to achieve that with the background-image property like this and also set the border to 0
btn.setStyleSheet("background-image: url('image.jpg'); border: none;")

I use PySide. Maybe the codes are similar
btn = QPushButton('')
btn.setIcon(QPixmap(image path))
# adjust width and height to fit the size of button.
btn.setIconSize(QSize(width, height))
# set zero border.
btn.setStyleSheet('QPushButton{border: 0px solid;}')

Related

Tkinter - how to change icon size or make black icon visible

I have two questions:
Is it possible to increase somehow size of the icon in tkinter? Because the icon choosen by me is not clear visible when I use root.iconbitmap(..).
I also have another icon, but it's black and is not visible on black taskbar. What can I do?
I don't believe it's possible to change the size of the icon, unfortunately. However, make sure that the icon your using is a .ico file not some other format. .ico files show up bigger and clearer than other formats.
As for the black icon problem, the color of the taskbar is determined by your Windows color settings. There isn't much you can do other than to make an icon that works for both dark and light colors. Although you could get rid of the default taskbar and make your own taskbar in tkinter with whatever colors you would like, if that's something you would like to undertake.

How to change the tkiner window border color?

I need to change the color of the Tkinter window border-color in windows 10 python. The border is shown in the image below.
I found a command that can delete the border
root.overrideredirect(1)
when I use this command I need to rebuild the border again but the functionality is different. So it's not an option.
Is there any way I could change the Tkinter window border color?
I only need to change the color of the border. Rebuilding the border is too much and some of the functionalities won't work properly.
Sorry you cannot change the color of the border as it is created by the OS and it changes device-to-device. But you can use overrideredirect(1) to cancel the border. And to exit the window, you can use the destroy() command.

How to hide a widget with pyuic5

Is there a way to hide a widget(in pyuic5).
I've tried:
self.playBtn.hide()
which doesn't cause an error, but doesn't hide the widget. That was kind of a shot in the dark, and the documentation isn't providing too much info. Any help is appreciated.
If you have a solid color background:
you can draw or create a sprite that is the same color of the background and position it on top of the button
Or
you can delete the element and re-create it when you want to show it

how to auto resize in pyqt4 python?

I want to auto resize the above picture at the size shown below when user resize the main window.
Is there any function to do this in pyqt4?
I was searching for an answer to this problem... but i can't find something related.
I've tried to set fixed minimum size but this doesn't work.
How to auto resize a window in pyqt4 (python)?
pictures is got in qtdesigner.
If you are using the QtDesigner, then its really easy. Have a look at layouts like vertical layout, horizontal layout
Follow step:
1. Add layout to your main window.
2. Right click main window and click 'layout vertically' as you want button below
the text area
3. Then add(drag-n-drop) your text area inside vertical area.
4. Add button and what not....
5. Have a look at 'http://doc.qt.io/qt-4.8/designer-layouts.html' google for
properties of layout like alignment of element. size, orientation.

How to make a wx Toolbar buttons larger?

I've got a wx.Toolbar and I'd like to make the buttons larger. I've searched and can't seem to find any concrete documentation on how to do this.
I'm also wondering how well this will translate across platforms; what will happen to the buttons and icons on OSX?
It depends on what you want to change: is it the size of the buttons or the size of the icons ?
To change the size of the buttons, use SetToolBitmapSize (24x24 for instance):
toolbar.SetToolBitmapSize((24, 24))
This will only change the size of the buttons, though. If you want to change the size of the icons, simply use bigger ones. The easiest way is to use wx.ArtProvider:
wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, (24, 24))
So, summing it up:
# Define the size of the icons and buttons
iconSize = (24, 24)
# Set the size of the buttons
toolbar.SetToolBitmapSize(iconSize)
# Add some button
saveIcon = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, iconSize)
toolBar.AddSimpleTool(1, saveIcon, "Save", "Save current file")
Remark: As SetToolBitmapSize changes the size of the buttons, not the size of the icons, you can set the buttons to be larger than the icons. This should leave blank space around the icons.
Doesn't the size of the toolbar adapts itself automatically to the size of the bitmap icons? I think if you want a bigger toolbar, you need bigger bitmaps.
On Mac OS X Big Sur running python 3.9 and wxpython 4.1.1. this call
toolbar.SetToolBitmapSize((24, 24))
does not work. The algorithm seems to be that of the icons associated with the toolbar wxPython picks the largest one and sets that size for all the other icons.

Categories

Resources