def _post_processing_task_started(self):
"""Show a 'processing' message on the UI while the post processing task is executing."""
pub.unsubscribe(self._post_processing_task_started, RunUploaderTopics.started_post_processing)
pub.subscribe(self._post_processing_task_completed, RunUploaderTopics.finished_post_processing)
pub.subscribe(self._post_processing_task_failed, RunUploaderTopics.failed_post_processing)
logging.info("Post-processing started, updating UI.")
self.Freeze()
self._post_processing_sizer = wx.BoxSizer(wx.HORIZONTAL)
self._post_processing_placeholder = ProcessingPlaceholderText(self)
self._post_processing_placeholder.SetFont(wx.Font(pointSize=18, family=wx.FONTFAMILY_DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_BOLD, face="Segoe UI Symbol"))
self._post_processing_text = wx.StaticText(self, label="Executing post-processing task.")
self._post_processing_text.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD))
self._post_processing_text.Wrap(350)
self._post_processing_text.SetToolTipString("Executing command `{}`.".format(read_config_option("completion_cmd")))
self._post_processing_sizer.Add(self._post_processing_text, flag=wx.RIGHT, border=5, proportion=1)
self._post_processing_sizer.Add(self._post_processing_placeholder, flag=wx.LEFT, border=5, proportion=0)
self._sizer.Insert(0, self._post_processing_sizer, flag=wx.EXPAND | wx.ALL, border=5)
self.Layout()
self.Thaw()
python类FONTWEIGHT_BOLD的实例源码
def initPieMenu(self):
font = wx.Font(pointSize=10, family=wx.FONTFAMILY_SWISS,
style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD,
#underline=False, face='DejaVu Serif')
#underline=False, faceName='Utopia') #wxpython3
underline=False, face='Utopia')
self.pieMenu = widgets.PieMenu(self,
choices=self.pg.choices, #font=font,
rotation=4.0*np.pi/len(self.pg.choices),
colors=('turquoise', 'red', 'blue violet', 'orange',
'blue', 'crimson'))
#colors=('turquoise', 'red', 'blue', 'green',
# 'yellow', 'blue violet'))
def initFont(self, font):
"""Initialize font for drawing text.
"""
# if none, use SWISS font
if font is None:
self.font = \
wx.Font(pointSize=12, family=wx.FONTFAMILY_SWISS,
style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD,
#underline=False)#, faceName='Utopia') # wxpython3
underline=False)#, face='Utopia') # wxpython3
# otherwise, use given font
else:
self.font = font
def draw_bitmap_rectangle(bitmap, faces):
"""Draw rectangle on bitmap."""
dc = wx.MemoryDC(bitmap.bmp)
dc.SetPen(wx.BLUE_PEN)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetTextBackground('black')
dc.SetTextForeground('white')
dc.SetBackgroundMode(wx.SOLID)
dc.SetFont(wx.Font(8,
wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_BOLD))
for face in faces:
dc.DrawRectangle(
face.rect.left * bitmap.scale,
face.rect.top * bitmap.scale,
face.rect.width * bitmap.scale,
face.rect.height * bitmap.scale,
)
if face.name:
text_width, text_height = dc.GetTextExtent(face.name)
dc.DrawText(face.name,
face.rect.left * bitmap.scale,
face.rect.top * bitmap.scale - text_height)
dc.SelectObject(wx.NullBitmap)
bitmap.bitmap.SetBitmap(bitmap.bmp)
def initMessageArea(self):
"""Initialize the message log area.
"""
# font for messages
msgFont = wx.Font(pointSize=11, family=wx.FONTFAMILY_MODERN,
style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL,
underline=False)
# font for CEBL introduction message
helloFont = wx.Font(pointSize=24, family=wx.FONTFAMILY_ROMAN,
style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD, underline=True)
# the message log
messageControlBox = widgets.ControlBox(self.scrolledPanel,
label='Message Log', orient=wx.VERTICAL)
self.messageArea = wx.TextCtrl(self.scrolledPanel,
style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH)
self.messageArea.SetMinSize((150,150))
messageControlBox.Add(self.messageArea, proportion=1, flag=wx.ALL | wx.EXPAND, border=10)
# intro message
self.messageArea.SetDefaultStyle(
#wx.TextAttr(colText=wx.Colour('black'), font=helloFont)) # wxpython3
wx.TextAttr(font=helloFont))
self.messageArea.AppendText('Welcome to CEBL!\n\n')
# setup message style
self.messageArea.SetDefaultStyle(wx.TextAttr())
#self.messageArea.SetDefaultStyle(wx.TextAttr(colText=wx.Colour('black'), font=msgFont)) # wxpython3
self.messageArea.SetDefaultStyle(wx.TextAttr(font=msgFont))
# add the message area text ctrl widget as a log target
self.mgr.logger.addTextCtrl(self.messageArea)
messageControlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
# button for saving the message log to a file
self.saveMessagesButton = wx.Button(self.scrolledPanel, label='Save')
messageControlSizer.Add(self.saveMessagesButton, proportion=0,
flag=wx.LEFT | wx.BOTTOM | wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.saveMessages, self.saveMessagesButton)
# button for clearing the message log
self.clearMessagesButton = wx.Button(self.scrolledPanel, label='Clear')
messageControlSizer.Add(self.clearMessagesButton, proportion=0,
flag=wx.BOTTOM | wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.clearMessages, self.clearMessagesButton)
# set up verbose logging
self.verboseMessagesCheckBox = wx.CheckBox(self.scrolledPanel, label='Verbose')
messageControlSizer.Add(self.verboseMessagesCheckBox, proportion=0,
flag=wx.BOTTOM | wx.RIGHT, border=10)
messageControlBox.Add(messageControlSizer, proportion=0, flag=wx.EXPAND)
# sizer for message log area
self.messageSizer = wx.BoxSizer(orient=wx.VERTICAL)
self.messageSizer.Add(messageControlBox, proportion=1,
flag=wx.ALL | wx.EXPAND, border=10)
def drawGrid(self, dc):
"""Draw the grid characters and highlights.
Args:
dc: wx.DC drawing context. Calling the methods of dc will
modify the drawing accordingly.
"""
##dc.SetFont(self.gridFont) # setting the font for the text
# figuring out what is the y-offset for the grid of symbols
yOffset = self.winHeight*32/340.0
if len(self.copyText) == 0:
yOffset = self.winHeight * 14/340.0
# figuring out the distances between each symbol horizontaly and vertically
dx = (self.winWidth+0.0)/(self.nCols+1)
dy = (self.winHeight-yOffset)/(self.nRows+1)
for i in xrange(self.nRows):
for j in xrange(self.nCols):
# select the color and font for the next symbol
mark = self.marked[i,j]
if mark == grid.normal:
dc.SetTextForeground(self.gridColor)
elif mark == grid.highlighted:
dc.SetTextForeground(self.highlightColor)
self.gridFont.SetWeight(wx.FONTWEIGHT_BOLD)
elif mark == grid.unhighlighted:
dc.SetTextForeground(self.unhighlightColor)
elif mark == grid.selected:
dc.SetTextForeground(self.selectColor)
self.gridFont.SetWeight(wx.FONTWEIGHT_BOLD)
else:
raise Exception('Invalid mark value %d.' % mark)
dc.SetFont(self.gridFont)
# get extents of symbol
text = self.grid[i,j]
textWidth, textHeight = dc.GetTextExtent(text)
# draw next symbol
#dc.DrawText(self.grid[i,j], (j+0.7)*dx, (i+0.7)*dy+yOffset)
dc.DrawText(self.grid[i,j],
(j+1.0)*dx-textWidth/2.0,
(i+1.0)*dy+yOffset-textHeight/2.0)
self.gridFont.SetWeight(wx.FONTWEIGHT_NORMAL)
def __init__(self, parent, info):
wx.Dialog.__init__(self, parent, title="About Bonsu", size=(460,300))
self.SetSizeHints(450,300,-1,-1)
self.parent = parent
self.info = info
self.vboxborder = wx.BoxSizer(wx.VERTICAL)
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.icon = wx.Image(os.path.join(os.path.dirname(os.path.dirname(__file__)),'image', 'bonsu.ico'), wx.BITMAP_TYPE_ICO)
if IsNotWX4():
self.bitmap = wx.BitmapFromImage(self.icon)
else:
self.bitmap = wx.Bitmap(self.icon)
self.staticbmp = wx.StaticBitmap(self, -1, self.bitmap)
self.vbox.Add(self.staticbmp, 0, flag=wx.CENTER, border=5)
namestr = info.GetName()+" "+info.GetVersion()
self.namefont = wx.Font((parent.font.GetPointSize()+8),parent.font.GetFamily(),wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
self.name = wx.StaticText(self, label=namestr)
self.name.SetFont(self.namefont)
self.vbox.Add((-1, 5))
self.vbox.Add(self.name, 0, flag=wx.CENTER, border=5)
self.vbox.Add((-1, 5))
self.description = wx.StaticText(self, label=info.GetDescription(), style=wx.ALIGN_CENTRE_HORIZONTAL)
self.description.Wrap(400)
self.vbox.Add(self.description, 0, flag=wx.CENTER, border=5)
self.vbox.Add((-1, 5))
self.copyright = wx.StaticText(self, label=info.GetCopyright())
self.vbox.Add(self.copyright, 0, flag=wx.CENTER, border=5)
self.vbox.Add((-1, 5))
if IsNotWX4():
self.web = wx.StaticText(self, label=info.GetWebSite()[0])
else:
self.web = wx.StaticText(self, label=info.GetWebSiteURL())
self.vbox.Add(self.web, 0, flag=wx.CENTER, border=5)
self.vbox.Add((-1, 10))
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
self.credits =wx.Button(self, label="More")
self.Bind(wx.EVT_BUTTON, self.OnCredits, self.credits)
self.hbox.Add(self.credits)
self.hbox.Add((10, -1))
self.license =wx.Button(self, label="License")
self.Bind(wx.EVT_BUTTON, self.OnLicense, self.license)
self.hbox.Add(self.license)
self.hbox.Add((10, -1))
self.close =wx.Button(self, label="Close")
self.Bind(wx.EVT_BUTTON, self.OnClose, self.close)
self.hbox.Add(self.close)
self.vbox.Add(self.hbox, 0, flag=wx.CENTER, border=5)
self.vbox.Add((-1, 10))
self.vboxborder.Add(self.vbox, 1, flag=wx.CENTER|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=20)
self.SetSizer( self.vboxborder )
self.SetAutoLayout(True)
self.Fit()
self.Layout()
self.Show()
def __init__(self, parent, info):
title = _("About") + " " + info.Name
wx.Dialog.__init__(self, parent, title=title)
self.info = info
if parent and parent.GetIcon():
self.SetIcon(parent.GetIcon())
image = None
if self.info.Icon:
bitmap = wx.BitmapFromIcon(self.info.Icon)
image = wx.StaticBitmap(self, bitmap=bitmap)
name = wx.StaticText(self, label="%s %s" % (info.Name, info.Version))
description = wx.StaticText(self, label=info.Description)
description.Wrap(400)
copyright = wx.StaticText(self, label=info.Copyright)
url = HyperLinkCtrl(self, label=info.WebSite[0], URL=info.WebSite[1])
font = name.GetClassDefaultAttributes().font
font.SetWeight(wx.FONTWEIGHT_BOLD)
font.SetPointSize(18)
name.SetFont(font)
credits = wx.Button(self, id=wx.ID_ABOUT, label=_("C&redits"))
license = wx.Button(self, label=_("&License"))
close = wx.Button(self, id=wx.ID_CANCEL, label=_("&Close"))
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(credits, flag=wx.CENTER | wx.LEFT | wx.RIGHT, border=5)
btnSizer.Add(license, flag=wx.CENTER | wx.RIGHT, border=5)
btnSizer.Add(close, flag=wx.CENTER | wx.RIGHT, border=5)
sizer = wx.BoxSizer(wx.VERTICAL)
if image:
sizer.Add(image, flag=wx.CENTER | wx.TOP | wx.BOTTOM, border=5)
sizer.Add(name, flag=wx.CENTER | wx.BOTTOM, border=10)
sizer.Add(description, flag=wx.CENTER | wx.BOTTOM, border=10)
sizer.Add(copyright, flag=wx.CENTER | wx.BOTTOM, border=10)
sizer.Add(url, flag=wx.CENTER | wx.BOTTOM, border=15)
sizer.Add(btnSizer, flag=wx.CENTER | wx.BOTTOM, border=5)
container = wx.BoxSizer(wx.VERTICAL)
container.Add(sizer, flag=wx.ALL, border=10)
self.SetSizer(container)
self.Layout()
self.Fit()
self.Centre()
self.Show(True)
self.SetEscapeId(close.GetId())
credits.Bind(wx.EVT_BUTTON, self.on_credits)
license.Bind(wx.EVT_BUTTON, self.on_license)
close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy())