2015-04-02 90 views

回答

1

可以使用GtkFixed容器:

的GtkFixed窗口小部件是可以在固定位置和固定的尺寸,以像素为单位给出放置子控件的容器。


而且因为你没有提到的语言,这里是在Python的例子:

from gi.repository import Gtk 
import sys 

class MainWindow(Gtk.ApplicationWindow): 

    def __init__(self, app): 
     Gtk.Window.__init__(self, title="GtkFixed", application=app) 
     # Set the window size 
     self.set_size_request(200, 200) 

     # Add GtkFixed to the main window 
     container = Gtk.Fixed() 
     self.add(container) 

     button = Gtk.Button("Test Button") 
     # Add the button in the (x=20,y=100) position 
     container.put(button, 20, 100) 


class Application(Gtk.Application): 

    def __init__(self): 
     Gtk.Application.__init__(self) 

    def do_activate(self): 
     self.mainWindow = MainWindow(self) 
     self.mainWindow.show_all() 

    def do_startup(self): 
     Gtk.Application.do_startup(self) 


application = Application() 

exitStatus = application.run(sys.argv) 
sys.exit(exitStatus) 

(不幸的是我不能发布结果图像)