当前位置: 首页>>代码示例>>Python>>正文


Python Bus.offsetToName方法代码示例

本文整理汇总了Python中bus.Bus.offsetToName方法的典型用法代码示例。如果您正苦于以下问题:Python Bus.offsetToName方法的具体用法?Python Bus.offsetToName怎么用?Python Bus.offsetToName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bus.Bus的用法示例。


在下文中一共展示了Bus.offsetToName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Window

# 需要导入模块: from bus import Bus [as 别名]
# 或者: from bus.Bus import offsetToName [as 别名]
class Window(QtGui.QWidget):
    def drawBus(self,nx,ny,angle,qp):
      ang=angle/180.*math.pi
      angd=15
      line=8
      headx=+math.sin(ang)*line+nx
      heady=-math.cos(ang)*line+ny
      tailx=-math.sin(ang)*line+nx
      taily=+math.cos(ang)*line+ny
      wing1x=-math.sin(ang+angd+math.pi)*line+headx
      wing1y=+math.cos(ang+angd+math.pi)*line+heady
      wing2x=-math.sin(ang-angd+math.pi)*line+headx
      wing2y=+math.cos(ang-angd+math.pi)*line+heady
      qp.drawLine(headx,heady,tailx,taily)
      qp.drawLine(headx,heady,wing1x,wing1y)
      qp.drawLine(headx,heady,wing2x,wing2y)

    def backChange(self,setvalue):
      if self.bus!=None:
        self.bus.backward=setvalue
        self.update()
    def forwardChange(self,setvalue):
      if self.bus!=None:
        self.bus.forward=setvalue
        self.update()
    def showSettingWindow(self):
      self.settingwindow.show()
    def quitApplication(self):
      self.closeSaving()
      QtGui.qApp.quit()
    def closeSaving(self):
        self.settings.setValue('size', self.size())
        self.settings.setValue('pos', self.pos())
        self.settings.setValue('setsize', self.settingwindow.size())
        self.settings.setValue('setpos', self.settingwindow.pos())
        if self.bus!=None:
          self.settings.setValue('bus', self.busname)
          self.settings.setValue('offset', self.bus.busoffset)
          self.settings.setValue('backward', self.bus.backward)
          self.settings.setValue('forward', self.bus.forward)
    def closeEvent(self, e):
        self.closeSaving()
        e.accept()
    def changeOffset(self,index):
      self.bus.busoffset=self.bus.waypointlist[index][1]
      self.offset=self.bus.busoffset
      #self.showMessage("Monitoring "+self.busname+".\n Alert near "+self.bus.offsetToName(self.bus.busoffset))
      self.update()
    def changeShape(self,index):
        print "changeShape"
        tempoffset=self.offset
        self.settings.shape=self.nameid[index][1]
        self.bus=Bus(self.settings.shape,self.offset,self.backsb.value(),self.forwardsb.value())
        self.busname=self.nameid[index][0]
        self.showMessage("Monitoring "+self.busname+".\n Alert near "+self.bus.offsetToName(self.bus.busoffset))
        self.update()
        self.stopcb.clear()
        for n in self.bus.waypointlist:
            self.stopcb.addItem(n[0])
        stopnamelist=[x[0] for x in self.bus.waypointlist]
        self.stopcb.setCurrentIndex(stopnamelist.index(self.bus.offsetToName(tempoffset)))
    def __init__(self):
        self.bus=None
        self.count=0
        super(Window, self).__init__()
        #need to catch timeout exceptions etc...
        self.settings = QtCore.QSettings('busSettings.ini', QtCore.QSettings.IniFormat)
        self.settings.setFallbacksEnabled(False)    # File only, no fallback to registry or or.
        # Initial window size/pos last saved if available
        #self.resize(400, 300)
        #self.setGeometry(200, 200,500*self.bus.xfactor,500)
        self.resize(self.settings.value('size', QtCore.QSize(350, 500)))
        self.move(self.settings.value('pos', QtCore.QPoint(200, 200)))
        self.offset=int(self.settings.value('offset',89))
        self.busname=(self.settings.value('bus',None))
        self.setWindowTitle(u"busLocator map")
        self.show()
#-------------------basic menu item------------------
        self.settingAction = QtGui.QAction(u"setting", self,
                triggered=self.showSettingWindow)
        self.minimizeAction = QtGui.QAction(u"hide", self,
                triggered=self.hide)
        self.restoreAction = QtGui.QAction(u"show", self,
                triggered=self.showNormal)
        self.quitAction = QtGui.QAction(u"exit", self,
                triggered=self.quitApplication)
        #add menu
        self.trayIconMenu = QtGui.QMenu(self)
        self.trayIconMenu.addAction(self.restoreAction)
        self.trayIconMenu.addAction(self.minimizeAction)
        self.trayIconMenu.addAction(self.settingAction)
        self.trayIconMenu.addAction(self.quitAction)
        #self.trayIconMenu.clear()
        #self.trayIconMenu.addAction(self.quitAction)
        self.trayIcon = QtGui.QSystemTrayIcon(self)
        self.trayIcon.setContextMenu(self.trayIconMenu)
#-------------------basic menu end------------------
#-------------------icon------------------
        self.icon=QtGui.QIcon(":/images/bus.ico")
        self.trayIcon.setIcon(self.icon)
#.........这里部分代码省略.........
开发者ID:yangqian,项目名称:busLocator,代码行数:103,代码来源:bustray.py


注:本文中的bus.Bus.offsetToName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。