pygtk

python locale for gtk does not work on windows

安稳与你 提交于 2019-12-03 16:31:04
I have python 2.7 and pygtk. I am trying to set locale language for gtk in my application but no luck. My windows is in slovak language and I would like to have button labels in my app in english. How to solve it? I tried this but no luck (all labels are still in slovak): import os os.environ['LANGUAGE'] = 'en_US' #tried en_UK as well os.environ['LANG'] = 'en_US' os.putenv('en_US', 'LANG') import locale locale.setlocale(locale.LC_ALL, 'English_United Kingdom.1252' ) but when I make cmd file this works: set LANG=en_US something.exe what am I doing wrong? This is becoming a common question these

higher level Python GUI toolkit, e.g. pass dict for TreeView/Grid

筅森魡賤 提交于 2019-12-03 16:03:46
Started my first Python pet project using PyGTK. Though it is a really powerful GUI toolkit and looks excellent, I have some pet peeves. So I thought about transitioning to something else, as it's not yet too extensive. Had a look around on SO and python documentation , but didn't get a good overview. What's nice about PyGTK: Glade files self.signal_autoconnect({...}) self.get_widget() as __getattr__ This is bugging me however: manual gobject.idle_add(lambda: ... and False) no standard functionality to save application/window states TreeView needs array building widget.get_selection().get

GTK: create a colored regular button

僤鯓⒐⒋嵵緔 提交于 2019-12-03 15:23:41
How do I do it? A lot of sites say I can just call .modify_bg() on the button, but that doesn't do anything. I'm able to add an EventBox to the button, and add a label to that, and then change its colors, but it looks horrendous - there is a ton of gray space between the edge of the button that doesn't change. I just want something that looks like this: (source: kksou.com ) The site claims to have just done modify_bg() on the button. But that doesn't work for me. =(. The right answer probably involves creating a style, or something with a gtkrc file, etc. Can someone point me in that direction

A sorted and filtered treemodel in Python Gtk+3..?

痞子三分冷 提交于 2019-12-03 14:34:10
I am trying to get a treemodel (a liststore in fact) that can be filtered and also sorted. I have the following piece of code self.modelfilter = self.liststore.filter_new() self.modelfilter.set_visible_func(\ self._visible_filter_function) self.treeview.set_model(self.modelfilter) where self.liststore and self.treeview are standard Gtk.ListStore and Gtk.TreeView objects that I get from a glade file, and self._visible_filter_function is a filtering function. The problem is that self.modelfilter does not seem to be sortable. When I click on the column headers (of the columns in self.treeview )

Periodically call a function in pygtk's main loop

…衆ロ難τιáo~ 提交于 2019-12-03 13:53:10
What's the pygtk equivalent for after method in tkinter? I want to periodically call a function in the main loop. What is the better way to achieve it? Use gobject.timeout_add : import gobject gobject.timeout_add(milliseconds, callback) For example here is a progress bar that uses timeout_add to update the progress ( HScale ) value: import gobject import gtk class Bar(object): def __init__(self,widget): self.val=0 self.scale = gtk.HScale() self.scale.set_range(0, 100) self.scale.set_update_policy(gtk.UPDATE_CONTINUOUS) self.scale.set_value(self.val) widget.add(self.scale) gobject.timeout_add

Right Click Menu (context menu) using PyGTK

自作多情 提交于 2019-12-03 12:48:28
So I'm still fairly new to Python, and have been learning for a couple months, but one thing I'm trying to figure out is say you have a basic window... #!/usr/bin/env python import sys, os import pygtk, gtk, gobject class app: def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("TestApp") window.set_default_size(320, 240) window.connect("destroy", gtk.main_quit) window.show_all() app() gtk.main() I wanna right click inside this window, and have a menu pop up like alert, copy, exit, whatever I feel like putting down. How would I accomplish that? There is a example for

How to have drag-and-drop and sorted GtkTreeView in GTK3?

柔情痞子 提交于 2019-12-03 10:55:32
I am porting liblarch , a library for handling directed acyclic graphs, from PyGTK (GTK2) to PyGObject introspection (GTK3). I ran into the problem with GtkTreeView. The app using liblarch needs to sort GtkTreeView by a column but in the same time, the user can drag-and-drop rows, move a row under another row. For that I had to manually process dnd_data_get() and dnd_data_receive() which is perfectly okay. There is the minimal setup for GtkTreeView which works under PyGTK. Rows are sorted and the user can move rows around. #!/usr/bin/python # -*- coding: utf-8 -*- import gtk window = gtk

Displaying PDF files with python3

老子叫甜甜 提交于 2019-12-03 09:34:52
问题 I want to write a python3/PyGTK3 application that displays PDF files and I was not able to find a python package that allows me to do that. There is pypoppler, but it looks outdated (?) and does not seem to support python3 (?) Do you have any suggestions? EDIT: Note, that I don't need fancy features, like pdf forms, manipulation or writing. 回答1: It turns out, that newer versions of poppler-glib don't require bindings as such. They ship with GObject Introspection files and can therefore be

What's the recommended way to unittest Python GUI applications?

岁酱吖の 提交于 2019-12-03 08:08:48
问题 I'm currently foolish enough to try to maintaintain two parallel code bases for a Python desktop application, one using PyGObject introspection for GTK 3 and one using PyGTK for GTK 2. I work mainly on the PyGObject branch and then I port changes over to the PyGTK branch. Due to all the minor differences between these implementations, I often overlook things and cause breakage that I miss and accidentally release, only to be caught by the users. I'm trying to figure out a good way to design

putting glade interface in python

百般思念 提交于 2019-12-03 06:27:55
I've made a gui in glade that I want to put in a python program. I was adapting the instructions from a tutorial I found online to load in my glade file (http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm). When I had problems I tried something basic (one button) calling it the same thing as in that tutorial, and copy pasting their code, and it still didn't work. I also took a look at (http://www.linuxjournal.com/article/6586?page=0,2), which has a function being called slightly differently ("self.wTree=gtk.glade.XML (gladefile,windowname)" instead of