本文整理汇总了Python中Manager.Manager类的典型用法代码示例。如果您正苦于以下问题:Python Manager类的具体用法?Python Manager怎么用?Python Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Manager类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Trigger
class Trigger(SignalManager, TriggerManager):
def __init__(self, editor):
SignalManager.__init__(self)
TriggerManager.__init__(self, editor)
self.__init_attributes(editor)
self.connect(self.__trigger, "activate", self.__show_window_cb)
def __init_attributes(self, editor):
self.__editor = editor
self.__manager = None
self.__trigger = self.create_trigger("show-advanced-configuration-window")
from MenuItem import MenuItem
self.__menuitem = MenuItem(editor)
return
def __show_window_cb(self, *args):
try:
self.__manager.show()
except AttributeError:
from Manager import Manager
self.__manager = Manager(self.__editor)
self.__manager.show()
return
def destroy(self):
if self.__manager: self.__manager.destroy()
if self.__menuitem: self.__menuitem.destroy()
self.remove_triggers()
self.disconnect()
del self
return
示例2: init
def init():
"""
Game initialization function.
1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and
stores references to them in an instance of L{EventManager}.
2. Several listeners are started and registered with eventManager:
- Instance of L{Universe} (universe)
- Instance of L{UserInterface} (ui)
- Instance of L{Window} (gameWindow)
3. We send the eventManager a message to start the game
- This message is interpreted by the gameWindow
"""
debugger = Debugger()
eventTimer = EventTimer()
#Create the event manager for low-level events
eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
#classes will be needed later?
try:
client = GameClient(eventManager,host='10.41.24.79',port=1567)
except:
pass
#Create the occurence manager for high-level events (same across client and server)
#FIXME: NOT YET IMPLEMENTED
#Note: Do we even need this anymore? - Julian
#Response: I don't think so. - Jared
#===========================================
#Create and register the standard listeners
#With the event manager
#===========================================
#FIXME: Not yet fully implemented
#THIS WILL BE CHANGED LATER TO ACCOUNT FOR LOADING, ETC.
# World w is set to the activeWorld of the universe
universe = Universe(eventManager)
ui = UserInterface(eventManager,universe.activeWorld)
gameWindow = Window(eventManager,width=1024,height=768)
w = World()
universe.changeWorld(w)
#===========================================
# Initialize 500 entities in World w
for i in range(100):
#w.addEntity(Entity('ball.png',i*50,i*50, w, (255,255,255)))
#w.addEntity(TestEntity('testBuilding.png', i*50, i*50, w, 'alpha'))
w.addEntity(TestEntity('testCraft.png',i*50,i*50,w,'alpha'))
eventManager.post(Event.WorldManipulationEvent())
#Notify the manager that the window should start to accept input:
eventManager.post(Event.StartEvent())
return eventManager.eventTypesToListeners
示例3: init
def init(host='localhost',server=None):
"""
Most of this code is copied from init() function in client.py
Game initialization function.
1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and
stores references to them in an instance of L{EventManager}.
2. Several listeners are started and registered with eventManager:
- Instance of L{Universe} (universe)
- Instance of L{UserInterface} (ui)
- Instance of L{Window} (gameWindow)
3. We send the eventManager a message to start the game
- This message is interpreted by the gameWindow
"""
#Creates a Debugger that posts events to the terminal for debugging purposes
debugger = Debugger()
eventTimer = EventTimer()
#Create the event manager for low-level events
eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
Entity.manager = eventManager
# World w is set to the activeWorld of the universe
universe = Universe(eventManager)
ui = UserInterface(eventManager,universe.activeWorld,'BROADCASTSERVER')
gameWindow = Window(eventManager,width=1024,height=768)
gameWindow.fullscreenMode = False
gameWindow.updateScreenMode()
w = World(universe)
s.world=w
networked = True
client = GameClient(eventManager,host=s.host,port=1567)
#wait until the client is assigned an ID before proceeding
while client.ID == None:
import time
time.sleep(.02)
print 'Got an ID',client.ID
clientID = client.ID
ui.setClientID(clientID)
wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)
#generate the resources in the server, the existance of these
#resources will propogate through to every client when they connect
w._generateResources()
#Notify the manager that the window should start to accept input:
eventManager.post(Event.StartEvent())
return eventManager.eventTypesToListeners
示例4: selectOptions
class Inventory:
option = 0
def selectOptions(self):
print("press 1 to purchase:")
print("press 2 to return:")
print("press 3 to display Inventory:")
return int(raw_input())
def __init__(self):
self.manager = Manager()
self.cashier = Cashier()
flag = True
while flag:
self.option = self.selectOptions()
if self.option == 1:
self.client_id = random.randint(1, 1000)
self.manager.itemList()
orderDetails = self.manager.takeOrder(self.client_id)
if orderDetails[0] == "checkout":
self.cashier.checkout(orderDetails[1])
self.manager.displayInventory()
elif orderDetails[0] == "don't checkout":
print("we have ordered the requested items right away! please wait for us to get back to you.")
elif self.option ==2:
self.manager.close()
self.cashier.close()
flag = False
sys.exit(0)
elif self.option == 3:
self.manager.displayInventory()
示例5: main
def main():
if len(sys.argv) == 2:
c = Config(sys.argv[1])
else:
print("Usage : ./main.py [config_file]")
m = Manager(c.stock, c.process)
m.linkStock()
print("")
m.displayStock()
示例6: __init_attributes
def __init_attributes(self, editor):
self.__editor = editor
from Manager import Manager
self.__manager = Manager(editor)
name, shortcut, description, category = (
"open-recent-files",
"<ctrl><alt>r",
_("Open recent files"),
_("File Operations")
)
self.__trigger = self.create_trigger(name, shortcut, description, category)
self.__trigger.command = "activate"
name, shortcut, description, category = (
"reopen-closed-file",
"<ctrl><shift>w",
_("Reopen last closed file"),
_("File Operations")
)
self.__trigger1 = self.create_trigger(name, shortcut, description, category)
self.__trigger1.command = "open-last-file"
name, shortcut, description, category = (
"reopen-closed-files",
"<ctrl><shift>q",
_("Reopen last closed file"),
_("File Operations")
)
self.__trigger2 = self.create_trigger(name, shortcut, description, category)
self.__trigger2.command = "open-last-files"
return
示例7: Trigger
class Trigger(SignalManager, TriggerManager):
def __init__(self, editor):
SignalManager.__init__(self)
TriggerManager.__init__(self, editor)
self.__init_attributes(editor)
self.connect(self.__trigger, "activate", self.__activate_cb)
def __init_attributes(self, editor):
self.__editor = editor
self.__manager = None
name, shortcut, description, category = (
"toggle-comments",
"<alt>c",
_("Toggle comments"),
_("Line Operations")
)
self.__trigger = self.create_trigger(name, shortcut, description, category)
return
def __get_manager(self):
if self.__manager: return self.__manager
from Manager import Manager
self.__manager = Manager(self.__editor)
return self.__manager
def __activate(self):
if self.__editor.readonly: return False
self.__get_manager().activate()
return False
def __activate_cb(self, *args):
from gobject import idle_add
idle_add(self.__activate)
return False
def __destroy(self):
self.disconnect()
self.remove_triggers()
if self.__manager: self.__manager.destroy()
del self
return False
def destroy(self):
from gobject import idle_add
idle_add(self.__destroy)
return False
示例8: __activate
def __activate(self):
try:
self.__manager.activate()
except AttributeError:
from Manager import Manager
self.__manager = Manager(self.__editor)
self.__manager.activate()
return False
示例9: __activate_cb
def __activate_cb(self, *args):
try:
self.__manager.match()
except AttributeError:
from Manager import Manager
self.__manager = Manager(self.__editor)
self.__manager.match()
return False
示例10: __show_window_cb
def __show_window_cb(self, *args):
try:
self.__manager.show()
except AttributeError:
from Manager import Manager
self.__manager = Manager(self.__editor)
self.__manager.show()
return
示例11: installStandardDAR
def installStandardDAR(darfile, installDir):
"""
_installStandardDAR_
Installation of a standard DARball
"""
config = {
"dar_shared_pool" : os.getcwd(),
"dar_dist_pool" : os.getcwd(),
"dar_inst_pool" : os.getcwd(),
"dar_tmp_dir" : os.getcwd(),
}
darConf = []
darConf.append("use dar file %s\n" % darfile)
manager = Manager( darConf, cnf=config, pltf=Platform() )
manager.installApplication( installDir, None )
return installDir
示例12: create_configure_dialog
def create_configure_dialog(self):
if not self.dlg:
self.dlg = Manager(self.plugin_info.get_data_dir())
else:
self.dlg.run()
window = Pluma.App.get_default().get_active_window()
if window:
self.dlg.dlg.set_transient_for(window)
return self.dlg.dlg
示例13: create_configure_dialog
def create_configure_dialog(self):
if not self.dlg:
self.dlg = Manager(self.get_data_dir())
else:
self.dlg.run()
window = gedit.app_get_default().get_active_window()
if window:
self.dlg.dlg.set_transient_for(window)
return self.dlg.dlg
示例14: Trigger
class Trigger(SignalManager, TriggerManager):
def __init__(self, editor):
SignalManager.__init__(self)
TriggerManager.__init__(self, editor)
self.__init_attributes(editor)
self.connect(self.__trigger, "activate", self.__activate_cb)
def __init_attributes(self, editor):
self.__editor = editor
name, shortcut, description, category = (
"activate-foo-power",
"<ctrl><alt>f",
_("Activate the holy power of foo"),
_("Example")
)
self.__trigger = self.create_trigger(name, shortcut, description, category)
self.__manager = None
return
def destroy(self):
self.disconnect()
self.remove_triggers()
if self.__manager: self.__manager.destroy()
del self
return False
def __activate(self):
try:
self.__manager.activate()
except AttributeError:
from Manager import Manager
self.__manager = Manager(self.__editor)
self.__manager.activate()
return False
def __activate_cb(self, *args):
from gobject import idle_add
idle_add(self.__activate)
return False