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


Python gtk.main方法代码示例

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


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

示例1: idlethread

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def idlethread(func):
    '''
    A decorator which causes the function to be called by the gtk
    main iteration loop rather than synchronously...

    NOTE: This makes the call async handled by the gtk main
    loop code.  you can NOT return anything.
    '''
    def dowork(arginfo):
        args,kwargs = arginfo
        return func(*args, **kwargs)

    def idleadd(*args, **kwargs):
        if currentThread().getName() == 'GtkThread':
            return func(*args, **kwargs)
        gtk.gdk.threads_enter()
        gobject.idle_add(dowork, (args,kwargs))
        gtk.gdk.threads_leave()

    return idleadd 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:22,代码来源:main.py

示例2: run

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def run(self, graphic):
        window = gtk.Window()
        self.__window = window
        window.set_default_size(200, 200)
        vbox = gtk.VBox()
        window.add(vbox)
        render = GtkGraphicRenderer(graphic)
        self.__render = render
        vbox.pack_end(render, True, True, 0)
        hbox = gtk.HBox()
        vbox.pack_start(hbox, False, False, 0)
        smaller_zoom = gtk.Button("Zoom Out")
        smaller_zoom.connect("clicked", self.__set_smaller_cb)
        hbox.pack_start(smaller_zoom)
        bigger_zoom = gtk.Button("Zoom In")
        bigger_zoom.connect("clicked", self.__set_bigger_cb)
        hbox.pack_start(bigger_zoom)
        output_png = gtk.Button("Output Png")
        output_png.connect("clicked", self.__output_png_cb)
        hbox.pack_start(output_png)
        window.connect('destroy', gtk.main_quit)
        window.show_all()
        #gtk.bindings_activate(gtk.main_quit, 'q', 0)
        gtk.main() 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:26,代码来源:grid.py

示例3: main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def main():
    (colors, timelines) = read_data(sys.argv[1])
    (lower_bound, upper_bound) = timelines.get_bounds()
    graphic = GraphicRenderer(lower_bound, upper_bound)
    top_legend = TopLegendRenderer()
    range_values = timelines.get_all_range_values()
    range_colors = []
    for range_value in range_values:
        range_colors.append(colors.lookup(range_value))
    top_legend.set_legends(range_values, 
                           range_colors)
    graphic.set_top_legend(top_legend)
    data = TimelinesRenderer()
    data.set_timelines(timelines, colors)
    graphic.set_data(data)

    # default range
    range_mid = (upper_bound - lower_bound) / 2
    range_width = (upper_bound - lower_bound) / 10
    range_lo = range_mid - range_width / 2
    range_hi = range_mid + range_width / 2
    graphic.set_range(range_lo, range_hi)

    main_window = MainWindow()
    main_window.run(graphic) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:27,代码来源:grid.py

示例4: _hijack_gtk

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def _hijack_gtk(self):
        """Hijack a few key functions in GTK for IPython integration.

        Modifies pyGTK's main and main_quit with a dummy so user code does not
        block IPython.  This allows us to use %run to run arbitrary pygtk
        scripts from a long-lived IPython session, and when they attempt to
        start or stop

        Returns
        -------
        The original functions that have been hijacked:
        - gtk.main
        - gtk.main_quit
        """
        def dummy(*args, **kw):
            pass
        # save and trap main and main_quit from gtk
        orig_main, gtk.main = gtk.main, dummy
        orig_main_quit, gtk.main_quit = gtk.main_quit, dummy
        return orig_main, orig_main_quit 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:gtkembed.py

示例5: send_keys

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def send_keys(self,modifier_byte,keys):

        cmd_str=""
        cmd_str+=chr(0xA1)
        cmd_str+=chr(0x01)
        cmd_str+=chr(modifier_byte)
        cmd_str+=chr(0x00)

        count=0
        for key_code in keys:
            if(count<6):
                cmd_str+=chr(key_code)
            count+=1

        self.device.send_string(cmd_str);		


#main routine 
开发者ID:yaptb,项目名称:BlogCode,代码行数:20,代码来源:btk_server.py

示例6: main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def main():

  import gtk

  from differentialMesh import DifferentialMesh
  from iutils.render import Animate

  DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS)

  DM.new_faces_in_ngon(MID,MID, H, 6, 0.0)

  def wrap(render):

    res = steps(DM)
    show(render, DM)

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)
  # render.get_colors_from_file('../colors/red_earth.gif')
  render.set_line_width(LINEWIDTH)

  gtk.main() 
开发者ID:inconvergent,项目名称:differential-mesh,代码行数:25,代码来源:main_ani_new.py

