Skip to content

Commit

Permalink
Switch to using bitmaps in small buttons
Browse files Browse the repository at this point in the history
wxGtk has issues with determining text size correctly
and sometimes button labels are not visible.
Icons work better.
  • Loading branch information
qu1ck committed Jul 11, 2021
1 parent 095f336 commit 4df0dd3
Show file tree
Hide file tree
Showing 13 changed files with 539 additions and 120 deletions.
Binary file added InteractiveHtmlBom/dialog/bitmaps/btn-arrow-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InteractiveHtmlBom/dialog/bitmaps/btn-arrow-up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InteractiveHtmlBom/dialog/bitmaps/btn-minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InteractiveHtmlBom/dialog/bitmaps/btn-plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InteractiveHtmlBom/dialog/bitmaps/btn-question.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 50 additions & 28 deletions InteractiveHtmlBom/dialog/dialog_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,12 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
bSizer20 = wx.BoxSizer( wx.HORIZONTAL )

self.fileNameFormatTextControl = wx.TextCtrl( sbSizer6.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer20.Add( self.fileNameFormatTextControl, 1, wx.ALL|wx.EXPAND, 5 )
bSizer20.Add( self.fileNameFormatTextControl, 1, wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.LEFT|wx.TOP, 5 )

self.m_button12 = wx.Button( sbSizer6.GetStaticBox(), wx.ID_ANY, u"?", wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
bSizer20.Add( self.m_button12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 4 )
self.m_bpButton5 = wx.BitmapButton( sbSizer6.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_bpButton5.SetMinSize( wx.Size( 30,30 ) )

bSizer20.Add( self.m_bpButton5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )


fgSizer1.Add( bSizer20, 1, wx.EXPAND, 5 )
Expand Down Expand Up @@ -269,17 +271,29 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.

bSizer5 = wx.BoxSizer( wx.VERTICAL )

self.m_button1 = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, u"Up", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer5.Add( self.m_button1, 0, wx.ALL, 5 )
self.m_btnSortUp = wx.BitmapButton( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )

self.m_btnSortUp.SetBitmap( wx.NullBitmap )
self.m_btnSortUp.SetMinSize( wx.Size( 30,30 ) )

bSizer5.Add( self.m_btnSortUp, 0, wx.ALL, 5 )

self.m_btnSortDown = wx.BitmapButton( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )

self.m_btnSortDown.SetBitmap( wx.NullBitmap )
self.m_btnSortDown.SetMinSize( wx.Size( 30,30 ) )

bSizer5.Add( self.m_btnSortDown, 0, wx.ALL, 5 )

self.m_button2 = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, u"Dn", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer5.Add( self.m_button2, 0, wx.ALL, 5 )
self.m_btnSortAdd = wx.BitmapButton( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_btnSortAdd.SetMinSize( wx.Size( 30,30 ) )

self.m_button3 = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, u"+", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer5.Add( self.m_button3, 0, wx.ALL, 5 )
bSizer5.Add( self.m_btnSortAdd, 0, wx.ALL, 5 )

self.m_button4 = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, u"-", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer5.Add( self.m_button4, 0, wx.ALL, 5 )
self.m_btnSortRemove = wx.BitmapButton( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_btnSortRemove.SetMinSize( wx.Size( 30,30 ) )

bSizer5.Add( self.m_btnSortRemove, 0, wx.ALL, 5 )


bSizer4.Add( bSizer5, 0, 0, 5 )
Expand All @@ -305,11 +319,15 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.

bSizer512 = wx.BoxSizer( wx.VERTICAL )

self.m_button112 = wx.Button( blacklistSizer.GetStaticBox(), wx.ID_ANY, u"+", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer512.Add( self.m_button112, 0, wx.ALL, 5 )
self.m_btnBlacklistAdd = wx.BitmapButton( blacklistSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_btnBlacklistAdd.SetMinSize( wx.Size( 30,30 ) )

bSizer512.Add( self.m_btnBlacklistAdd, 0, wx.ALL, 5 )

self.m_btnBlacklistRemove = wx.BitmapButton( blacklistSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_btnBlacklistRemove.SetMinSize( wx.Size( 30,30 ) )

self.m_button212 = wx.Button( blacklistSizer.GetStaticBox(), wx.ID_ANY, u"-", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer512.Add( self.m_button212, 0, wx.ALL, 5 )
bSizer512.Add( self.m_btnBlacklistRemove, 0, wx.ALL, 5 )


bSizer412.Add( bSizer512, 0, 0, 5 )
Expand Down Expand Up @@ -339,13 +357,13 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.

# Connect Events
self.Bind( wx.EVT_SIZE, self.OnSize )
self.m_button12.Bind( wx.EVT_BUTTON, self.OnNameFormatHintClick )
self.m_button1.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderUp )
self.m_button2.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderDown )
self.m_button3.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderAdd )
self.m_button4.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderRemove )
self.m_button112.Bind( wx.EVT_BUTTON, self.OnComponentBlacklistAdd )
self.m_button212.Bind( wx.EVT_BUTTON, self.OnComponentBlacklistRemove )
self.m_bpButton5.Bind( wx.EVT_BUTTON, self.OnNameFormatHintClick )
self.m_btnSortUp.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderUp )
self.m_btnSortDown.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderDown )
self.m_btnSortAdd.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderAdd )
self.m_btnSortRemove.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderRemove )
self.m_btnBlacklistAdd.Bind( wx.EVT_BUTTON, self.OnComponentBlacklistAdd )
self.m_btnBlacklistRemove.Bind( wx.EVT_BUTTON, self.OnComponentBlacklistRemove )

def __del__( self ):
pass
Expand Down Expand Up @@ -411,11 +429,15 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.

bSizer5 = wx.BoxSizer( wx.VERTICAL )

self.m_button1 = wx.Button( extraFieldsSizer.GetStaticBox(), wx.ID_ANY, u"Up", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer5.Add( self.m_button1, 0, wx.ALL, 5 )
self.m_btnUp = wx.BitmapButton( extraFieldsSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_btnUp.SetMinSize( wx.Size( 30,30 ) )

bSizer5.Add( self.m_btnUp, 0, wx.ALL, 5 )

self.m_btnDown = wx.BitmapButton( extraFieldsSizer.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 )
self.m_btnDown.SetMinSize( wx.Size( 30,30 ) )

self.m_button2 = wx.Button( extraFieldsSizer.GetStaticBox(), wx.ID_ANY, u"Dn", wx.DefaultPosition, wx.Size( 30,30 ), 0|wx.BORDER_DEFAULT )
bSizer5.Add( self.m_button2, 0, wx.ALL, 5 )
bSizer5.Add( self.m_btnDown, 0, wx.ALL, 5 )


bSizer4.Add( bSizer5, 0, 0, 5 )
Expand Down Expand Up @@ -498,8 +520,8 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
# Connect Events
self.Bind( wx.EVT_SIZE, self.OnSize )
self.netlistFilePicker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnNetlistFileChanged )
self.m_button1.Bind( wx.EVT_BUTTON, self.OnExtraFieldsUp )
self.m_button2.Bind( wx.EVT_BUTTON, self.OnExtraFieldsDown )
self.m_btnUp.Bind( wx.EVT_BUTTON, self.OnExtraFieldsUp )
self.m_btnDown.Bind( wx.EVT_BUTTON, self.OnExtraFieldsDown )
self.normalizeCaseCheckbox.Bind( wx.EVT_CHECKBOX, self.OnNetlistFileChanged )
self.boardVariantFieldBox.Bind( wx.EVT_COMBOBOX, self.OnBoardVariantFieldChange )

Expand Down
36 changes: 27 additions & 9 deletions InteractiveHtmlBom/dialog/settings_dialog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Subclass of settings_dialog, which is generated by wxFormBuilder."""
import os
import re

Expand All @@ -16,7 +15,7 @@ def __init__(self, extra_data_func, config_save_func,
file_name_format_hint, version):
dialog_base.SettingsDialogBase.__init__(self, None)
self.panel = SettingsDialogPanel(
self, extra_data_func, config_save_func, file_name_format_hint)
self, extra_data_func, config_save_func, file_name_format_hint)
best_size = self.panel.BestSize
# hack for some gtk themes that incorrectly calculate best size
best_size.IncBy(dx=0, dy=30)
Expand Down Expand Up @@ -82,6 +81,21 @@ class GeneralSettingsPanel(dialog_base.GeneralSettingsPanelBase):
def __init__(self, parent, file_name_format_hint):
dialog_base.GeneralSettingsPanelBase.__init__(self, parent)
self.file_name_format_hint = file_name_format_hint
bitmaps = os.path.join(os.path.dirname(__file__), "bitmaps")
self.m_btnSortUp.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-arrow-up.png"), wx.BITMAP_TYPE_PNG))
self.m_btnSortDown.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-arrow-down.png"), wx.BITMAP_TYPE_PNG))
self.m_btnSortAdd.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-plus.png"), wx.BITMAP_TYPE_PNG))
self.m_btnSortRemove.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-minus.png"), wx.BITMAP_TYPE_PNG))
self.m_bpButton5.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-question.png"), wx.BITMAP_TYPE_PNG))
self.m_btnBlacklistAdd.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-plus.png"), wx.BITMAP_TYPE_PNG))
self.m_btnBlacklistRemove.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-minus.png"), wx.BITMAP_TYPE_PNG))

# Handlers for GeneralSettingsPanelBase events.
def OnComponentSortOrderUp(self, event):
Expand All @@ -103,8 +117,8 @@ def OnComponentSortOrderDown(self, event):

def OnComponentSortOrderAdd(self, event):
item = wx.GetTextFromUser(
"Characters except for A-Z will be ignored.",
"Add sort order item")
"Characters other than A-Z will be ignored.",
"Add sort order item")
item = re.sub('[^A-Z]', '', item.upper())
if item == '':
return
Expand All @@ -114,7 +128,7 @@ def OnComponentSortOrderAdd(self, event):
return
self.componentSortOrderBox.Append(item)
self.componentSortOrderBox.SetSelection(
self.componentSortOrderBox.Count - 1)
self.componentSortOrderBox.Count - 1)

def OnComponentSortOrderRemove(self, event):
selection = self.componentSortOrderBox.Selection
Expand All @@ -129,8 +143,8 @@ def OnComponentSortOrderRemove(self, event):

def OnComponentBlacklistAdd(self, event):
item = wx.GetTextFromUser(
"Characters except for A-Z 0-9 and * will be ignored.",
"Add blacklist item")
"Characters other than A-Z 0-9 and * will be ignored.",
"Add blacklist item")
item = re.sub('[^A-Z0-9*]', '', item.upper())
if item == '':
return
Expand All @@ -139,8 +153,7 @@ def OnComponentBlacklistAdd(self, event):
self.blacklistBox.SetSelection(found)
return
self.blacklistBox.Append(item)
self.blacklistBox.SetSelection(
self.blacklistBox.Count - 1)
self.blacklistBox.SetSelection(self.blacklistBox.Count - 1)

def OnComponentBlacklistRemove(self, event):
selection = self.blacklistBox.Selection
Expand Down Expand Up @@ -169,6 +182,11 @@ def __init__(self, parent, extra_data_func):
dialog_base.ExtraFieldsPanelBase.__init__(self, parent)
self.extra_data_func = extra_data_func
self.extra_field_data = None
bitmaps = os.path.join(os.path.dirname(__file__), "bitmaps")
self.m_btnUp.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-arrow-up.png"), wx.BITMAP_TYPE_PNG))
self.m_btnDown.SetBitmap(wx.Bitmap(
os.path.join(bitmaps, "btn-arrow-down.png"), wx.BITMAP_TYPE_PNG))

# Handlers for ExtraFieldsPanelBase events.
def OnExtraFieldsUp(self, event):
Expand Down
70 changes: 70 additions & 0 deletions icons/btn-arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions icons/btn-arrow-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4df0dd3

Please sign in to comment.