gtk3

Adding an icon to a ToolButton in Gtk 3

蓝咒 提交于 2019-12-06 08:09:13
Is there a way to add an icon to a Gtk.ToolButton (Gtk3 using PyGi for Python) to add to the GTK+3 toolbar ? Below is my code: self.addfile = Gtk.ToolButton() self.addfile.set_label("Add File") self.addfileimg = Gtk.Image() self.addfileimg.show() self.addfileimg.set_from_file(self.get_resource("img/file.png")) self.addfile.set_icon_widget(self.addfileimg) self.addfile.connect("clicked", self.on_open_file) Note: The get_resource() method digs into the local working folder for the resource path and this method is assumed working in this context. I tried the code written above using PyGi. The

Creating print job in gtk3/python

别来无恙 提交于 2019-12-06 07:30:38
I have some information (a list of participants to an event) which I want to print out easily. No need for fancy layout, just a table with several columns, and if possible a drawn line in between the lines of text for better readability. Will need to print landscape to make it all fit (can be done via a GtkPageSetup). I'm using Python, and I'm on Linux so will have to use the GtkPrintUnixDialog interface. I've been searching on Internet but can't find any example on how this could possibly be achieved. To simplify the problem: it's for my own use only, so known paper size (A4). The problem

Window freezes after clicking of button in python GTK3

*爱你&永不变心* 提交于 2019-12-06 05:17:25
Hello I have some command, which runs for average 30 min, when I click on button created by GTK3, python starts to executing command but my all application freezes. My python code for button clicked is: def on_next2_clicked(self,button): cmd = "My Command" proc = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE) while True: line = proc.stdout.read(2) if not line: break self.fper = float(line)/100.0 self.ui.progressbar1.set_fraction(self.fper) print "Done" I also have to set output of command to progress bar in my window. Can any one help to solve my problem ? I also tried with Threading

Python GTK3 Treeview Move Selection up or down

夙愿已清 提交于 2019-12-06 02:10:01
How do I move a selection up or down in a Treeview? The idea is that I can have an up and down buttons to move the selection up a row or down a row. My Treeview is using a ListStore. Not sure if that matters. First off, I will be using C code as that's what I'm familiar with. Should you have problems translating it to Python, then say so, and I will do my best to help. The class you want to use for this is GtkTreeSelection . Basically, what you do is: Get the selection object of the view ( gtk_tree_view_get_selection ) Get the currently selected GtkTreeIter ( gtk_tree_selection_get_selected ).

unresponsive drag and drop in pygobject

只谈情不闲聊 提交于 2019-12-06 01:59:19
im trying to get drag and drop working well in pygobject, but it is slow and unresponsive, 90% of the time i have to wave the item i am dragging around before i can drop it successfully, can anyone see if i am doing it incorrectly or is this a bug with pygobject? here is my code from gi.repository import Gtk, GdkPixbuf, Gdk import os def got_data_cb(windowid, context, x, y, data, info, time): # Got data. tempArray = data.get_text().splitlines() for i in tempArray: i = i.replace('file://','') print i windowid.get_model().append([i]) context.finish(True, False, time) def drop_cb(windowid,

How to write custom Gtk.CellRenderer in python and GTK 3?

匆匆过客 提交于 2019-12-06 01:33:29
问题 i must write my own cell renderer with button, i came up with this: #!/usr/bin/env python3 from gi.repository import Gtk class CellRendererButton(Gtk.CellRenderer): def __init__(self): Gtk.CellRenderer.__init__(self) def get_size(self, widget, cell_area): buttonHeight = cell_area.height buttonWidth = buttonHeight return (0, 0, buttonWidth, buttonHeight) def render(self, window, widget, background_area, cell_area, expose_area, flags): style = widget.get_style() x, y, buttonWidth, buttonHeight

PyCharm - autocomplete for Gtk3 magically stops working

回眸只為那壹抹淺笑 提交于 2019-12-06 00:58:34
问题 I have this weird problem - I'm learning Gtk3 on Windows 7 with PyCharm Community 3.4.1. When I try to import Gtk: from gi.repository import Gtk it underlines Gtk as unresolved reference, becouse it's a binary module. Then I press Alt+Enter and choose "Generate methon stubs for binary module..." and wait until it it finishes indexing. Then I happily write this simple empty window with autocomplete working correctly: class Okienko(Gtk.Window): def __init__(self): Gtk.Window.__init__(self,

How to use CssStyleProvider in Gtkmm3

会有一股神秘感。 提交于 2019-12-05 21:52:26
问题 I'm programming in c++ with gtkmm3. I want to change some fonts in my program. I read all the things about CssStyleProvider, StyleContext in gtkmm documentation and also in gtk+ documentaion but i couldn't make it work and couldn't find any tutorial about that. I'm trying like that Glib::ustring data; data="GtkMenuBar, GtkMenuItem {font-name: Sans 6}"; /*tried with semi-colon, too*/ Glib::RefPtr<Gtk::CssProvider> asd = Gtk::CssProvider::create(); Glib::RefPtr<Gtk::StyleContext> asd2 = Gtk:

How to include resources file in anjuta project

纵然是瞬间 提交于 2019-12-05 21:49:18
I'm trying to update a graphical project in vala, moving lot of code lines into an ui file. I want to use template (available with glib-2.38 and GTK+3.8, something like that). My project is managed with Anjuta and autoconf. In the src directory there are application.ui : <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.8 --> <template class="SpiWindow" parent="GtkApplicationWindow"> <property name="title" translatable="yes">Example Application</property> <property name="default-width">600</property> <property name="default-height">400</property> <child>

How to left align a Gtk Label when its width is set by GtkSizeGroup

你说的曾经没有我的故事 提交于 2019-12-05 21:38:36
I have labels that should be left aligned and should all have the same width. I'm using a GtkSizeGroup to achieve the sizing (because the labels don't all have the same parent). Unfortunately this seems to break alignment: With the below code the labels align horizontally in the middle even though I ask for GTK_ALIGN_START . If I remove the sizegroup the labels align to start as they should. /* gcc `pkg-config --libs --cflags gtk+-3.0` label-align-test.c */ #include <gtk/gtk.h> int main(int argc, char **argv) { GtkSizeGroup *group; GtkWidget *window, *grid, *label1, *label2; gtk_init (&argc,