示例7: main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def main(args):
    import optparse
    usage = """usage: %%prog [Options]\n\n%s""" % __doc__.strip()
    parser = optparse.OptionParser(usage)
    parser.add_option('-t', '--test', dest='test', action="store_true", 
                      default=False, help="Run in test mode (show webview)")
    options, args0 = parser.parse_args(args)    
    url, = args0
    resource_regexp = first(pattern for (urlre, pattern) in SITES.iteritems() 
                       if re.search(urlre, url))    
    if not resource_regexp and not options.test:
        debug("No module found for URL: %s" % url)
        return 1
    window, webview = create_webview()
    skip_regexp = re.compile(r"\.(jpg|png|gif|css)(\?|$)", re.I)
    webview.connect("resource-request-starting", on_request, resource_regexp, skip_regexp)
    webview.load_uri(url)    
    if options.test:
        window.resize(640, 480)
        window.show_all()        
    gtk.main() 
开发者ID:ActiveState,项目名称:code,代码行数:23,代码来源:recipe-577167.py

示例8: Main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def Main():
    
    train=False
    print 'training started'
    
    if train:
        v=Video()
        n=NormalizedRGB()
        for i in range(100):
            frm=v.outFrame()
            n.getRGB(frm)
            norm=n.normalized()
            plain=v.imagePlanes(norm)
        
            sample_bg(plain[1])
        print 'training ends...'
        del v
    
    
    m=MainUI()
    gtk.main() 
开发者ID:akash0x53,项目名称:virtual-dressing-room,代码行数:23,代码来源:main.py

示例9: inputhook

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def inputhook(context):
    """
    When the eventloop of prompt-toolkit is idle, call this inputhook.

    This will run the GTK main loop until the file descriptor
    `context.fileno()` becomes ready.

    :param context: An `InputHookContext` instance.
    """

    def _main_quit(*a, **kw):
        gtk.main_quit()
        return False

    gobject.io_add_watch(context.fileno(), gobject.IO_IN, _main_quit)
    gtk.main() 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:18,代码来源:inputhook.py

示例10: main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def main():
    # Create user interface.
    hello_world_window()

    # Enable threading in GTK. (Otherwise, GTK will keep the GIL.)
    gtk.gdk.threads_init()

    # Read input from the command line, using an event loop with this hook.
    # We use `patch_stdout`, because clicking the button will print something;
    # and that should print nicely 'above' the input line.
    with patch_stdout():
        session = PromptSession(
            "Python >>> ", inputhook=inputhook, lexer=PygmentsLexer(PythonLexer)
        )
        result = session.prompt()
    print("You said: %s" % result) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:18,代码来源:inputhook.py

示例11: main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def main():
    currentThread().setName('GtkThread')
    gtk.gdk.threads_enter()
    gtk.main()
    gtk.gdk.threads_leave() 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:7,代码来源:main.py

示例12: main

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def main(self):
		"""Enters the main loop."""
		gtk.main() 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:5,代码来源:tintwizard.py

示例13: run

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def run(self):
        while not self.quit:
            #print "sim: Wait for go"
            self.go.wait() # wait until the main (view) thread gives us the go signal
            self.go.clear()
            if self.quit:
                break
            #self.go.clear()
            #print "sim: Acquire lock"
            self.lock.acquire()
            try:
                if 0:
                    if ns3.core.Simulator.IsFinished():
                        self.viz.play_button.set_sensitive(False)
                        break
                #print "sim: Current time is %f; Run until: %f" % (ns3.Simulator.Now ().GetSeconds (), self.target_time)
                #if ns3.Simulator.Now ().GetSeconds () > self.target_time:
                #    print "skipping, model is ahead of view!"
                self.sim_helper.SimulatorRunUntil(ns.core.Seconds(self.target_time))
                #print "sim: Run until ended at current time: ", ns3.Simulator.Now ().GetSeconds ()
                self.pause_messages.extend(self.sim_helper.GetPauseMessages())
                gobject.idle_add(self.viz.update_model, priority=PRIORITY_UPDATE_MODEL)
                #print "sim: Run until: ", self.target_time, ": finished."
            finally:
                self.lock.release()
            #print "sim: Release lock, loop."

# enumeration 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:30,代码来源:core.py

示例14: start

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def start(self):
        self.scan_topology()
        self.window.connect("delete-event", self._quit)
        #self._start_update_timer()
        gobject.timeout_add(200, self.autoscale_view)
        self.simulation.start()

        try:
            __IPYTHON__
        except NameError:
            pass
        else:
            self._monkey_patch_ipython()

        gtk.main() 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:17,代码来源:core.py

示例15: start

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main [as 别名]
def start(self):
        """Starts the GTK main event loop and sets our kernel startup routine.
        """
        # Register our function to initiate the kernel and start gtk
        gobject.idle_add(self._wire_kernel)
        gtk.main() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:gtkembed.py


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