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


Python control.Control类代码示例

本文整理汇总了Python中control.Control的典型用法代码示例。如果您正苦于以下问题:Python Control类的具体用法?Python Control怎么用?Python Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Anna

class Anna(sleekxmpp.ClientXMPP):
	def __init__(self):
		config = ConfigParser()
		config.read("config.ini")
		jid = config.get("general", "jid")
		resource = config.get("general", "resource")
		password = config.get("general", "password")
		self._owners = config.get("general", "owner").split(",")
		sleekxmpp.ClientXMPP.__init__(self, jid + "/" + resource, password)
		self._rooms = []
		self._control = Control(self)

		self.add_event_handler("session_start", self.handle_XMPP_connected)
		self.add_event_handler("message", self.handle_incoming_message)

		for r in config.get("general", "rooms").split(","):
			self._rooms.append(room.Room(self, config.get(r, "room"), config.get(r, "modules").split(','), config.get(r, "botname")))

	def handle_XMPP_connected(self, event):
		self.sendPresence(pstatus = "<3")
		self.getRoster()
		for room in self._rooms:
			room.connect()

	def handle_incoming_message(self, message):
		if message['type'] == 'chat':
			for room in self._rooms:
				if room.get_roomname() == message['from'].bare and message['from'].resource in room.get_roster():
					room.handle_private_message(message, message['from'])
					break
			if message['from'].bare in self._owners:
				self._control.handle_message(message, message['from'])
开发者ID:Jerk31,项目名称:pyAnna,代码行数:32,代码来源:anna.py

示例2: main

def main():
    cfg = Config()

    # PyGame init
    pygame.init()
    screen = pygame.display.set_mode(cfg.getDisplay())
    pygame.display.set_caption("Solar Mechanics")

    # Space init
    bg = Surface(cfg.getDisplay())
    bg.fill(Color(cfg.getSpaceColor()))
    # Draw fixed stars
    for i in range(cfg.getStarNumber()):
        draw.circle(bg, Color(random.sample(cfg.getStarColors(), 1)[0]),
                    (random.randrange(bg.get_width()),
                     random.randrange(bg.get_height())),
                    0)

    # Timer init
    timer = pygame.time.Clock()

    control = Control(timer, screen, bg, cfg)
    control.run()

    # Farewell
    print(":-)")
开发者ID:balzat,项目名称:spacesim,代码行数:26,代码来源:main.py

示例3: fogging

 def fogging(self,Indoor,Parameter,Control):
     if Indoor.get_temperature()>Parameter.temperature_to_open_fogging+1:
         Control.set_fogging("on")
        # if Control.get_thermal_screen()=="on"
         #    Control.set_thermal_screen("off")
     elif Indoor.get_temperature()<Parameter.temperature_to_open_fogging-1:
         Control.set_fogging("off")
开发者ID:tj621,项目名称:shen.tao,代码行数:7,代码来源:test02.py

示例4: __init__

 def __init__(self, parent, **kwargs):
     Control.__init__(self, Label(master=parent._frame), **kwargs)
     # Tk does not have a truly dedicated "Image" object
     # unless you install PIL
     self._picture = Picture(self._ctrl)
     if kwargs.get('file'):
         self._picture.open_file(kwargs['file'])
开发者ID:todd-x86,项目名称:tkplus,代码行数:7,代码来源:image.py

示例5: __init__

 def __init__(self, parent, **kwargs):
     Control.__init__(self, TkScale(parent._frame), **kwargs)
     self.min = 0
     self.max = 100
     self.value = 0
     self.ticks = 0
     self.show_label = False
     self.orientation = HORIZONTAL
开发者ID:todd-x86,项目名称:tkplus,代码行数:8,代码来源:slider.py

示例6: api_control_power

def api_control_power():
	action = request.args.get('action')
	control = Control(config['control'])
	if action == 'halt':
		control.halt()
	elif action == 'reboot':
		control.reboot()
	return json.dumps('OK')
开发者ID:oliverkurth,项目名称:pypiwifi,代码行数:8,代码来源:main.py

示例7: __init__

    def __init__(self, **kwargs): 

        Control.__init__(self, **kwargs)

        self.target = None

        # generalized coordinates
        self.target_gain = 2*np.pi
        self.target_bias = -np.pi
开发者ID:ptee,项目名称:blog,代码行数:9,代码来源:control_GC.py

示例8: __init__

    def __init__(self, null_control=False, **kwargs): 
        """
        null_control boolean: 
        """

        Control.__init__(self, **kwargs)

        self.DOF = 2
        self.null_control = null_control
开发者ID:ptee,项目名称:blog,代码行数:9,代码来源:control_OSC.py

示例9: __init__

    def __init__(self, parent, **kwargs):
        Control.__init__(self, TkProgressBar(), **kwargs)

        self._min = 0
        self._max = 0
        self._value = 0
        
        self.max = 100
        self.min = 0
        self.value = 50
开发者ID:todd-x86,项目名称:tkplus,代码行数:10,代码来源:progressbar.py

示例10: main

def main():
	global users
	users = dict()

	t = Control()
	t.start()

	reactor.listenTCP(PORT, ServerFactory())
	log("Server started, port {0}\n".format(PORT))
	reactor.run()
