本文整理汇总了Python中javax.swing.JLabel.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Python JLabel.setLocation方法的具体用法?Python JLabel.setLocation怎么用?Python JLabel.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addSection
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setLocation [as 别名]
def addSection(self, name, fontstyle=None):
"""Creates a new section in the Popup menu."""
if self.isFirstSection:
self.isFirstSection = False
else:
self.menu.addSeparator() # menu.add(JSeparator()) ???
label = JLabel(name)
label.setLocation(4, 4)
if fontstyle is not None:
label.font = fontstyle
self.applyStyle(label)
self.menu.add(label)
示例2: TextView
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setLocation [as 别名]
class TextView(core.DataViewComponent):
def __init__(self,view,name,func,args=(),label=None):
core.DataViewComponent.__init__(self,label)
self.view=view
self.name=name
self.func=func
self.show_label=False
self.update_label()
self.data=self.view.watcher.watch(name,func,args=args)
self.text_label=JLabel('',verticalAlignment=JLabel.CENTER,horizontalAlignment=JLabel.CENTER)
self.text_label.font=Font('SansSerif',Font.BOLD,12)
self.font_size=12
self.add(self.text_label)
self.popup.add(JPopupMenu.Separator())
self.popup.add(JMenuItem('larger',actionPerformed=self.increase_font))
self.popup.add(JMenuItem('smaller',actionPerformed=self.decrease_font))
def increase_font(self,event):
self.font_size+=2
self.text_label.font=Font('SansSerif',Font.BOLD,self.font_size)
def decrease_font(self,event):
if self.font_size<7: return
self.font_size-=2
self.text_label.font=Font('SansSerif',Font.BOLD,self.font_size)
def paintComponent(self,g):
core.DataViewComponent.paintComponent(self,g)
data=self.data.get(start=self.view.current_tick,count=1)[0]
self.text_label.setSize(self.width,self.height-self.label_offset)
self.text_label.setLocation(0,self.label_offset)
self.text_label.text=data
def save(self):
info = core.DataViewComponent.save(self)
info['font_size']=self.font_size
return info
def restore(self,d):
core.DataViewComponent.restore(self,d)
self.font_size=d.get('font_size',12)
self.text_label.font=Font('SansSerif',Font.BOLD,self.font_size)