def __init__(self): self.readlog = None self.keyList = None window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_resizable(True) window.set_size_request(1000, 800) window.connect("destroy", self.close_application) window.set_title("TextView Widget Basic Example") window.set_border_width(0) box1 = gtk.VBox(False, 0) window.add(box1) box1.show() box2 = gtk.VBox(False, 10) box2.set_border_width(10) box1.pack_start(box2, True, True, 0) box2.show() sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) textview = gtk.TextView() self.textbuffer = textview.get_buffer() sw.add(textview) sw.show() textview.show() box2.pack_start(sw) #--- changes hbox = gtk.HButtonBox() box2.pack_start(hbox, False, False, 0) hbox.show() vbox = gtk.VBox() vbox.show() hbox.pack_start(vbox, False, False, 0) # check button to toggle editable mode check = gtk.CheckButton("Editable") vbox.pack_start(check, False, False, 0) check.connect("toggled", self.toggle_editable, textview) check.set_active(True) check.show() # check button to toggle cursor visiblity check = gtk.CheckButton("Cursor Visible") vbox.pack_start(check, False, False, 0) check.connect("toggled", self.toggle_cursor_visible, textview) check.set_active(True) check.show() # check button to toggle left margin check = gtk.CheckButton("Left Margin") vbox.pack_start(check, False, False, 0) check.connect("toggled", self.toggle_left_margin, textview) check.set_active(False) check.show() # check button to toggle right margin check = gtk.CheckButton("Right Margin") vbox.pack_start(check, False, False, 0) check.connect("toggled", self.toggle_right_margin, textview) check.set_active(False) check.show() # radio buttons to specify wrap mode vbox = gtk.VBox() vbox.show() hbox.pack_start(vbox, False, False, 0) radio = gtk.RadioButton(None, "WRAP__NONE") vbox.pack_start(radio, False, True, 0) radio.connect("toggled", self.new_wrap_mode, textview, gtk.WRAP_NONE) radio.set_active(True) radio.show() radio = gtk.RadioButton(radio, "WRAP__CHAR") vbox.pack_start(radio, False, True, 0) radio.connect("toggled", self.new_wrap_mode, textview, gtk.WRAP_CHAR) radio.show() radio = gtk.RadioButton(radio, "WRAP__WORD") vbox.pack_start(radio, False, True, 0) radio.connect("toggled", self.new_wrap_mode, textview, gtk.WRAP_WORD) radio.show() # radio buttons to specify justification vbox = gtk.VBox() vbox.show() hbox.pack_start(vbox, False, False, 0) radio = gtk.RadioButton(None, "JUSTIFY__LEFT") vbox.pack_start(radio, False, True, 0) radio.connect("toggled", self.new_justification, textview, gtk.JUSTIFY_LEFT) radio.set_active(True) radio.show() radio = gtk.RadioButton(radio, "JUSTIFY__RIGHT") vbox.pack_start(radio, False, True, 0) radio.connect("toggled", self.new_justification, textview, gtk.JUSTIFY_RIGHT) radio.show() radio = gtk.RadioButton(radio, "JUSTIFY__CENTER") vbox.pack_start(radio, False, True, 0) radio.connect("toggled", self.new_justification, textview, gtk.JUSTIFY_CENTER) radio.show() separator = gtk.HSeparator() box1.pack_start(separator, False, True, 0) separator.show() box2 = gtk.VBox(False, 10) box2.set_border_width(10) box1.pack_start(box2, False, True, 0) box2.show() button = gtk.Button("close") button.connect("clicked", self.close_application) box2.pack_start(button, True, True, 0) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.show() window.show() #---------- Logic Buttons --------- #-- label = gtk.Label("Log Path to Process") label.set_alignment(0, 0) vbox.pack_start(label, True, True, 0) label.show() self.entry = gtk.Entry() self.entry.set_max_length(100) self.entry.connect("activate", self.enter_callback, self.entry) self.entry.set_text( "/var/opt/ORCLemaas/var_opt_ORCLemaas/logs/loganalytics/library/libraryLog.log" ) self.entry.insert_text("", len(self.entry.get_text())) self.entry.select_region(0, len(self.entry.get_text())) vbox.pack_start(self.entry, True, True, 0) self.entry.show() buttonlog = gtk.Button("Process log") buttonlog.connect("clicked", self.process_log, None) vbox.pack_start(buttonlog, True, True, 0) #buttonlog.set_flags(gtk.CAN_DEFAULT) #buttonlog.grab_default() buttonlog.show() buttonlog.show() buttonlogv = gtk.Button("View log") buttonlogv.connect("clicked", self.view_log, None) vbox.pack_start(buttonlogv, True, True, 0) #buttonlogv.set_flags(gtk.CAN_DEFAULT) #buttonlogv.grab_default() buttonlogv.show() buttonlogv.show() #-- label = gtk.Label("Type of Category") label.set_alignment(0, 0) vbox.pack_start(label, True, True, 0) label.show() self.event_type_txt = gtk.Entry() self.event_type_txt.set_max_length(100) self.event_type_txt.connect("activate", self.enter_callback) self.event_type_txt.set_text("2") self.event_type_txt.insert_text("", len(self.event_type_txt.get_text())) self.event_type_txt.select_region(0, len(self.event_type_txt.get_text())) vbox.pack_start(self.event_type_txt, True, True, 0) self.event_type_txt.show() #-- label = gtk.Label("Number of Lines") label.set_alignment(0, 0) vbox.pack_start(label, True, True, 0) label.show() self.num_rows_txt = gtk.Entry() self.num_rows_txt.set_max_length(100) self.num_rows_txt.connect("activate", self.enter_callback) self.num_rows_txt.set_text("4") self.num_rows_txt.insert_text("", len(self.num_rows_txt.get_text())) self.num_rows_txt.select_region(0, len(self.num_rows_txt.get_text())) vbox.pack_start(self.num_rows_txt, True, True, 0) self.num_rows_txt.show() button = gtk.Button("See latest event") button.connect("clicked", self.see_latest_event, None) vbox.pack_start(button, True, True, 0) #button.set_flags(gtk.CAN_DEFAULT) #button.grab_default() button.show() window.show() button2 = gtk.Button("See event one by one") button2.connect("clicked", self.see_event_onebyone, None) vbox.pack_start(button2, True, True, 0) #button2.set_flags(gtk.CAN_DEFAULT) #button2.grab_default() button2.show() window.show() # Load the file into the text window #infile = open("textview-basic.py", "r") infile = open(self.entry.get_text(), "r") if infile: string = infile.read() infile.close() self.textbuffer.set_text(string)
def __init__(self): #open the dictionary file file = open("pickledatabase.dat", "r") self.mldict = pickle.load(file) file.close() self.window = gtk.Window() menubar = gtk.MenuBar() menu_file = gtk.Menu() menu_help = gtk.Menu() item_file = gtk.MenuItem("File") item_help = gtk.MenuItem("Help") item_quit = gtk.MenuItem("Quit") item_about = gtk.MenuItem("About") menu_file.append(item_quit) menu_help.append(item_about) item_file.set_submenu(menu_file) item_help.set_submenu(menu_help) menubar.append(item_file) menubar.append(item_help) button = gtk.Button("Look Up") self.buffer = gtk.TextBuffer() self.entry = gtk.Entry() liststore = gtk.ListStore(str) textview = gtk.TextView(self.buffer) completion = gtk.EntryCompletion() self.entry.set_completion(completion) completion.set_model(liststore) completion.set_text_column(0) for item in self.mldict: liststore.append([item]) vbox = gtk.VBox(False, 3) hbox = gtk.HBox(False, 3) hbox2 = gtk.HBox(False, 3) textview.set_editable(False) hbox.pack_start(self.entry, True, True, 6) hbox.pack_start(button, False, False, 6) hbox2.pack_start(textview, True, True, 6) vbox.pack_start(menubar, False, False, 0) vbox.pack_start(hbox, False, False) vbox.pack_start(hbox2, True, True, 6) #Event Handlers button.connect("clicked", self.FindMeaning1) completion.connect("match-selected", self.FindMeaning) self.window.connect("destroy", lambda w: gtk.main_quit()) self.entry.connect("activate", self.FindMeaning1) item_quit.connect("activate", lambda w: gtk.main_quit()) item_about.connect("activate", self.ShowDialog) self.window.set_title("Dictionary") self.window.set_size_request(400, 520) self.window.add(vbox) self.window.show_all()
print "Callback", data def delete_event(widget, event, data=None): gtk.main_quit() return False h = gtk.HBox() b1 = gtk.Button("Button 1") b1.connect("clicked", callback, "1") h.add(b1) for padding in [0, 10]: for fill in [True, False]: for expand in [True, False]: name = "expand %s\nfill %s\npadding %s" % (expand, fill, padding) ab = gtk.Button(name) ab.connect("clicked", callback, name) h.pack_start(ab, expand, fill, padding) w = gtk.Window() w.connect("delete_event", delete_event) w.add(h) w.set_border_width(10) w.show_all() gtk.main()
import gtk def hello_world(widget, data=None): print("Hello World") def delete_event(widget, event, data=None): return False def destroy(widget, data=None): gtk.main_quit() window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.connect("delete_event", delete_event) window.connect("destroy", destroy) button = gtk.Button("Hello World") button.connect("clicked", hello_world, None) window.add(button) button.show() window.show() try: from IPython.lib.inputhook import enable_gui enable_gui('gtk') except ImportError: gtk.main()
def __init__(self): self.stemmer = Stemmer(sys.argv) self.word_count = 0 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect('delete_event', self.delete_event) self.window.connect('destroy', self.destroy) self.window.set_title('Tamil Stemmer GUI') self.window.set_size_request(350, 400) self.list = gtk.ListStore(int, str, str, str) self.entry = gtk.Entry() self.entry.connect('activate', self.add_new_row, self.list) self.tvcolumn1 = gtk.TreeViewColumn('No.') self.cell1 = gtk.CellRendererText() self.tvcolumn1.pack_start(self.cell1, True) self.tvcolumn1.add_attribute(self.cell1, 'text', 0) self.tvcolumn1.set_resizable(True) self.tvcolumn2 = gtk.TreeViewColumn('Word') self.cell2 = gtk.CellRendererText() self.tvcolumn2.pack_start(self.cell2, True) self.tvcolumn2.add_attribute(self.cell2, 'text', 1) self.tvcolumn2.set_min_width(175) self.tvcolumn3 = gtk.TreeViewColumn('Stemmed word') self.cell3 = gtk.CellRendererText() self.tvcolumn3.pack_start(self.cell3, True) self.tvcolumn3.add_attribute(self.cell3, 'text', 2) self.tview = gtk.TreeView(self.list) self.tview.append_column(self.tvcolumn1) self.tview.append_column(self.tvcolumn2) self.tview.append_column(self.tvcolumn3) self.tview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH) self.scrollwindow = gtk.ScrolledWindow() self.scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrollwindow.add(self.tview) self.textview = gtk.TextView() self.textbuffer = self.textview.get_buffer() self.textview.set_editable(False) self.textview.set_justification(gtk.JUSTIFY_CENTER) self.scrolledwindow2 = gtk.ScrolledWindow() self.scrolledwindow2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolledwindow2.add(self.textview) self.vbox = gtk.VBox(False, 5) self.vbox.pack_start(self.entry, expand=False, fill=False, padding=0) self.vbox.pack_start(self.scrollwindow, expand=True, fill=True, padding=0) self.vbox.pack_start(self.scrolledwindow2, expand=True, fill=True, padding=0) self.window.add(self.vbox) self.window.show_all()
def __init__(self): # Create window, set its properties and connect signals self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_title("BlenderTextGenerator") self.window.set_border_width(10) # Create a hBox which would allow parallel using of settings # and openGL view self.hBox = gtk.HBox(True, 5) self.window.add(self.hBox) # Create a vBox to hold all of the settings' controls self.vBox = gtk.VBox(True, 5) self.hBox.add(self.vBox) # Create textbox self.textEditFrame = gtk.Frame("Enter Text:") self.textEditEntry = gtk.Entry(16) self.textEditFrame.add(self.textEditEntry) # Create a font selector self.fontSelectFrame = gtk.Frame("Select Font:") self.fontSelectComboBox = gtk.combo_box_new_text() for f in FontFetcher.fetchAllFonts(): self.fontSelectComboBox.append_text(f) self.fontSelectFrame.add(self.fontSelectComboBox) # Create a hBox to hold the number settings self.numberValuesHBox = gtk.HBox(True, 5) # Create an entry for the text height setting self.textHeightFrame = gtk.Frame("Height") self.textHeightEntry = gtk.Entry(4) self.textHeightFrame.add(self.textHeightEntry) # Create an entry for the base height setting self.baseHeightFrame = gtk.Frame("Base Height") self.baseHeightEntry = gtk.Entry(4) self.baseHeightFrame.add(self.baseHeightEntry) # Create an entry for the base height setting self.paddingFrame = gtk.Frame("Padding") self.paddingEntry = gtk.Entry(4) self.paddingFrame.add(self.paddingEntry) # Add all of the number entries to the numberValuesHBox self.numberValuesHBox.pack_start(self.textHeightFrame) self.numberValuesHBox.add(self.baseHeightFrame) self.numberValuesHBox.add(self.paddingFrame) # Create a button for creating the model and connect the signal self.createButton = gtk.Button("Create") self.createButton.connect("clicked", self.createModel) # Fill the vBox with the settings self.vBox.pack_start(self.textEditFrame) self.vBox.add(self.fontSelectFrame) self.vBox.add(self.numberValuesHBox) self.vBox.add(self.createButton) # Show all elements self.hBox.show() self.vBox.show() self.textEditFrame.show() self.textEditEntry.show() # TODO: self.fontSelectFrame.show() self.fontSelectComboBox.show() self.numberValuesHBox.show() self.textHeightFrame.show() self.textHeightEntry.show() self.baseHeightFrame.show() self.baseHeightEntry.show() self.paddingFrame.show() self.paddingEntry.show() self.createButton.show() self.window.show()
def get_screen_size(): """This function finds the width and height of the screen. This will be for a single monitor in a multi-monitor set-up. Args: None Returns: A list of numbers (width-in-pixels, height-in-pixels) """ backend = plt.get_backend() if 'GTK' in backend: # Implementation by starfry at # https://stackoverflow.com/questions/3129322/how-do-i-get-monitor-resolution-in-python import gtk window = gtk.Window() # the screen contains all monitors screen = window.get_screen() # collect data about active monitor curmon = screen.get_monitor_at_window(screen.get_active_window()) dx, dy, width, height = screen.get_monitor_geometry(curmon) # get geometry of current monitor elif 'Tk' in backend: # Modified version of implementation by FogleBird at # https://stackoverflow.com/questions/8762536/how-can-i-choose-the-default-wx-display-in-wxpython import wx MyApp = wx.App(False) # the wx.App object must be created first. display = wx.Display(0) # find the size of the first display screen dx, dy, width, height = display.GetGeometry() elif 'MacOSX' in backend: # Implementation by Mike Rhodes at # https://stackoverflow.com/questions/1281397/how-to-get-the-desktop-resolution-in-mac-via-python from Quartz import CGDisplayBounds from Quartz import CGMainDisplayID from Quartz import CGDisplayScreenSize mainMonitor = CGDisplayBounds(CGMainDisplayID()) width = mainMonitor.size.width height = mainMonitor.size.height sizeInMm = CGDisplayScreenSize(CGMainDisplayID()) pixels2inches = width * 25.4 / sizeInMm.width # 25.4 mm = 1 inch elif 'WX' in backend: # Implementation by Justin at # https://stackoverflow.com/questions/3129322/how-do-i-get-monitor-resolution-in-python import ctypes user32 = ctypes.windll.user32 user32.SetProcessDPIAware() width = user32.GetSystemMetrics(0) height = user32.GetSystemMetrics(1) elif 'Qt4' in backend: # NOT TESTED YET. Implementation by Harsh Kumar Narula at # https://stackoverflow.com/questions/3129322/how-do-i-get-monitor-resolution-in-python from PyQt4 import QtGui MyApp = QtGui.QApplication(sys.argv) screen_resolution = MyApp.desktop().screenGeometry() width = screen_resolution.width() height = screen_resolution.height() elif 'Qt5' in backend: # Implementation by Harsh Kumar Narula at # https://stackoverflow.com/questions/3129322/how-do-i-get-monitor-resolution-in-python from PyQt5 import QtWidgets MyApp = QtWidgets.QApplication(sys.argv) screen_resolution = MyApp.desktop().screenGeometry() width = screen_resolution.width() height = screen_resolution.height() else: print 'Solution not implemented yet for backend =', backend width, height = (1280, 1024) return (width, height)
def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_size_request(600, 500) window.connect("delete_event", lambda *args: gtk.main_quit()) window.add(Scene()) window.show_all()
def __init__(self): gtk.Entry.__init__(self) self.news = False self.activities = None self.external_activities = [] # suggestions from outer space self.categories = None self.filter = None self.max_results = 10 # limit popup size to 10 results self.external = external.ActivitiesSource() self.popup = gtk.Window(type=gtk.WINDOW_POPUP) box = gtk.ScrolledWindow() box.set_shadow_type(gtk.SHADOW_IN) box.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.tree = gtk.TreeView() self.tree.set_headers_visible(False) self.tree.set_hover_selection(True) self.time_icon_cell = gtk.CellRendererPixbuf() self.time_icon_cell.set_property("icon-name", "appointment-new") self.time_icon_column = gtk.TreeViewColumn("", self.time_icon_cell) self.tree.append_column(self.time_icon_column) self.time_cell = gtk.CellRendererText() self.time_cell.set_property("scale", 0.8) self.time_column = gtk.TreeViewColumn("Time", self.time_cell, text=3) self.tree.append_column(self.time_column) self.activity_column = gtk.TreeViewColumn("Activity", gtk.CellRendererText(), text=1) self.activity_column.set_expand(True) self.tree.append_column(self.activity_column) self.category_cell = gtk.CellRendererText() self.category_cell.set_property('alignment', pango.ALIGN_RIGHT) self.category_cell.set_property('scale', pango.SCALE_SMALL) self.category_cell.set_property('yalign', 0.0) self.category_column = gtk.TreeViewColumn("Category", self.category_cell, text=2) self.tree.append_column(self.category_column) self.tree.connect("button-press-event", self._on_tree_button_press_event) box.add(self.tree) self.popup.add(box) self.connect("button-press-event", self._on_button_press_event) self.connect("key-press-event", self._on_key_press_event) self.connect("key-release-event", self._on_key_release_event) self.connect("focus-out-event", self._on_focus_out_event) self.connect("changed", self._on_text_changed) self._parent_click_watcher = None # bit lame but works runtime.storage.connect('activities-changed', self.after_activity_update) self.show() self.populate_suggestions()
def __init_window(self): # Start pyGTK setup self.window = gtk.Window() self.window.set_title(_("Openbox Logout")) self.window.connect("destroy", self.quit) self.window.connect("key-press-event", self.on_keypress) self.window.connect("window-state-event", self.on_window_state_change) if not self.window.is_composited(): self.logger.debug("No compositing, enabling rendered effects") # Window isn't composited, enable rendered effects self.rendered_effects = True else: # Link in Cairo rendering events self.window.connect('expose-event', self.on_expose) self.window.connect('screen-changed', self.on_screen_changed) self.on_screen_changed(self.window) self.rendered_effects = False self.window.set_size_request(620,200) self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) self.window.set_decorated(False) self.window.set_position(gtk.WIN_POS_CENTER) # Create the main panel box self.mainpanel = gtk.HBox() # Create the button box self.buttonpanel = gtk.HButtonBox() self.buttonpanel.set_spacing(10) # Pack in the button box into the panel box, with two padder boxes self.mainpanel.pack_start(gtk.VBox()) self.mainpanel.pack_start(self.buttonpanel, False, False) self.mainpanel.pack_start(gtk.VBox()) # Add the main panel to the window self.window.add(self.mainpanel) for button in self.button_list: self.__add_button(button, self.buttonpanel) if self.rendered_effects == True: self.logger.debug("Stepping though render path") w = gtk.gdk.get_default_root_window() sz = w.get_size() pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1]) pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1]) self.logger.debug("Rendering Fade") # Convert Pixbuf to PIL Image wh = (pb.get_width(),pb.get_height()) pilimg = Image.frombytes("RGB", wh, pb.get_pixels()) pilimg = pilimg.point(lambda p: (p * self.opacity) / 255 ) # "Convert" the PIL to Pixbuf via PixbufLoader buf = StringIO.StringIO() pilimg.save(buf, "ppm") del pilimg loader = gtk.gdk.PixbufLoader("pnm") loader.write(buf.getvalue()) pixbuf = loader.get_pixbuf() # Cleanup IO buf.close() loader.close() pixmap, mask = pixbuf.render_pixmap_and_mask() # width, height = pixmap.get_size() else: pixmap = None self.window.set_app_paintable(True) self.window.resize(gtk.gdk.screen_width(), gtk.gdk.screen_height()) self.window.realize() if pixmap: self.window.window.set_back_pixmap(pixmap, False) self.window.move(0,0)
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("WAVE MIXER") self.window.connect("destroy", self.destroy) self.window.set_size_request(1000, 800) self.fixed = gtk.Fixed() self.window.add(self.fixed) self.fixed.show() self.timerevlist = [] self.modlist = [] self.mixlist = [] self.playing = [-1] * 3 self.pause = [-1] * 3 self.processpid = 0 filelist = [-1] * 3 self.mixspause = -1 self.mixspid = -1 self.modspause = -1 self.modspid = -1 for i in range(3): checkbutton1 = gtk.CheckButton("Time Reversal") checkbutton2 = gtk.CheckButton("Select for Modulation") checkbutton3 = gtk.CheckButton("Select for Mix") self.fixed.put(checkbutton1, 100 + 250 * i, 330) self.fixed.put(checkbutton2, 100 + 250 * i, 360) self.fixed.put(checkbutton3, 100 + 250 * i, 390) self.timerevlist.append(checkbutton1) self.modlist.append(checkbutton2) self.mixlist.append(checkbutton3) #scale for amplitude self.amplist = [] for i in range(3): scale = gtk.HScale() scale.set_range(0, 10) scale.set_value(1) scale.set_increments(0.5, 1) scale.set_digits(1) scale.set_size_request(160, 45) self.fixed.put(scale, 100 + i * 250, 130) self.amplist.append(scale) #scale for time Shift self.timeshiftlist = [] for i in range(3): scale = gtk.HScale() scale.set_range(-30, 30) scale.set_increments(1, 1) scale.set_digits(0) scale.set_size_request(160, 45) self.fixed.put(scale, 100 + i * 250, 200) self.timeshiftlist.append(scale) #scale for tCONTscaling self.timescalelist = [] for i in range(3): scale = gtk.HScale() scale.set_range(0.125, 10) scale.set_value(1) scale.set_increments(0.125, 0.125) scale.set_digits(3) scale.set_size_request(160, 45) self.fixed.put(scale, 100 + i * 250, 270) self.timescalelist.append(scale) #filechooser self.filechooser = [] for i in range(3): filechooserbutton = gtk.FileChooserButton("Select A File", None) filechooserbutton.connect("file-set", self.file_selected, i) filechooserbutton.set_width_chars(10) self.fixed.put(filechooserbutton, 100 + 250 * i, 50) self.filechooser.append(filechooserbutton) for i in range(3): label = gtk.Label("Select File") self.fixed.put(label, 120 + i * 250, 30) for i in range(3): label = gtk.Label("Amplitude:") self.fixed.put(label, 100 + i * 250, 110) for i in range(3): label = gtk.Label("Time Shift:") self.fixed.put(label, 100 + i * 250, 180) for i in range(3): label = gtk.Label("Time Scaling:") self.fixed.put(label, 100 + i * 250, 250) self.button = [] for i in range(3): but = gtk.Button("Start") but1 = gtk.Button("Play/Pause") but2 = gtk.Button("Stop") self.button.append(but) self.fixed.put(but, 100 + i * 250, 500) self.fixed.put(but2, 240 + i * 250, 500) self.fixed.put(but1, 150 + i * 250, 500) but.connect("clicked", self.callback, i) but2.connect("clicked", self.stopback, i) but1.connect("clicked", self.pauseback, i) but = gtk.Button("Mix and Play") but3 = gtk.Button("Stop Mix") but2 = gtk.Button("Stop Modulation") but1 = gtk.Button("Modulate and Play") but.connect("clicked", self.mixback) but1.connect("clicked", self.modback) but2.connect("clicked", self.modstop) but3.connect("clicked", self.mixstop) self.fixed.put(but, 100, 600 - 50) self.fixed.put(but3, 100, 600 - 20) self.fixed.put(but1, 200, 600 - 50) self.fixed.put(but2, 200, 600 - 20) recordbut = gtk.Button("Record") recordbut.connect("clicked", self.recordstart) self.fixed.put(recordbut, 400, 550) #recordbut=gtk.Button("Play") #recordbut.connect("clicked",self.recordplay) self.recordingplay = -1 self.recordpid = -1 #self.fixed.put(recordbut,480,550) self.window.show_all()
def main(): # window window = gtk.Window() window.resize(400, 400) # TODO this resizes the surface and view? window.move(400, 600) window.connect('destroy', gtk.main_quit) window.realize() da = gtk.DrawingArea() ''' This must precede realization of view? or use add_events(). First three are mouse events. STRUCTURE is configure-event (resizing the window) Last are focus and keyboard events. ''' da.set_events( \ gdk.BUTTON_PRESS_MASK \ | gdk.POINTER_MOTION_MASK \ | gdk.BUTTON_RELEASE_MASK \ | gdk.STRUCTURE_MASK \ | gdk.FOCUS_CHANGE_MASK\ | gdk.KEY_RELEASE_MASK \ | gdk.KEY_PRESS_MASK ) ''' Enable drawing area widget to receive keyboard events: focus_in, key_release, etc. We implement our own widgets (controls) including text controls that receive keyboard. Also, we implement our own *traversal* (via the tab key per convention) among our controls that get the keyboard focus. ''' da.set_flags(da.flags() | gtk.CAN_FOCUS) window.add(da) # Can draw to several ports. a_view = port.ViewPort(da) a_printerport = port.PrinterPort() a_fileport = port.FilePort() # global singletons config.viewport = a_view config.scheme = scheme.Scheme() window.show_all() # Show now so allocation becomes valid gui.manager.control.control_manager = gui.manager.control.ControlsManager( ) # Enforces one control active controlinstances.build_all(a_printerport, a_fileport) # build singleton controls gui.manager.control.control_manager.set_root_control( controlinstances.bkgd_control) # Initial active control is the background manager. Controlee is the bkgd_control itself. gui.manager.control.control_manager.activate_control( controlinstances.bkgd_control, controlinstances.bkgd_control) a_view.set_model(config.scheme.model) a_printerport.set_model(config.scheme.model) a_fileport.set_model(config.scheme.model) make_test_doc() gtk.main()
lines = commands.getoutput("wmctrl -l").split("\n") windows = [] for line in lines: line = line.replace(" ", " ") win = tuple(line.split(" ", 3)) windows.append(win) isPopulated = dict() for desktop in desktops: isPopulated[desktop[0]] = False for win in windows: if win[1] == desktop[0]: isPopulated[desktop[0]] = True tabWin = gtk.Window() tabWin.set_decorated(False) tabWin.set_skip_taskbar_hint(True) tabWin.set_skip_pager_hint(True) cols = 0 for desktop in isPopulated: if isPopulated[desktop] == True: cols = cols + 1 else: desktops.remove(desktops[int(desktop)]) buttons = [] table = gtk.Table(3, cols, False) table.set_col_spacings(10) windowName = gtk.Label(windows[0][3])
def main(self): #print "------------------Main-------------------------" accel_group = gtk.AccelGroup() # Main Window main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_resizable(False) main_window.set_title("GTK Tetris") main_window.connect("key-press-event", self.keyboard_event_handler) main_window.connect("destroy", gtk.main_quit) # vertical box v_box = gtk.VBox(False, 0) main_window.add(v_box) v_box.show() # menu stuff menu_bar = gtk.MenuBar() menu_bar.show() v_box.pack_start(menu_bar, False, False, 0) # Game sub-menu menu_game = gtk.MenuItem("_Game", True) menu_game.show() menu_bar.add(menu_game) menu_game_menu = gtk.Menu() menu_game.set_submenu(menu_game_menu) self.menu_game_quick = gtk.MenuItem("Start Game", True) self.menu_game_quick.show() menu_game_menu.add(self.menu_game_quick) self.menu_game_quick.connect("activate", self.game_start_stop) self.menu_game_quick.add_accelerator("activate", accel_group, ord('G'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) self.menu_game_stop = gtk.MenuItem("Stop Game", True) self.menu_game_stop.show() menu_game_menu.add(self.menu_game_stop) self.menu_game_stop.connect("activate", self.game_start_stop) self.menu_game_stop.add_accelerator("activate", accel_group, ord('O'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) self.menu_game_stop.set_sensitive(False) self.menu_game_pause = gtk.CheckMenuItem("Pause", True) self.menu_game_pause.show() menu_game_menu.add(self.menu_game_pause) self.menu_game_pause.connect("activate", self.game_set_pause) self.menu_game_pause.add_accelerator("activate", accel_group, ord('P'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) separatormenuitem1 = gtk.MenuItem() separatormenuitem1.show() menu_game_menu.add(separatormenuitem1) separatormenuitem1.set_sensitive(False) self.menu_game_quit = gtk.MenuItem("Quit", True) self.menu_game_quit.show() menu_game_menu.add(self.menu_game_quit) self.menu_game_quit.connect("activate", gtk.main_quit) self.menu_game_quit.add_accelerator("activate", accel_group, ord('X'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) # Settings sub-menu menu_settings = gtk.MenuItem("_Settings", True) menu_settings.show() menu_bar.add(menu_settings) menu_settings_menu = gtk.Menu() menu_settings.set_submenu(menu_settings_menu) self.menu_game_start = gtk.MenuItem("Level Settings", True) self.menu_game_start.show() menu_settings_menu.add(self.menu_game_start) self.menu_game_start.connect("activate", self.show_new_game) self.menu_game_show_next_block = gtk.CheckMenuItem("Show next block", True) self.menu_game_show_next_block.show() menu_settings_menu.add(self.menu_game_show_next_block) self.menu_game_show_next_block.connect("activate", self.game_show_next_block) if common.options["shw_nxt"]: self.menu_game_show_next_block.set_active(True) self.menu_game_show_next_block.add_accelerator("activate", accel_group, ord('N'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) separator1 = gtk.MenuItem() separator1.show() menu_settings_menu.add(separator1) separator1.set_sensitive(False) self.menu_save_options = gtk.MenuItem("Save Settings", True) self.menu_save_options.show() menu_settings_menu.add(self.menu_save_options) self.menu_save_options.connect("activate", self.save_options) # Help sub-menu menu_help = gtk.MenuItem("_Help", True) menu_help.show() menu_bar.add(menu_help) menu_help.set_right_justified(True) menu_help_menu = gtk.Menu() menu_help.set_submenu(menu_help_menu) help1 = gtk.MenuItem("Help", True) help1.show() menu_help_menu.add(help1) help1.connect("activate", self.show_help) # How to set F1 shortcut????????????????????????// help1.add_accelerator("activate", accel_group, ord('H'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) high_scores1 = gtk.MenuItem("High-scores", True) high_scores1.show() menu_help_menu.add(high_scores1) high_scores1.connect("activate", self.show_highscore_wrapper) separator2 = gtk.MenuItem() separator2.show() menu_help_menu.add(separator2) separator2.set_sensitive(False) about1 = gtk.MenuItem("About", True) about1.show() menu_help_menu.add(about1) about1.connect("activate", self.show_about) # horizontal box h_box = gtk.HBox(False, 1) h_box.show() v_box.pack_start(h_box, False, False, 0) # game_border game_border = gtk.Frame() game_border.set_shadow_type(gtk.SHADOW_IN) h_box.pack_start(game_border, False, False, 1) game_border.show() # Global game_area common.game_area = gtk.DrawingArea() common.game_area.show() common.game_area.set_size_request(common.MAX_X*common.BLOCK_WIDTH, common.MAX_Y*common.BLOCK_HEIGHT) common.game_area.connect("expose_event", self.game_area_expose_event) common.game_area.set_events(gtk.gdk.EXPOSURE_MASK) game_border.add(common.game_area) # right side right_side = gtk.VBox(False, 0) h_box.pack_start(right_side, False, False, 0) right_side.show() # next_block_border next_block_border = gtk.Frame() next_block_border.set_shadow_type(gtk.SHADOW_IN) right_side.pack_start(next_block_border, False, False, 0) next_block_border.show() # Global next block area common.next_block_area = gtk.DrawingArea() common.next_block_area.show() common.next_block_area.set_size_request(4*common.BLOCK_WIDTH, 4*common.BLOCK_HEIGHT) common.next_block_area.connect("expose_event", self.next_block_area_expose_event) common.next_block_area.set_events(gtk.gdk.EXPOSURE_MASK) next_block_border.add(common.next_block_area) # the score, level, lines self.score_label1 = gtk.Label("Score:") self.score_label1.set_justify(gtk.JUSTIFY_RIGHT) self.score_label1.show() right_side.pack_start(self.score_label1, False, False, 3) self.score_label2 = gtk.Label("0") self.set_gtk_color_style(self.score_label2, 0xffff, 0, 0) self.score_label2.set_justify(gtk.JUSTIFY_RIGHT) self.score_label2.show() right_side.pack_start(self.score_label2, False, False, 3) self.level_label1 = gtk.Label("Level:") self.level_label1.set_justify(gtk.JUSTIFY_RIGHT) self.level_label1.show() right_side.pack_start(self.level_label1, False, False, 3) dummy = str(common.current_level) self.level_label2 = gtk.Label(dummy) # ??????????????????????????????????????????????????? self.set_gtk_color_style(self.level_label2, 0,0,0) #?????????????????????????????????????????? self.level_label2.set_justify(gtk.JUSTIFY_RIGHT) self.level_label2.show() right_side.pack_start(self.level_label2, False, False, 3) self.line_label1 = gtk.Label("Lines:") self.line_label1.set_justify(gtk.JUSTIFY_RIGHT) self.line_label1.show() right_side.pack_start(self.line_label1, False, False, 3) self.line_label2 = gtk.Label("0") self.line_label2.set_justify(gtk.JUSTIFY_RIGHT) self.line_label2.show() right_side.pack_start(self.line_label2, False, False, 3) # the game buttons # Start_stop self.Start_stop_button = gtk.Button() self.Start_stop_button.show() self.Start_stop_button.connect("clicked", self.game_start_stop) self.Start_stop_button_label = gtk.Label(self.start_stop_str[0]) box2 = self.label_box(right_side, self.Start_stop_button_label, self.start_stop_str[0]) box2.show() self.Start_stop_button.add(box2) right_side.pack_start(self.Start_stop_button, False, False, 3) self.Start_stop_button.set_flags(gtk.CAN_DEFAULT) self.Start_stop_button.grab_default() # Pause self.Pause_button = gtk.Button() self.Pause_button.show() self.Pause_button.connect("clicked", self.game_set_pause_b) self.Pause_button_label = gtk.Label(self.pause_str[0]) box1 = self.label_box(right_side, self.Pause_button_label, self.pause_str[0]) box1.show() self.Pause_button.add(box1) right_side.pack_start(self.Pause_button, False, False, 3) self.Pause_button.set_flags(gtk.CAN_DEFAULT) self.Pause_button.set_sensitive(False) main_window.add_accel_group(accel_group) main_window.show() # Block pixmap common.blocks_pixmap,mask = gtk.gdk.pixmap_create_from_xpm_d(common.game_area.window, None, common.blocks_xpm) gtk.main()
def __init__(self): # ################################################################################################################################# # # Load and apply gtkrc # ################################################################# # # No exception control because rc_parse doesn't throw exception on fail... sad but true ;) # ORIGDIR = os.getcwd() # os.chdir('lib/ui/data/Brave/gtk-2.0/') # gtk.rc_parse('gtkrc') # os.chdir(ORIGDIR) # Load Output Manager self.gom = om.OutputManager('gui') ################################################################################################################################# # Create a new window ################################################################# splash.push(("Creatin main window...")) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_focus = True self.window.connect("destroy", lambda w: gtk.main_quit()) self.window.connect("delete_event", self.quit) splash.push(("Loading...")) gtk.settings_get_default().set_long_property("gtk-button-images", True, "main") # Title self.window.set_title(MAINTITLE) # Positions self.window.resize(800, 600) self.window.move(25, 25) # Maximize window self.window.maximize() ################################################################################################################################# # Load core... ################################################################# #Initialize KB splash.push(("Loading KB...")) self.uicore = core.UIcore() self.uicore.add_local_asn() self.uicore.set_om(self.gom) self.gom.set_core(self.uicore) ################################################################################################################################# # Main VBox ################################################################# mainvbox = gtk.VBox(False, 1) mainvbox.set_border_width(1) self.window.add(mainvbox) mainvbox.show() ################################################################################################################################# # Tool Bars HBox ################################################################# tbhbox = gtk.HBox(False, 1) mainvbox.pack_start(tbhbox, False, False, 1) tbhbox.show() ################################################################################################################################# # UIManager for MAP Toolbar ################################################################# # to make it nice we'll put the toolbar into the handle box, # so that it can be detached from the main window self.handlebox = gtk.HandleBox() tbhbox.pack_start(self.handlebox, True, True, 1) # Create a UIManager instance splash.push(("Creating menu and toolbar...")) uimanager = gtk.UIManager() accelgroup = uimanager.get_accel_group() self.window.add_accel_group(accelgroup) self._actiongroup = actiongroup = gtk.ActionGroup('UIManager') # Create actions actiongroup.add_actions([ # xml_name, icon, real_menu_text, accelerator, tooltip, callback ('Load', gtk.STOCK_OPEN, ('Load'), None, (''), self.loadKB), ('Save', gtk.STOCK_SAVE, ('Save'), None, (''), self.saveKB), ('Import', gtk.STOCK_CONVERT, ('Import'), None, (''), self.importScan), ('Edit', gtk.STOCK_EDIT, ('Edit'), None, (''), self.loadEditor), ('Proxy', gtk.STOCK_CONNECT, ('Proxy'), None, (''), gtk.main_quit), ('Web Server', gtk.STOCK_EXECUTE, ('Web'), None, ('Web'), gtk.main_quit), #('Sniffer', gtk.STOCK_NETWORK, ('Sniffer'), None, (''), gtk.main_quit), ('Sniffer', gtk.STOCK_NETWORK, ('Sniffer'), None, (''), self.run_sniffer), ('Scapy', gtk.STOCK_HELP, ('Scapy'), None, (''), self.show_term), ('Add Target', gtk.STOCK_ADD, ('Add Target'), None, (''), self.addTarget), ('Preferences', gtk.STOCK_PREFERENCES, ('Preferences'), None, (''), self.showPref), ('Show Log', gtk.STOCK_DND, ('Show Log'), None, (''), self.show_log), ('Show KB', gtk.STOCK_DND, ('Show KB'), None, (''), self.show_kb), ('Report', gtk.STOCK_DND, ('Report'), None, (''), self.report), ('Quit', gtk.STOCK_QUIT, ('Quit'), None, (''), gtk.main_quit), ]) # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) uimanager.add_ui_from_string(ui_menu) # Toolbar toolbar = uimanager.get_widget('/Toolbar') toolbar.set_style(gtk.TOOLBAR_BOTH) # Disabled until I get them working button_proxy = uimanager.get_widget('/Toolbar/Proxy') button_proxy.set_sensitive(False) button_web = uimanager.get_widget('/Toolbar/Web Server') button_web.set_sensitive(False) # Disable if not GtkSourceView2 if not config.HAS_SOURCEVIEW: button_edit = uimanager.get_widget('/Toolbar/Edit') button_edit.set_sensitive(False) # Disable if not Vte if not config.HAS_VTE: button_sniffer = uimanager.get_widget('/Toolbar/Sniffer') button_sniffer.set_sensitive(False) button_scapy = uimanager.get_widget('/Toolbar/Scapy') button_scapy.set_sensitive(False) self.handlebox.add(toolbar) toolbar.show() self.handlebox.show() ################################################################################################################################# # Map tab ################################################################# # Will contain on top the notebook and on bottom log window self.vpaned = gtk.VPaned() # Will contain xdot widget and kb window self.hpaned = gtk.HPaned() ################################################################# # KB Textview ################################################################# self.textview = kbwin.KBwindow() #self.gom.set_kbwin(self.textview) ################################################################# # KB TreeView ################################################################# self.treeview = kbtree.KBtree() self.tree = self.treeview.createTree() self.treeview.updateTree() self.gom.set_kbwin(self.treeview) self.tree.show() ################################################################# # xdot map ################################################################# from . import inxdot # self.context = cmenu.contextMenu() # self.context.createMenus(self.textview, self.gom) # # self.xdotw = inxdot.MyDotWidget(self.context, self.uicore) # nodeMenu initialization stuff self.uiman = nodeMenu.UIManager(self.gom, self.uicore, config) self.uiman.set_data(None) accel = self.uiman.get_accel_group() self.window.add_accel_group(accel) # graphMenu initialization stuff self.graph_uiman = graphMenu.UIManager(self.gom, self.uicore) #self.graph_uiman.set_data(None) graph_accel = self.graph_uiman.get_accel_group() self.window.add_accel_group(graph_accel) self.xdotw = inxdot.MyDotWidget(self.uiman, self.graph_uiman, self.uicore) setattr(self.graph_uiman, 'xdot', self.xdotw) self.xdotw.set_size_request(900, 450) self.gom.set_map(self.xdotw) setattr(self.uicore, 'xdot', self.xdotw) self.uicore.getDot(doASN=True) self.xdotw.set_dotcode(self.uicore.get_kbfield('dotcode')) self.xdotw.zoom_image(1.0) ################################################################# # Graph Menu ################################################################# gmenu = graphTBar.GraphMenu(self.xdotw, self.uicore) ################################################################# # HBox for Map and GraphMenu ################################################################# menubox = gtk.HBox() menubox.pack_start(self.xdotw, True, True) menubox.pack_start(gmenu, False, False) # Show elements gmenu.show() menubox.show() ################################################################# # Scrolled Window ################################################################# self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window.set_size_request(100, 100) # Add Textview to Scrolled Window #self.scrolled_window.add_with_viewport(self.textview) self.scrolled_window.add_with_viewport(self.tree) ################################################################# # Map Iface ################################################################# bufferf = "Map" frame = gtk.Frame(bufferf) frame.set_border_width(5) frame.show() label = gtk.Label('Map') # Test XDOT MAP frame.add(self.hpaned) #self.hpaned.add1(self.xdotw) self.hpaned.add1(menubox) self.hpaned.add2(self.scrolled_window) self.textview.show() # Check visibility on config preferences if config.SHOW_KBTREE: self.scrolled_window.show() self.scrolled_window.is_visible = True else: self.scrolled_window.is_visible = False self.hpaned.show() self.xdotw.show() label = gtk.Label('Map') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() ################################################################# # Notebook ################################################################# self.notebook = gtk.Notebook() self.notebook.set_tab_pos(gtk.POS_LEFT) #notebook.append_page(frame, label) self.notebook.append_page(frame, b) self.notebook.connect("switch_page", self.onSwitch) ################################################################################################################################# # Consoles Tab ################################################################# label = gtk.Label('Term') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() term_box = gtk.VBox() term_button = gtk.Button("New Tab") # Disable if VTE not available if not config.HAS_VTE: term_button.set_sensitive(False) term_box.pack_start(term_button, False) self.term_notebook = libTerminal.TerminalNotebook() #term_button.connect("clicked", term_notebook.new_tab) term_button.connect("clicked", self.new_tab) term_box.pack_start(self.term_notebook) setattr(self.uiman, 'termnb', self.term_notebook) setattr(self.uiman, 'mainnb', self.notebook) self.notebook.append_page(term_box, b) term_box.show_all() ################################################################################################################################# # RCE Iface ################################################################# # xdot rce import xdot self.xdotr = xdot.DotWidget() self.xdotr.set_size_request(600, 512) self.xdotr.show() bufferf = "RCE" frame = gtk.Frame(bufferf) frame.set_border_width(5) frame.set_size_request(400, 400) label = gtk.Label('RCE') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() self.notebook.append_page(frame, b) # RCE graph menu self.rmenu = rceTBar.RceMenu(self.xdotr, rcecore) self.dasmenu = rceTBar.DasmMenu() ################################################################################################################################# # UIManager for RCE Toolbar ################################################################# # to make it nice we'll put the toolbar into the handle box, # so that it can be detached from the main window self.rcehb = gtk.HandleBox() tbhbox.pack_start(self.rcehb, True, True, 1) # Create a UIManager instance rceuiman = gtk.UIManager() rceaccelgroup = rceuiman.get_accel_group() self.window.add_accel_group(rceaccelgroup) self._actiongroup = actiongroup = gtk.ActionGroup('UIManager') # Create actions actiongroup.add_actions([ # xml_name, icon, real_menu_text, accelerator, tooltip, callback ('New', gtk.STOCK_NEW, ('New'), None, (''), self.newBin), ('Load', gtk.STOCK_OPEN, ('Load'), None, (''), self.loadBin), ('Show Log', gtk.STOCK_DND, ('Show Log'), None, (''), self.show_log), #('Debugger', gtk.STOCK_EXECUTE, ('Debugger'), None, (''), gtk.main_quit), ('Debugger', gtk.STOCK_EXECUTE, ('Debugger'), None, (''), self.run_debugger), #('Report', gtk.STOCK_DND, ('Report'), None, (''), gtk.main_quit), ('Quit', gtk.STOCK_QUIT, ('Quit'), None, (''), gtk.main_quit), ]) # Add the actiongroup to the rceuiman rceuiman.insert_action_group(actiongroup, 0) rceuiman.add_ui_from_string(rce_menu) # Toolbar rcetoolbar = rceuiman.get_widget('/RceToolbar') self.rcehb.add(rcetoolbar) self.rcehb.hide() ################################################################# # RCE HBox and VBoxes ################################################################# rcepaned = gtk.HPaned() lrcevb = gtk.VBox(False, 1) rrcevb = gtk.VBox(False, 1) rcepaned.add1(lrcevb) rcepaned.add2(rrcevb) lrcevb.pack_start(self.rmenu, False, False, 1) rrcevb.pack_start(self.dasmenu, False, False, 1) rcepaned.show_all() ################################################################# # Textview RCE ################################################################# rcetv = gtk.TextView(buffer=None) rcetv.set_wrap_mode(gtk.WRAP_NONE) rcetv.set_editable(False) fontdesc = pango.FontDescription("MonoSpace 10") #fontdesc = pango.FontDescription("Purisa 10") rcetv.modify_font(fontdesc) rcetv.show() self.textbuffer = rcetv.get_buffer() # Scrolled Window rce_scrolled_window = gtk.ScrolledWindow() rce_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) rce_scrolled_window.show() # Add Textview to Scrolled Window rce_scrolled_window.add_with_viewport(rcetv) # Add xdotr and textview to rcehbox lrcevb.pack_start(self.xdotr, True, True, 2) rrcevb.pack_start(rce_scrolled_window, True, True, 2) frame.add(rcepaned) frame.show() rcepaned.show() ################################################################################################################################# # Xploit Iface ################################################################# bufferf = "Exploit" frame = gtk.Frame(bufferf) frame.set_border_width(5) frame.show() label = gtk.Label('Exploit') frame.add(label) label.show() label = gtk.Label('Exploit') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() self.exploitsInst = exploits.Exploits(config, self.term_notebook) exploitsGui = self.exploitsInst.get_widget() exploitsGui.show_all() self.notebook.append_page(exploitsGui, b) #mainvbox.pack_start(notebook, True, True, 1) self.vpaned.add1(self.notebook) self.notebook.show() ################################################################################################################################# # Log Window ################################################################# self.logtext = gtk.TextView(buffer=None) self.logtext.set_wrap_mode(gtk.WRAP_NONE) self.logtext.set_editable(False) #self.logtext.set_size_request(40,40) self.logbuffer = self.logtext.get_buffer() self.logbuffer.set_text('Loading Inguma...\n') self.logtext.show() ################################################################# # Log Scrolled Window ################################################################# self.log_scrolled_window = gtk.ScrolledWindow() self.log_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.log_scrolled_window.is_visible = True #Always on bottom on change self.vajd = self.log_scrolled_window.get_vadjustment() self.vajd.connect( 'changed', lambda a, s=self.log_scrolled_window: self.rescroll(a, s)) #self.log_scrolled_window.set_size_request(40,40) #self.logtext.set_size_request(20,20) # Add Textview to Scrolled Window self.log_scrolled_window.add_with_viewport(self.logtext) # Set logtext as output for gui self.gom.set_gui(self.logbuffer) # Add Scrolled Log Window to Bottom Notebook ############################################ # Notebook for bottom panel self.bottom_nb = gtk.Notebook() self.bottom_nb.set_tab_pos(gtk.POS_LEFT) # Icon and label for Logs tab label = gtk.Label('Logs') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() self.bottom_nb.append_page(self.log_scrolled_window, b) # Icon and label for Actions tab label = gtk.Label('Actions') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() # Add Threads TreeView self.threadsInst = threadstv.ThreadsTv() threadsGui = self.threadsInst.get_widget() threadsGui.show_all() self.bottom_nb.append_page(threadsGui, b) #self.bottom_nb.set_scrollable(True) self.bottom_nb.set_current_page(0) # Check visibility on config preferences if config.SHOW_LOG: self.bottom_nb.is_visible = True self.bottom_nb.show() else: self.bottom_nb.is_visible = False self.vpaned.add2(self.bottom_nb) mainvbox.pack_start(self.vpaned, True, True, 1) self.log_scrolled_window.show() # Add threadtv to core self.uicore.set_threadtv(self.threadsInst) setattr(self.graph_uiman, 'threadtv', self.threadsInst) # ################################################################################################################################# # # Progress Bar # ################################################################# # self.progressbar = pbar.PBar() # self.progressbar.set_stopped() # mainvbox.pack_start(self.progressbar, False, False, 1) ################################################################################################################################# #StatusBar ################################################################# statusbar = gtk.Statusbar() mainvbox.pack_end(statusbar, False, False, 1) context_id = statusbar.get_context_id("Inguma 0.2") message_id = statusbar.push(context_id, 'Inguma 0.2') statusbar.show() ################################################################################################################################# # finish it ################################################################# self.vpaned.show() self.window.show() splash.destroy() gtk.main()
def __init__(self): ttle1 = 'Spectrum el1' ttle2 = ' el2 - . el1' ttle3 = ' el3 - . el1' ttle4 = ' el1 - . el2' ttle5 = ' Spectrum el2' ttle6 = ' el3 - . el2' ttle7 = ' el1 - . el3' ttle8 = 'el2 - . el3' ttle9 = 'Spectrum el3' self.win = gtk.Window() self.win.set_border_width(5) self.win.resize(800, 400) vbox = gtk.VBox(spacing=3) self.win.add(vbox) vbox.show() self.fig = Figure(figsize=(7, 5), dpi=72) self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea self.canvas.show() vbox.pack_start(self.canvas, True, True) (self.e1, self.e2, self.e3) = signal_gen.signal_gen(3, .1, .001) c = 0 for i in self.e1: print i, self.e2[c] c += 1 self.ax1 = self.fig.add_subplot(431, title=ttle1) # self.ax1.set_xlim(0,60) # self.ax1.set_ylim(0,1) self.ax2 = self.fig.add_subplot(432, title=ttle2) self.ax2.set_xlim(0, 60) self.ax2.set_ylim(0, 1) self.ax3 = self.fig.add_subplot(433, title=ttle3) self.ax3.set_xlim(0, 60) self.ax3.set_ylim(0, 1) self.ax4 = self.fig.add_subplot(434, title=ttle4) self.ax4.set_xlim(0, 60) self.ax4.set_ylim(0, 1) self.ax5 = self.fig.add_subplot(435, title=ttle5) self.ax5.set_xlim(0, 60) self.ax5.set_ylim(0, 1) self.ax6 = self.fig.add_subplot(436, title=ttle6) self.ax6.set_xlim(0, 60) self.ax6.set_ylim(0, 1) self.ax7 = self.fig.add_subplot(437, title=ttle7) self.ax7.set_xlim(0, 60) self.ax7.set_ylim(0, 1) self.ax8 = self.fig.add_subplot(438, title=ttle8) self.ax8.set_xlim(0, 60) self.ax8.set_ylim(0, 1) self.ax9 = self.fig.add_subplot(439, title=ttle9) self.ax9.set_xlim(0, 60) self.ax9.set_ylim(0, 1) self.ax10 = self.fig.add_subplot(4, 3, 10, title="el1") self.ax11 = self.fig.add_subplot(4, 3, 11, title="el2") self.ax12 = self.fig.add_subplot(4, 3, 12, title="el3")
import gtk ventana = gtk.Window() gtk.main()
alpha = 0.0 # Function for fade splash screen def fade_window(data=None): global alpha data.set_opacity(alpha) alpha += 0.05; if alpha <= 1.0: gobject.timeout_add(20, fade_window, data); return False; # init window splash = gtk.Window(gtk.WINDOW_TOPLEVEL) # enable RGBA colormap for opacity screen = splash.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) # Set width and height splash.set_size_request (595, 218) # Set window hint spashscreen splash.set_type_hint (gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN) # Set window centered splash.set_position (gtk.WIN_POS_CENTER) # Set window above the others
def __init__(self, hosts=None, owner=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() if not hosts: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) self.hosts = hosts if owner is None: owner = USER self.owner = owner self.window = gtk.Window() self.window.set_title("cylc gscan") self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.theme_name = gcfg.get(['use theme']) self.theme = gcfg.get(['themes', self.theme_name]) self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore(str, str, bool, str, int, str, str) self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Construct the host column. host_name_column = gtk.TreeViewColumn("Host") cell_text_host = gtk.CellRendererText() host_name_column.pack_start(cell_text_host, expand=False) host_name_column.set_cell_data_func( cell_text_host, self._set_cell_text_host) host_name_column.set_sort_column_id(0) host_name_column.set_visible("host" in gsfg.get(["columns"])) host_name_column.set_resizable(True) # Construct the suite name column. suite_name_column = gtk.TreeViewColumn("Suite") cell_text_name = gtk.CellRendererText() suite_name_column.pack_start(cell_text_name, expand=False) suite_name_column.set_cell_data_func( cell_text_name, self._set_cell_text_name) suite_name_column.set_sort_column_id(1) suite_name_column.set_visible("suite" in gsfg.get(["columns"])) suite_name_column.set_resizable(True) # Construct the suite title column. suite_title_column = gtk.TreeViewColumn("Title") cell_text_title = gtk.CellRendererText() suite_title_column.pack_start(cell_text_title, expand=False) suite_title_column.set_cell_data_func( cell_text_title, self._set_cell_text_title) suite_title_column.set_sort_column_id(3) suite_title_column.set_visible("title" in gsfg.get( ["columns"])) suite_title_column.set_resizable(True) # Construct the update time column. time_column = gtk.TreeViewColumn("Updated") cell_text_time = gtk.CellRendererText() time_column.pack_start(cell_text_time, expand=False) time_column.set_cell_data_func( cell_text_time, self._set_cell_text_time) time_column.set_sort_column_id(4) time_column.set_visible("updated" in gsfg.get(["columns"])) time_column.set_resizable(True) self.suite_treeview.append_column(host_name_column) self.suite_treeview.append_column(suite_name_column) self.suite_treeview.append_column(suite_title_column) self.suite_treeview.append_column(time_column) # Construct the status column. status_column = gtk.TreeViewColumn("Status") status_column.set_sort_column_id(5) status_column.set_visible("status" in gsfg.get(["columns"])) status_column.set_resizable(True) status_column_info = 6 cycle_column_info = 5 cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func( cell_text_cycle, self._set_cell_text_cycle, cycle_column_info) self.suite_treeview.append_column(status_column) for i in range(len(TASK_STATUSES_ORDERED)): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func( cell_pixbuf_state, self._set_cell_pixbuf_state, (status_column_info, i) ) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.updater = ScanAppUpdater( self.hosts, suite_treemodel, self.suite_treeview, owner=self.owner, poll_interval=poll_interval ) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(300, 150) self.suite_treeview.grab_focus() self.window.show()
def run(self): warnings.simplefilter("ignore") self._pipe_name = '/tmp/webapp.pipe' self._view = view = webkit.WebView() view.connect('navigation-policy-decision-requested', self._nav_req_handler) view.connect('close-web-view', self._close) view.connect('onload-event', self._onload) language = self._get_browser_lang() view.execute_script("window.navigator.userLanguage = '%s'" % language) if self._inspector: view.get_settings().set_property("enable-developer-extras", True) if hasattr(self.__class__, "_focus_in"): view.connect('focus-in-event', self._focus_in) if hasattr(self.__class__, "_focus_out"): view.connect('focus-out-event', self._focus_out) if hasattr(self.__class__, "_download"): view.connect('download-requested', self._download) splitter = gtk.VPaned() sw = gtk.ScrolledWindow() sw.add(view) splitter.add1(sw) inspector = view.get_web_inspector() inspector.connect("inspect-web-view", self._activate_inspector, splitter) self._win = win = gtk.Window(gtk.WINDOW_TOPLEVEL) win.set_title(self._title) win.connect("destroy", gtk.main_quit) if self._app_icon is not None: if os.path.exists(self._app_icon): win.set_icon_from_file(self._app_icon) else: win.set_icon_name(self._app_icon) if self._taskbar is False: gtk.Window.set_skip_taskbar_hint(win, True) win.add(splitter) win.realize() win.show_all() gdk_window_settings(win.window, self._x, self._y, self._width, self._height, self._decoration, self._maximized, self._centered) if self._disable_minimize: win.connect("window-state-event", self._unminimise_if_minimised) view.open(self._index) # Start a thread that injects Javascript code coming from a filesystem pipe. if self._pipe == True: atexit.register(atexit_pipe_cleanup, self._pipe_name) thread.start_new_thread(thr_inject_javascript, (self._view, self._pipe_name)) gtk.main()
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_resizable(True) self.window.set_size_request(450,540) self.window.connect("destroy", self.close_application) self.window.connect("key_press_event", self.key_pressed) self.handler = self.window.connect("key_release_event", self.key_released) self.window.set_title("Devanagari Editor") self.window.set_border_width(0) self.window.set_icon_from_file("DElogo.ico") menubar = gtk.MenuBar() menu_file = gtk.Menu() menu_edit = gtk.Menu() menu_help = gtk.Menu() item_open = gtk.MenuItem("Open") item_open.connect("activate", self.open_devanagari_file) item_save = gtk.MenuItem("Save") item_save.connect("activate", self.save_devanagari_file) item_quit = gtk.MenuItem("Quit") item_quit.connect("activate", self.close_application) menu_file.append(item_open) menu_file.append(item_save) menu_file.append(item_quit) item_cut = gtk.MenuItem("Cut") item_copy = gtk.MenuItem("Copy") item_paste = gtk.MenuItem("Paste") menu_edit.append(item_cut) menu_edit.append(item_copy) menu_edit.append(item_paste) item_about = gtk.MenuItem("About") menu_help.append(item_about) item_file = gtk.MenuItem("File") item_edit = gtk.MenuItem("Edit") item_help = gtk.MenuItem("Help") item_file.set_submenu(menu_file) item_edit.set_submenu(menu_edit) item_help.set_submenu(menu_help) menubar.append(item_file) menubar.append(item_edit) menubar.append(item_help) self.box1 = gtk.VBox(False, 0) self.window.add(self.box1) self.box1.show() self.box1.pack_start(menubar, False, False, 0) box2 = gtk.VBox(False, 0) box2.set_border_width(0) self.box1.pack_start(box2, True, True, 0) box2.show() # the source text buffer sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.TextView() self.textbuffer = self.textview.get_buffer() self.textview.set_wrap_mode(gtk.WRAP_WORD) self.textview.modify_font(pango.FontDescription("Sans 12")) sw.add(self.textview) sw.show() self.textview.show() box2.pack_start(sw) self.Mode = 'Devanagari' # clipboard self.clipboard = gtk.Clipboard(gtk.gdk.display_get_default(), "CLIPBOARD") # show the window self.window.show_all()
def __init__(self): # Create the main window, and attach delete_event signal to terminate # the application. Note that the main window will not have a titlebar # since we're making it a popup. window = gtk.Window(gtk.WINDOW_POPUP) window.set_flags(gtk.CAN_FOCUS | gtk.SENSITIVE) window.connect("delete_event", self.close_application) window.set_events(window.get_events() | gtk.gdk.BUTTON_PRESS_MASK) window.set_events(window.get_events() | gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK) window.connect("button_press_event", self.close_application) window.connect("key-press-event", self.close_application) ww = 320 hh = 100 #window.set_position(gtk.WIN_POS_CENTER_ALWAYS) window.move(gtk.gdk.screen_width() - (ww + 20), 40) window.show() # Now for the pixmap and the image widget #pixmap, mask = gtk.gdk.pixmap_create_from_xpm_d( # window.window, None, WheelbarrowFull_xpm) #pixmap = gtk.gdk.pixbuf_new_from_file("/usr/share/pixmaps/gnome-logo-large.png") #image = gtk.image_new_from_file("/usr/share/pixmaps/gnome-logo-large.png") #image = gtk.image_new_from_file("/usr/share/pixmaps/gnome-background-image.png") image = gtk.image_new_from_file("/usr/share/pixmaps/gnome-tigert.png") fname = os.getcwd() + "/rect.png" #print fname #image = gtk.image_new_from_file(fname) #pixbuff = image.get_pixbuf() #print image #pixbuff = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 300, 300); #pixbuff.fill(0xfffaafff) pixmap = gtk.gdk.Pixmap(window.window, ww, hh, depth=-1) gc = gtk.gdk.GC(pixmap) colormap = window.get_colormap() color = colormap.alloc_color("#ff8080") gc.set_foreground(color) pixmap.draw_rectangle(gc, True, 0, 0, ww, hh) color = colormap.alloc_color("#000000") gc.set_foreground(color) gc.line_width = 4 gc.cap_style = gtk.gdk.CAP_ROUND #pixmap.draw_line(gc, 10, 10, ww-10, hh-10) #pixmap.draw_line(gc, ww-10, 10, 10, hh-10) cairo = pixmap.cairo_create() lay = cairo.create_layout() fd = pango.FontDescription() fd.set_size(14 * 1024) lay.set_font_description(fd) lay.set_text("Please set Password for 'user' ") dim = lay.get_pixel_size() pixmap.draw_layout(gc, pixmap.get_size()[0] / 2 - dim[0] / 2, pixmap.get_size()[1] / 2 - dim[1], lay) lay.set_text("Please set Password for 'root'") dim = lay.get_pixel_size() pixmap.draw_layout(gc, pixmap.get_size()[0] / 2 - dim[0] / 2, pixmap.get_size()[1] / 2, lay) image2 = gtk.Image() image2.set_from_pixmap(pixmap, None) image2.show() #rect = gtk.gdk.Rectangle(100, 100, 200, 200) #region = gtk.gdk.region_rectangle(rect) #window.shape_combine_region(region, 0, 0) # To display the image, we use a fixed widget to place the image fixed = gtk.Fixed() fixed.put(image, 0, 0) window.add(fixed) fixed.show() maskmap = gtk.gdk.Pixmap(window.window, ww, hh, depth=-1) gc = gtk.gdk.GC(maskmap) gc.set_rgb_fg_color(gtk.gdk.Color(0, 0, 0)) maskmap.draw_rectangle(gc, True, 0, 0, ww, hh) gc.set_rgb_fg_color(gtk.gdk.Color(0xffff, 0xffff, 0xffff)) maskmap.draw_rectangle(gc, True, 20, 20, ww - 40, hh - 40) maskbuff = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, ww, hh) maskbuff.get_from_drawable(maskmap, gtk.gdk.colormap_get_system(), \ 0, 0, 0, 0, ww, hh) maskbuff.add_alpha(True, 0, 0, 0) mask2, mask3 = maskbuff.render_pixmap_and_mask() #image3 = gtk.Image() #image3.set_from_pixmap(mask2, None) #image3.show() #fixed.put(image3, 0, 0) # This masks out everything except for the image itself #window.shape_combine_mask(mask3, 0, 0) # show the window window.show()
def __init__(self, mainWindow): self.runcmd = mainWindow.runcmd # Create a new window self.window = gtk.Window() #hadjustment=None, vadjustment=None) self.swindow = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) self.swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.window.set_title("AGOOEY Process Selector") self.window.set_size_request(600, 240) self.window.connect("delete_event", self.delete_event) self.vbox = gtk.VBox(homogeneous=False, spacing=0) self.hbox = gtk.HBox(homogeneous=False, spacing=0) rows = 6 cols = 6 self.table = gtk.Table(rows, cols, False) button_strings = [ 'm__readfiles', 's__readfiles', 'coarseorb', 'demassist', 'subtrrefpha', 'dinsar', 'm__porbits', 's__porbits', 'coarsecorr', 'coregpm', 'comprefdem', 'slant2h', 'm__crop', 's__crop', 'm__filtazi', 'resample', 'subtrrefdem', 'geocode', 'm__simamp', '', 's__filtazi', 'filtrange', 'coherence', '', 'm__timing', '', 'fine', 'interfero', 'filtphase', '', 'm__ovs', 's__ovs', 'reltiming', 'comprefpha', 'unwrap' ] button = map(lambda i: gtk.Button(button_strings[i]), range(len(button_strings))) ##### SET THE HBOX ##### self.processEntry = gtk.Entry() self.processEntry.set_editable(False) self.processEntry.show() self.applyButton = gtk.Button(label='Apply', stock=None, use_underline=True) self.applyButton.connect("clicked", self.applyButtonClicked) self.applyButton.set_flags(gtk.CAN_DEFAULT) self.applyButton.show() self.refreshButton = gtk.Button(label='Clear', stock=None, use_underline=True) self.refreshButton.connect("clicked", self.refreshButtonClicked) self.refreshButton.set_flags(gtk.CAN_DEFAULT) self.refreshButton.show() self.advancedChkBtn = gtk.CheckButton("Advanced") self.advancedChkBtn.connect("toggled", self.advancedChkBtnToggled) self.advancedChkBtn.show() self.hbox.pack_start(self.refreshButton, expand=False, fill=False, padding=10) self.hbox.pack_start(self.applyButton, expand=False, fill=False, padding=10) self.hbox.pack_end(self.advancedChkBtn, expand=False, fill=False, padding=20) #### SET THE TABLE #### for i in range(len(button_strings)): y, x = divmod(i, cols) if not button_strings[i]: continue button[i].connect("clicked", self.processButtonClicked) self.table.attach(button[i], x, x + 1, y, y + 1) button[i].show() ### SET THE VBOX #### self.vbox.pack_start( self.processEntry, expand=False, fill=False, ) self.vbox.pack_start( self.hbox, expand=False, fill=False, ) self.vbox.pack_start( self.table, expand=False, fill=False, ) self.window.set_default(self.applyButton) self.swindow.add_with_viewport(self.vbox) self.window.add(self.swindow) #self.vbox.show() self.window.show_all()
def ssh_sessions(self, _widget, terminal): """ Main Process. Preparing all buttons and window """ global window window = gtk.Window() window.set_decorated(False) window.set_size_request(500, -1) window.set_title("Opened SSH Sessions") window.connect("destroy", self.destroy) total_session = len(self.proc.ssh_sessions) if total_session == 0: message = gtk.MessageDialog( type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK) message.set_markup("NO SSH Connection FOUND") message.run() message.destroy() else: self.mainbox = gtk.VBox() label = gtk.Label("Select the opened ssh session:") label.set_alignment(0, 0) self.mainbox.pack_start(label, padding=10) label.show() check_button = gtk.CheckButton("Copy SSH Keygen to Server?") check_button.connect("clicked", self.check_box, "") self.mainbox.pack_end(check_button, expand=False) check_button.show() #radio1 = gtk.RadioButton(None, self.return_item(0)) #self.mainbox.pack_start(radio1, expand=False) # radio1.show() # {'terminal' : terminal, 'command' : command['command'] #radio1.connect("clicked", self.action, {'terminal': terminal, 'command': self.return_item(0)}) for i in range(total_session): radio = gtk.RadioButton(None, self.return_item(i)) self.mainbox.pack_start(radio, expand=False) radio.connect("clicked", self.action, { 'terminal': terminal, 'command': self.return_item(i)}) radio.show() self.label = gtk.Label() self.mainbox.pack_start(self.label, padding=10) self.label.show() separator = gtk.HSeparator() self.mainbox.pack_start(separator, False, True, 0) separator.show() radio = gtk.VBox(False, 10) self.mainbox.set_border_width(10) radio.show() # hbox_open = gtk.HBox(False, 0) # button_open = gtk.Button(label='Open') # button_open.connect("clicked", lambda w: self.action()) # button_open.set_flags(gtk.CAN_DEFAULT) # hbox_open.pack_start(button_open, True, False, 0) # button_open.show() hbox_close = gtk.HBox(False, 0) button_close = gtk.Button(stock=gtk.STOCK_CLOSE) button_close.connect("clicked", lambda w: window.hide()) button_close.set_flags(gtk.CAN_DEFAULT) hbox_close.pack_end(button_close, False, False, 0) button_close.show() # hbox_open.show() hbox_close.show() self.mainbox.add(hbox_close) window.add(self.mainbox) window.show_all()
show how to add a matplotlib FigureCanvasGTK or FigureCanvasGTKAgg widget to a gtk.Window """ import gtk from matplotlib.figure import Figure from numpy import arange, sin, pi # uncomment to select /GTK/GTKAgg/GTKCairo from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas #from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas #from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas win = gtk.Window() win.connect("destroy", lambda x: gtk.main_quit()) win.set_default_size(400,300) win.set_title("Embedding in GTK") f = Figure(figsize=(5,4), dpi=100) a = f.add_subplot(111) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) canvas = FigureCanvas(f) # a gtk.DrawingArea win.add(canvas) win.show_all() gtk.main()
def __init__(self, sourceview, sv_changed): self.sourceview = sourceview sv_changed.append(self.on_sv_changed) # Widgets self.textview = tv = gtk.TextView() self.hscrollbar = hs = gtk.HScrollbar() self.vscrollbar = vs = gtk.VScrollbar() self.resizegrip = rg = gtk.EventBox() self.vbox1 = vb1 = gtk.VBox() self.vbox2 = vb2 = gtk.VBox() self.hbox = hb = gtk.HBox() self.window = win = gtk.Window(gtk.WINDOW_POPUP) self.char_width, self.char_height = self.get_char_size(tv) # Dragging vars self.is_dragging = None self.drag_x = None self.drag_y = None self.drag_left = None self.drag_top = None self.was_dragged = None # Resizing vars self.is_resizing = None self.resize_x = None self.resize_y = None self.resize_width = None self.resize_height = None self.was_displayed = False # Initialization style = gtk.rc_get_style_by_paths( tv.get_settings(), 'gtk-tooltip', 'gtk-tooltip', TYPE_NONE) tv.modify_text(gtk.STATE_NORMAL, style.fg[gtk.STATE_NORMAL]) tv.modify_base(gtk.STATE_NORMAL, style.bg[gtk.STATE_NORMAL]) tv.set_size_request(0,0) tv.props.editable = False tv.connect('event', self.on_textview_event) tv.set_scroll_adjustments(hs.props.adjustment, vs.props.adjustment) tv.connect('scroll-event', self.on_textview_scroll) hs.props.adjustment.connect('changed', self.on_hadj_changed) rg.add_events(gdk.BUTTON_PRESS_MASK | gdk.BUTTON_MOTION_MASK | gdk.BUTTON_RELEASE_MASK | gdk.EXPOSURE_MASK) rg.connect('event', self.on_resizegrip_event) rg.set_size_request(vs.size_request()[0], vs.size_request()[0]) vb1.pack_start(tv, True, True) vb1.pack_start(hs, False, False) vb2.pack_start(vs, True, True) vb2.pack_end(rg, False, False) hb.pack_start(vb1, True, True) hb.pack_start(vb2, False, False) win.add(hb) # Make all widgets except the window visible, so that a simple "show" # will suffice to show the window hb.show_all() # We define this handler here so that it will be defined before # the default key-press handler, and so will have higher priority. self.keypress_handler = self.sourceview.connect( 'key-press-event', self.on_keypress) self.sourceview.handler_block(self.keypress_handler) self.keypress_handler_blocked = True
def __init__(self, fb): self.needsReboot = [] self.xserver_pid = fb.xserver_pid self.wm_pid = fb.wm_pid self.doReconfig = fb.doReconfig self.doDebug = fb.doDebug self.lowRes = fb.lowRes self.autoscreenshot = fb.autoscreenshot self.moduleList = [] self.moduleDict = {} self.pageHistory = [] self.nextPage = None # Create the initial window and a vbox to fill it with. self.win = gtk.Window() self.win.set_position(gtk.WIN_POS_CENTER) self.win.set_decorated(False) if not self.doReconfig: self.win.set_keep_below(True) self.x_screen = gtk.gdk.screen_width() self.y_screen = gtk.gdk.screen_height() # Create a box that will hold all other widgets. self.mainHBox = gtk.HBox(False, 10) # leftVBox holds the labels for the various modules. self.leftVBox = gtk.VBox() self.leftVBox.set_border_width(5) # leftEventBox exists only so we have somewhere to paint an image. self.leftEventBox = gtk.EventBox() self.leftEventBox.add(self.leftVBox) self.leftEventBox.connect("realize", self.leb_realized) # rightVBox holds the notebook and the button box. self.rightVBox = gtk.VBox() self.rightVBox.set_border_width(5) # If we're in low res mode, grow the right hand box to take up the # entire window. if self.x_screen >= 800: self.leftEventBox.set_size_request(int(0.2 * self.x_screen), self.y_screen) self.rightVBox.set_size_request(int(0.8 * self.x_screen), self.y_screen) self.win.fullscreen() else: self.rightVBox.set_size_request(self.x_screen, self.y_screen) self.win.set_size_request(self.x_screen, self.y_screen) self.lowRes = 1 # Create a button box to handle navigation. self.buttonBox = gtk.HButtonBox() self.buttonBox.set_layout(gtk.BUTTONBOX_END) self.buttonBox.set_spacing(10) # Create the "go back" button, marking it insensitive by default. self.backButton = gtk.Button(use_underline=True, stock='gtk-go-back', label=_("_Back")) self.backButton.set_sensitive(False) self.backButton.connect('clicked', self.backClicked) self.buttonBox.set_border_width(10) self.buttonBox.pack_start(self.backButton) # Create the "go forward" button. self.nextButton = gtk.Button(use_underline=True, stock='gtk-go-forward', label=_("_Forward")) self.nextHandler = self.nextButton.connect('clicked', self.nextClicked) self.buttonBox.pack_start(self.nextButton) # Create the notebook. We use a ListView to control which page in the # notebook is displayed. self.notebook = gtk.Notebook() if self.doDebug: #self.modulePath = ('/usr/src/rhn/up2date/firstboot') self.modulePath = ('/usr/share/firstboot/modules') self.notebook.set_show_tabs(False) self.notebook.set_scrollable(True) self.notebook.set_show_border(False) else: self.modulePath = ('/usr/share/firstboot/modules') self.notebook.set_show_tabs(False) self.notebook.set_show_border(False) self.notebook.connect("switch-page", self.switchPage) sys.path.append(self.modulePath) self.loadModules() self.notebook.set_current_page(0) self.setPointer(0) # Add the widgets into the right side. self.rightVBox.pack_start(self.notebook) self.rightVBox.pack_start(self.buttonBox, expand=False) # Add the widgets into the main widget. if not self.lowRes: self.mainHBox.pack_start(self.leftEventBox) self.mainHBox.pack_start(self.rightVBox) self.win.add(self.mainHBox) self.win.connect("destroy", self.destroy) self.winHandler = self.win.connect("key-release-event", self.keyRelease) # This should really be in firstboot.py, but something about # importing all the modules screws the keyboard up only when we # start from rhgb. So here it is. if not fb.doDebug: from rhpl.keyboard import Keyboard kbd = Keyboard() kbd.read() kbd.activate() self.win.show_all() self.win.present() self.nextButton.grab_focus() gtk.main()
def __init__(self): #Vetana - - - - - self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_resizable(False) self.window.set_title("Temas del Burg") self.window.set_position(gtk.WIN_POS_CENTER) self.window.set_border_width(0) self.window.set_size_request(550, 540) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_icon_from_file('/usr/share/pixmaps/canaima-burg-icon.png') #Contenedor - - - - - self.fixed = gtk.Fixed() #Etiqueta Descripción - - - - - self.label_description = gtk.Label() self.label_description.set_markup( "Modifica los temas existentes del burg.") self.fixed.put(self.label_description, 130,10) self.label_description.show() #Etiqueta tema - - - - - self.label_tema_selec= gtk.Label() self.label_tema_selec.set_markup( "Seleccione el Thema : ") self.fixed.put(self.label_tema_selec, 110, 50) self.label_tema_selec.show() #Pestaña desplegable - - - - - ruta_burg = next(os.walk(self.RUTA_BUG))[1] ruta_burg.sort(key=lambda x: x.upper()) self.combox_themas = gtk.combo_box_new_text() self.combox_themas.set_size_request(180, 35) for datos_ruta in ruta_burg: if datos_ruta == "icons" or datos_ruta == "conf.d" or datos_ruta == "burg" or datos_ruta == "radiance": False else: self.combox_themas.append_text(datos_ruta) self.fixed.put(self.combox_themas, 280, 40) self.combox_themas.show() self.combox_themas.connect('changed', self.emulando_thema_burg) #Imagen Monitor - - - - - self.image_pc = gtk.Image() self.image_pc.set_from_file(self.MONITOR_IMG) self.fixed.put(self.image_pc, 54, 90) self.image_pc.show() #Boton Aplicar - - - - - self.button_aplicar = gtk.Button(stock=gtk.STOCK_APPLY) self.button_aplicar.set_size_request(80, 30) self.button_aplicar.connect("clicked",self.aplicar_thema_burg) self.fixed.put(self.button_aplicar, 460,500) self.button_aplicar.show() #~ #Boton Atras - - - - - #~ self.button_atras = gtk.Button(stock=gtk.STOCK_GO_BACK) #~ self.button_atras.set_size_request(80, 30) #~ self.button_atras.connect("clicked",self.atras_inicio) #~ self.fixed.put(self.button_atras, 370,500) #~ self.button_atras.show() #Boton Ayuda - - - - - self.button_ayuda = gtk.Button(stock=gtk.STOCK_HELP) self.button_ayuda.set_size_request(70, 30) self.button_ayuda.connect("clicked",self.ayuda_thema_burg) self.fixed.put(self.button_ayuda, 110,500) self.button_ayuda.show() #Boton Cerrar - - - - - self.button_cerrar = gtk.Button(stock=gtk.STOCK_QUIT) self.button_cerrar.set_size_request(80, 30) self.button_cerrar.connect("clicked",self.destroy) self.fixed.put(self.button_cerrar, 15,500) self.button_cerrar.show() #WebKit - - - - self.view = webkit.WebView() self.window.add(self.fixed) self.window.show_all() self.window.show()
def test_constructor(self): m = hildon.FileSystemModel(root_dir="/") d = hildon.FileChooserDialog(gtk.Window(), gtk.FILE_CHOOSER_ACTION_OPEN, m) self.assertTrue(isinstance(d, hildon.FileChooserDialog))
def main(): PY2 = sys.version_info[0] == 2 if PY2: import gtk w = gtk.Window(gtk.WINDOW_TOPLEVEL) w.set_default_size(499, 316) w.set_title("xterm size hints") w.connect("delete_event", gtk.main_quit) da = gtk.DrawingArea() w.add(da) hints = { "min_width": 25, "min_height": 17, "base_width": 19, "base_height": 4, "width_inc": 6, "height_inc": 13, } w.set_geometry_hints(None, **hints) else: import gi gi.require_version('Gdk', '3.0') gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk w = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) w.set_default_size(499, 316) w.set_title("xterm size hints") w.connect("delete_event", Gtk.main_quit) da = gtk.DrawingArea() w.add(da) geom = Gdk.Geometry() wh = Gdk.WindowHints geom.min_width = 25 geom.min_height = 17 geom.base_width = 19 geom.base_height = 4 geom.width_inc = 6 geom.height_inc = 13 mask = wh.MIN_SIZE | wh.BASE_SIZE | wh.RESIZE_INC if sys.platform.startswith("linux"): geom.max_width = 32767 geom.max_height = 32764 mask |= wh.MAX_SIZE gdk_hints = Gdk.WindowHints(mask) w.set_geometry_hints(None, geom, gdk_hints) gtk = Gtk def configure_event(w, event): #print("configure_event(%s, %s)" % (w, event)) print("event geometry: %s" % ((event.x, event.y, event.width, event.height), )) if PY2: gdkwindow = w.get_window() x, y = gdkwindow.get_origin() else: gdkwindow = da.get_window() x, y = gdkwindow.get_origin()[1:] w, h = w.get_size() print("drawing area geometry: %s" % ((x, y, w, h), )) w.connect("configure_event", configure_event) w.show_all() gtk.main()