开发者ID:0x6C77,项目名称:mapwars-server,代码行数:10,代码来源:server.py

示例11: __init__

 def __init__(self, config):
     self.config = config
     self.game = Game()
     self.queue = Queue.Queue(0)
     pp("Initiating Irc Thread")
     self.c1 = Control(1, "Controller-1", self.config, self.queue, Irc.from_config(self.config, self.queue).start)
     self.c1.daemon = True
     self.c1.start()
     pp("Initiating Tornado Thread")
     self.c2 = Control(2, "Controller-2", self.config, self.queue, web.run)
     self.c2.daemon = True
     self.c2.start()
开发者ID:LucentW,项目名称:twitch-plays,代码行数:12,代码来源:bot.py

示例12: event_switch_to_list_view

 def event_switch_to_list_view(self, widget, event, data=None):
   TixMode.current = TixMode.LIST
   self.status_bar.update("- Search: %s" % Control.get_last_regex() if Control.get_last_regex() else "")
   if Control.reload_notes:
     self.stored_items.load(self.notes_root, self.recursive)
     self.create_list()
     Control.reload_notes = False
   self.vbox.remove(self.editor.get_parent())
   self.vbox.pack_start(self.commandline, False, False, 0)
   self.vbox.add(self.tree_view.get_parent())
   self.tree_view.grab_focus()
   self.main_window.show_all()
开发者ID:siadat,项目名称:tix,代码行数:12,代码来源:gtk_main.py

示例13: __init__

class Handler:
    """This class represents a rectangular control points handler"""

    def __init__(self):
        self.control = list()
        self.can_pivot = True
        self.center_pivot = False
        self.pivot = Control()
        self.pivot.pivot = True

        self.line = False

        self.is_testing = False

        index = 0
        while index < ANONIMOUS:
            control = Control()
            self.control.append(control)
            index += 1

    def draw_handler(self, context):
        if not self.line:
            context.set_antialias(cairo.ANTIALIAS_NONE)
            context.set_line_width(1.0 / context.get_matrix()[0])
            context.set_source_rgb(0.5, 0.5, 1.0)
            dash = []
            context.set_dash(dash)
            context.rectangle(self.x, self.y, self.width, self.height)
            context.stroke()
            context.set_antialias(cairo.ANTIALIAS_DEFAULT)

    def draw_controls(self, context):
        for control in self.control:
            control.draw(context)

    def draw_pivot(self, context):
        self.pivot.draw(context)

    def draw(self, context):
        self.draw_handler(context)
        self.draw_controls(context)
        if self.can_pivot:
            self.draw_pivot(context)

    def at_position(self, x, y):
        return self.get_direction(x, y) is not NONE

    def get_direction(self, x, y):
        for direction, control in enumerate(self.control):
            if control.at_position(x, y):
                return direction
        return NONE
开发者ID:Happy-Ferret,项目名称:sanaviron,代码行数:52,代码来源:handler.py

示例14: main

def main():
    print sys.argv
    arg = sys.argv[1]
    command = Command()
    command.room='living'
    command.action='power'
    command.value='on'
    if arg == '1':
    	command.value = 'on'
    elif arg == '2':
    	command.value = 'off'
    control = Control()
    control.execute_command(command)
开发者ID:AnanthaRajuC,项目名称:homecontrol,代码行数:13,代码来源:remote.py

示例15: datagramReceived

    def datagramReceived(self, data, addr):
        """Event handler of receiving a UDP request.
        Verify the identity of the client and assign a Control
        to it if it is trusted.
        """
        logging.debug("received DNS request from %s:%d" % (addr[0], addr[1]))

        if not self.transmit:
            try:
                dnsq = dnslib.DNSRecord.parse(data)
                query_data = str(dnsq.q.qname).split('.')
                # Give a NXDOMAIN response
                self.answer(dnsq, addr)
            except KeyError:
                logging.info("Corrupt request")

        try:
            # One control corresponds to one client (with a unique SHA1)

            # TODO: get obfs level from query length

            if self.transmit:
                main_pw, client_sha1, number, tcp_port, remote_ip, certs_str, signature = \
                    self.parse_udp_msg_transmit(data)
            else:
                main_pw, client_sha1, number, tcp_port, remote_ip, certs_str, signature = \
                    self.parse_udp_msg(*query_data[:6])
            if (client_sha1 + main_pw) not in self.controls:
                cert = self.certs_db.query(client_sha1)
                control = Control(self, signature, client_sha1, cert[0], cert[1],
                                  remote_ip, tcp_port,
                                  main_pw, number, certs_str)
                self.controls[client_sha1 + main_pw] = control
            else:
                control = self.controls[client_sha1 + main_pw]
                control.update(remote_ip, tcp_port, number)

            control.connect()

        except CorruptedReq:
            logging.debug("corrupt request")
        except KeyError:
            logging.warning("untrusted client attempting to connect")
        except AssertionError:
            logging.debug("authentication failed or corrupt request")
        except BlacklistReq:
            logging.debug("request or salt on blacklist")
        except IllegalReq:
            logging.debug("request for too many connections")
开发者ID:projectarkc,项目名称:arkc-server,代码行数:49,代码来源:coordinator.py


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