Wednesday, November 27, 2024
Google search engine
HomeLanguageswxPython | GetToolBitmapSize() function in python

wxPython | GetToolBitmapSize() function in python

In this article we are going to learn about GetToolBitmapSize() function of wxPython. GetToolBitmapSize() returns the size of bitmap that a toolbar expects to have. 

The default bitmap size is platform-dependent: for example, it is 16×15 for MSW and 24×24 for GTK. This size does not necessarily indicate the best size to use for the toolbars on the given platform, for this you should use ArtProvider::GetNativeSizeHint(wxART_TOOLBAR) but in any case, as the bitmap size is deduced automatically from the size of the bitmaps associated with the tools added to the toolbar, it is usually unnecessary to call SetToolBitmapSize explicitly.

Syntax: 

wx.ToolBar.GetToolBitmapSize(self)

Parameters : 

No Parameters in GetToolBitmapSize() function.

Return Type: 

wx.Size

Code Example:  

Python3




import wx
 
 
class Example(wx.Frame):
    global count
    count = 0;
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
        self.toolbar.SetMargins(10, 10)
        # Add Tools Using AddTool function
        rtool = self.toolbar.AddTool(13, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2")
        stool = self.toolbar.AddTool(14, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
 
        self.toolbar.Realize()
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
 
        # print tool bitmap size
        print(self.toolbar.GetToolBitmapSize())
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output : 

(32, 32)

Code Example 2:  

Python3




import wx
 
class Example(wx.Frame):
    global count
    count = 0;
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
        self.toolbar.SetMargins(10, 10)
        # Add Tools Using AddTool function
        rtool = self.toolbar.AddTool(13, 'twoTool', wx.Bitmap('user.png'), shortHelp ="Simple Tool2")
 
        self.toolbar.Realize()
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
 
        # print tool bitmap size
        print(self.toolbar.GetToolBitmapSize())
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output: 

(24, 24)

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments