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


Python FigureCanvasGTK.set_size_request方法代码示例

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


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

示例1: JwsFileChooserDialog

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import set_size_request [as 别名]
class JwsFileChooserDialog(gtk.FileChooserDialog):
    def __init__(self, parent, current_folder=None, title=_("Open spectra...")):
        gtk.FileChooserDialog.__init__(
            self,
            title=title,
            parent=parent,
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_ADD, gtk.RESPONSE_OK),
        )
        self.figure = Figure(figsize=(5, 4))
        self.canvas = FigureCanvas(self.figure)
        self.canvas.set_size_request(200, 200)  # tamaño mínimo del widget
        self.add_filter(ff_jws)
        self.set_select_multiple(True)
        if current_folder:
            self.set_current_folder(current_folder)
        self.set_preview_widget(self.canvas)
        self.connect("selection-changed", self._update_preview_cb)
        self.show_all()

    def _update_preview_cb(self, widget):
        input_fn = self.get_preview_filename()
        error = True
        if input_fn is not None:
            results = jwslib.read_file(input_fn)
            if results[0] == jwslib.JWS_ERROR_SUCCESS:
                header = results[1]
                channels = results[2]
                if len(channels) > 0:
                    error = False
            if not error:
                xdata = arange(
                    header.x_for_first_point,  # start
                    header.x_for_last_point + header.x_increment,  # end+incr.
                    header.x_increment,
                )  # increment
                ellipticity = array(channels[0], float32)
                self.figure.clear()
                p = self.figure.add_subplot(111)
                p.plot(xdata, ellipticity)
                self.canvas.draw()
        self.set_preview_widget_active(not error)
开发者ID:vhernandez,项目名称:jwsProcessor,代码行数:44,代码来源:jws_filechooser.py

示例2: __init__

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import set_size_request [as 别名]
class mainGUI:
    #====================
    #constructor
    #====================
    def __init__(self):
        # Create main window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Dan's crazy gene regulation simulator")
        self.window.set_border_width(2)
        self.window.connect("delete_event",self.close)
        
        #window size values
        self.x_size = 640
        self.y_size = 480
        self.design_Window_Fraction_x = 1.0
        self.design_Window_Fraction_y = 0.5
        self.button_Window_Fraction_x = 0.1
        self.button_Window_Fraction_y = 0.5
        self.plot_Window_Fraction_x = 0.9
        self.plot_Window_Fraction_y = 0.5

                
        #divide up the window
        self.main_Box = gtk.VBox(False,0)
        self.window.add(self.main_Box)

        #Setup circuit design area
        self.setup_Design_Area(self.main_Box)
        
        self.sub_Box = gtk.HBox(False,0)
        self.main_Box.pack_start(self.sub_Box,True,True,0)
        #Setup buttons
        self.setup_Buttons(self.sub_Box)
        self.setup_Plots(self.sub_Box)
       
        self.sub_Box.show_all()
        self.main_Box.show_all()
        self.window.show_all()


    #====================
    #Init helpers
    #====================
    def setup_Design_Area(self,box):
        self.design_Area = gtk.Fixed()
        self.design_Area.set_size_request(int(self.design_Window_Fraction_x*self.x_size),
                                          int(self.design_Window_Fraction_y*self.y_size))


        self.design_Area.set_has_window(True)
        box.pack_start(self.design_Area,True,True,0)
        self.design_Area.show()
        self.gene_Collection = Gene_Collection(self.design_Area)
        self.design_Area.connect("button-press-event",self.create_Object,"")
        
    def setup_Buttons(self,box):
        self.button_Box = gtk.VBox(False,0)

        self.button_Clear = gtk.Button("Clear")
        self.button_Clear.connect("clicked",self.clear,"")
        self.button_Clear.show()
        self.button_Box.pack_start(self.button_Clear,True,True,0)


        self.button_Go = gtk.Button("Go")
        self.button_Go.connect("clicked",self.runSim,"")
        self.button_Box.pack_start(self.button_Go,True,True,0)
        self.button_Go.show()

        self.button_Quit = gtk.Button("Quit")
        self.button_Quit.connect("clicked",self.close,"")
        self.button_Box.pack_start(self.button_Quit,True,True,0)
        self.button_Quit.show()
        
        self.button_Box.show()
        box.add(self.button_Box)

    def setup_Plots(self,box):
        self.plot_Figure = Figure(figsize=(5,4), dpi=72)
        self.plot = self.plot_Figure.add_subplot(111) 
        self.plot.plot(0,0,'-')
        self.plot_Canvas = FigureCanvas(self.plot_Figure)
        self.plot_Canvas.set_size_request(int(self.plot_Window_Fraction_x*self.x_size),
                                          int(self.plot_Window_Fraction_y*self.y_size))
        self.plot_Canvas.show()
        box.add(self.plot_Canvas)    
        
    #====================
    #Call backs
    #====================
    def close(self, widget, event, data=None):
        gtk.main_quit()
        return False
    def clear(self, widget, event, data=None):
        print "clear"
    def runSim(self, widget, event, data=None):
        print "sim"
        if(self.gene_Collection.Build_Simulation()):
            self.gene_Collection.Run_Simulation()
        else:
#.........这里部分代码省略.........
开发者ID:dgastler,项目名称:gene-sim,代码行数:103,代码来源:GUI.py


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