在本文中,我们将学习GetForegroundColour()
与wxPython的wx.StaticText类别关联的函数。GetForegroundColour()
函数返回用于StaticText的字体或前景的颜色。颜色的格式为(R,G,B,A)。不需要参数GetForegroundColour()
函数。
用法:
wx.StaticText.GetForegroundColour(self)
参数:
GetForegroundColour()函数中不需要任何参数。
Return Type:
颜色
代码示例:
# importing the module
import wx
# definition of the Example class
class Example(wx.Frame):
# instantiating the class
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
# method for creation of user interface
def InitUI(self):
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
# create parent panel for button
self.pnl = wx.Panel(self)
# create button at point (20, 20)
self.st = wx.StaticText(self.pnl, id = 1, label ="Button")
# change foreground colour of button
self.st.SetForegroundColour((10, 20, 255, 255))
# get foreground colour
fc = self.st.GetForegroundColour()
# print foreground colour
print(fc)
self.SetSize((350, 250))
self.SetTitle('wx.Button')
self.Centre()
# definition of the main function
def main():
# creating an App object
app = wx.App()
# creating an Example object
ex = Example(None)
# showing the Example object
ex.Show()
# running the App object
app.MainLoop()
# driver code
if __name__ == '__main__':
main()
控制台输出:
(10, 20, 255, 255)
输出窗口:
相关用法
- wxPython wx.MenuBar SetLabel()用法及代码示例
- wxPython wx.MenuBar GetHelpString()用法及代码示例
- wxPython wx.MenuBar SetHelpString()用法及代码示例
- wxPython wx.MenuBar FindMenuItem()用法及代码示例
- wxPython wx.MenuBar GetMenuLabelText()用法及代码示例
- wxPython wx.MenuBar GetMenuLabel()用法及代码示例
- wxPython wx.MenuBar GetMeuCount()用法及代码示例
- wxPython wx.MenuBar GetLabel()用法及代码示例
注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 wxPython – GetForegroundColour() function in wx.StaticText。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。