當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。