Giuseppe Penone | 20 May 17:49
Picon
Gravatar

shrink window to minimum size when some child widgets are hidden

Hi,
It happens to me many times that after hiding some widgets in the window, the window keeps the original size
leaving part of the window with just window background (gray) visible.
I'm searching for a solution, but had no luck so far.
Does anybody know how to behave to have the window to shrink to minimum size given the actual displayed widgets?

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Andreas Heinlein | 16 May 10:08
Picon
Favicon

gtk.SpinButton - weird behaviour

Hello,

we have a GTK2 python app which uses a gtk.SpinButton with a precision 
of 1, i.e. numbers like 1234.5. This widget behaves oddly when trying to 
enter values directly with the keyboard. It is difficult to describe; 
when you click the field and enter some digits, only the first is 
accepted, then the marker jumps to the end of the field (after the 
decimal digit) where you cannot enter anything. You can move the mark 
manually again and enter some more digits. It just isn't possible to 
click the field once and enter "1234.5" like it should.

Is this a known GTK problem/bug? We're using GTK 2.20. The spinButton is 
configured with digits=1, numeric=True, snap-to-ticks=False, 
alignment=1, increments=0.1,10.

Thanks,
Andreas
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Stuart Axon | 9 May 13:49
Picon
Favicon

Porting to gobject and pygi questions?

Hello All,

  Appologies for asking on the pygtk list but -

I'm starting to port my app from pygtk to pygobject and running up against various problems... however I can't work out where to ask questions about pygi - the bugtracker on gnome says it's closed and I can't find a mailinglist for it (!)
 
S++
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
cwr | 7 May 17:26
Picon
Favicon

PyGTK Windows debugging.

I usually debug PyGTK programs in the first instance
by starting them from a terminal and reading any error
messages written to stdout.  This works on Linux, but
apparently not on Windows, and for some reason I can't
find a clear Windows equivalent.

What's the usual way of getting error messages out of
a GUI under Windows?  Do I have to open a second window
and feed the messages across with eg. a pipe?

Thanks for any ideas - Will

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Mark Summerfield | 27 Apr 11:00

Questions about PyGObject

Hi,

I hope this is the right list for PyGObject?
(If not, please ignore the rest and tell me what the right one is!)

I want to use PyGObject to create some GUI applications using Python 3.1
and Gtk 3.

And I want to test the applications against Python 3.1, 3.2, 3.3, ... on
Linux, Windows, and Mac OS X.

On the plus side, Fedora 16 and Ubuntu 11 both provide packages for
Python 3.2 + PyGObject + Gtk 3, so I can create the applications.

I have locally built and installed versions of Python 3.1, 3.2 (and soon
3.3), but have not been able to install PyGObject with any of them. Has
anyone done this who can point me to or provide (simple!) instructions?

I tried using jhbuild as per http://live.gnome.org/PyGObject It
wouldn't build gnome-doc-utils so I told it to skip that; but it also
failed to build glib so there was no point in continuing. Strangly it
looked like a Python 2 vs. Python 3 problem.

Also, there only seem to be Windows binaries for Python 2 (and they are
all a year old); and none for Python 3. At least not where I looked:
http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.28/

Thanks!

--

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
	"Programming in Python 3" - ISBN 0321680561
            http://www.qtrac.eu/py3book.html
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Lion Chen | 25 Apr 09:33
Picon

gtk.TreeView displays all right on Windows, but can't see the values on Ubuntu(sry, i don't know why the indentation became a mess last time )

Sorry, every time i finish writing an email which has codes in, the indentation no problem, but when i send
it, i found it becomes a mess....

so i have to send it again

Hi, All,
first thanks the people who gave helps to me, 

now i encountered another question...
my first program LionCalculator, works ok on Windows, but there is a
problem on Ubuntu.

LionCalculator has a function that can store the previous calculation
results to the gtk.ListStore.

when pressing F1--F12 or clicking the gtk.CellRendererRadio, the gtk.Entry
will get the corresbonding values stored in ListStore.

when i run the program on Windows, no problem, i can see everything that
should display on the screen. but when i run it on Ubuntu, i can't see
the "F1" -- "F12" in the ListStore, can't see the calculation results
that should also display on ListStore, only the gtk.CellRendererRadio
showed. i don't understand...

and when i add "print ...get_store()[0][0]" and run it again, it print
"F1"! strange... and when i press F1 or F2..., the result will copy to
the entry, although it does not display in the TreeView, strange...

the following are codes:

#in class ResultsView......
def make_view(self):
    # make ListStore for storing results
    self.results_store = gtk.ListStore(gobject.TYPE_STRING,
                                       gobject.TYPE_BOOLEAN,
                                       gobject.TYPE_STRING)

    #to store 12 calculation results, "F1"--"F2" will show
    #in the 1st column
    for i in xrange(12):
        self.results_store.append(["F%d" % (i+1), None, None])

    self.results_view = gtk.TreeView(self.results_store)

    #f_renderer is for "F1" -- "F12"
    f_renderer = gtk.CellRendererText()
    f_renderer.set_property( 'editable', False )
    f_renderer.set_property("size", 5)
    f_renderer.set_property("cell-background", "cyan")

    #when clicked bt_renderer, it will copy the 
    #corresbonding values to gtk.Entry    
    bt_renderer = gtk.CellRendererToggle()
    bt_renderer.set_property('activatable', True)
    bt_renderer.set_property("radio", True)
    bt_renderer.set_property("cell-background", "grey")
    bt_renderer.connect("toggled", self.ready_cp, self.results_store)

    #txt_renderer is for storing calculation results
    txt_renderer = gtk.CellRendererText()
    txt_renderer.set_property( 'editable', False )
    txt_renderer.set_property("size", 5)
    txt_renderer.set_property("cell-background", "green")

    #i guess the problem is in the following, but i don't know where it
    #exactly is, ok in Windows, can't show in Ubuntu...

    bt_column = gtk.TreeViewColumn("F1--F12")
    bt_column.pack_start(f_renderer, True)
    bt_column.pack_start(bt_renderer, False)
    bt_column.set_attributes(f_renderer, text=0)
    bt_column.add_attribute(bt_renderer, "active", 1)

    
    txt_column = gtk.TreeViewColumn("Calculation Results ", 
                                    txt_renderer,
                                    text=2)

    self.results_view.append_column(bt_column)
    self.results_view.append_column(txt_column)

    self.results_view.show()

    return self.results_view

#in class LionCalc....
    def __init__(self):
    ......
    self.results_view = ResultsView()
    right_vbox.pack_start(self.results_view.make_view(), True, True, 0)

    win.show_all()

could anybody give me help? thanks.

--

-- 
Lion Chen

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Lion Chen | 25 Apr 06:41
Picon

gtk.TreeView displays all right on Windows, but can't see the values on Ubuntu

Hi, All,
first thanks the people who gave helps to me, :)

now i encountered another question...
my first program LionCalculator, works ok on Windows, but there is a
problem on Ubuntu.

LionCalculator has a function that can store the previous calculation
results to the
gtk.ListStore((gobject.TYPE_STRING, gobject.TYPE_BOOLEAN,
gobject.TYPE_STRING))

for i in xrange(12):
self.results_store.append(["F%d" % (i+1), None, None])

when pressed F1--F12 or click the gtk.CellRendererRadio, the gtk.Entry
will get the corresbonding values stored in ListStore.

when i run the program on Windows, no problem, i can see everything that
should display on the screen. but when i run it on Ubuntu, i can't see
the "F1" -- "F12" in the ListStore, can't see the calculation results
that should also display on ListStore, only the gtk.CellRendererRadio
showed.
i don't understand...

and when i add "print ...get_store()[0][0]" and run it again, it print
"F1"! strange... and when i press F1 or F2..., the result will copy to
the entry,
although it does not display in the TreeView, strange...

the following are codes:

#in class ResultsView......
def make_view(self):
# make ListStore for storing results
self.results_store = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_BOOLEAN,
gobject.TYPE_STRING)

#to store 12 calculation results, the results_store[0][0] is "F1--F12"
for i in xrange(12):
self.results_store.append(["F%d" % (i+1), None, None])

self.results_view = gtk.TreeView(self.results_store)

#f_renderer is for "F1" -- "F12"
f_renderer = gtk.CellRendererText()
f_renderer.set_property( 'editable', False )
f_renderer.set_property("size", 5)
f_renderer.set_property("cell-background", "cyan")

#when clicked bt_renderer, it will copy the corresbonding values to
gtk.entry
bt_renderer = gtk.CellRendererToggle()
bt_renderer.set_property('activatable', True)
bt_renderer.set_property("radio", True)
bt_renderer.set_property("cell-background", "grey")
bt_renderer.connect("toggled", self.ready_cp, self.results_store)

#txt_renderer is for storing calculation results
txt_renderer = gtk.CellRendererText()
txt_renderer.set_property( 'editable', False )
txt_renderer.set_property("size", 5)
txt_renderer.set_property("cell-background", "green")

#i guess the problem is in the following, but i don't know where it
exactly is, ok in Windows, can't show in Ubuntu...
bt_column = gtk.TreeViewColumn("F1--F12")
bt_column.pack_start(f_renderer, True)
bt_column.pack_start(bt_renderer, False)
bt_column.set_attributes(f_renderer, text=0)
#set active to be clickable. and the bt_columen is
#corresbonding to results_store columne 1
bt_column.add_attribute(bt_renderer, "active", 1)

#and txt_column is corresbonding to the store column 2
txt_column = gtk.TreeViewColumn("Calculation Results ", txt_renderer,
text=2)
self.results_view.append_column(bt_column)
self.results_view.append_column(txt_column)

self.results_view.show()

return self.results_view

#in class LionCalc....
def __init__(self):
......
self.results_view = ResultsView()
right_vbox.pack_start(self.results_view.make_view(), True, True, 0)

win.show_all()

could anybody give me help? thanks.

--

-- 
Lion Chen

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Lion Chen | 23 Apr 13:25
Picon

why gtk.Entry does not give me right answers?

Hi, All,

i am trying write a calculator, now normal calculation works ok. but if
i enter long numbers, for example 333333333333333333 + 7, it gives me
"333333333333333312".....

there are 18 "3"s, if the length is more than 17, the calculation will
be wrong on Windows and Ubuntu.

the following is some of my codes:

def pre_calc(self, op):
#if entry is empty, any operators are invalid except "-"
if not self.entry.get_text() and op != "-":
return

if not self.entry.get_text() and op == "-":
self.entry.set_text(op)
self.cleared = 1
self.negative_sign = True#indicates there's already a "-"
return

#retrieve the 1st num and operator
if not self.op and self.entry.get_text():
if op != "=":
self.op = op
#print "text typ:", type(self.entry.get_text())
self.first_num = self.entry.get_text()
self.cleared = 0 # ready to input 2nd num
#print "op:", self.op, "-----", "1st num:", self.first_num
return
else:
self.first_num = None
self.second_num = None
self.op = None
self.cleared = 0
self.negative_sign = False
return

#retrieve the second num and begin calculation
elif self.op and self.first_num and self.entry.get_text() != "-":
if op == "=":
self.second_num = self.entry.get_text()
self.calc()
#reset the following varibles, awaiting next round of inputs
self.first_num = None
self.second_num = None
self.op = None
self.cleared = 0
self.negative_sign = False
return
elif op == "-":
if self.cleared == 1: #if user has input 2nd num already
self.second_num = self.entry.get_text()
self.calc()
self.first_num = self.entry.get_text()
self.op = op
self.cleared = 0
self.negative_sign = False
return
else:
self.entry.set_text(op)
self.cleared = 1
self.negative_sign = True#indicates there's already a "-"
return
else:
self.op = op
if self.cleared == 1:
self.second_num = self.entry.get_text()
self.calc()
self.first_num = self.entry.get_text()
self.cleared = 0
self.negative_sign = False
return
else:
return

def calc(self, unary_op = None):
if not unary_op:
if (not self.first_num) or (not self.second_num) or \
(not self.op):
return

result = None

calc_methods = {"+": self.add,
"-": self.subtract,
"*": self.multiply,
"/": self.divide,
"%": self.mod,
"pwr": self.power,
"|": self.b_or,
"&": self.b_and,
"^": self.b_exc,
"<<": self.b_lshift,
">>": self.b_rshift
}

unary_methods ={"~": self.b_invert,
"1/x": self.a_fraction,
"sqrt": self.sqrt
}

if not unary_op:
for op, method in calc_methods.items():
if self.op == op:
result = calc_methods[op]()
else:
for op, method in unary_methods.items():
if unary_op == op:
result = unary_methods[op]()

self.entry.set_text(result)

def add(self):
result = None
#if hex system
#print type(self.first_num)
if self.hdob["h"].get_active():
self.first_num = long(self.first_num, 16)
self.second_num = long(self.second_num, 16)
r = self.first_num + self.second_num

r = self.convert.d2h(r)

return r

#if decimal system
elif self.hdob["d"].get_active():
self.first_num = float(self.first_num)
self.second_num = float(self.second_num)
result = self.first_num + self.second_num

if result - long(result) == 0:
#print str(long(result))
return str(long(result))
else:
return str(result)

#if octal system
elif self.hdob["o"].get_active():
self.first_num = long(self.first_num, 8)
self.second_num = long(self.second_num, 8)
result = self.first_num + self.second_num

result = self.convert.d2o(result)

return result

else:
self.first_num = long(self.first_num, 2)
self.second_num = long(self.second_num, 2)
result = bin(self.first_num + self.second_num)

result = self.convert.d2b(result)

return result
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Pierre Barthelemy | 23 Apr 12:44
Picon

gobject.connect

Hi everyone,


I am new to this mailing list. I am working on a program to perform data analysis in python. This program is based on a library already developped, that uses pygtk to create data-handling objects. 
This data object inherits from gobject.GObject, and defines a few signals "new-data-point".

I would like to connect this signal to a few functions, specifying the arguments of these functions. I have read the PyGTK webpage (http://www.pygtk.org/docs/pygobject/class-gobject.html#method-gobject--connect), which specifies that i just have to concatenate in the "connect" call the arguments: "object.connect("signal_name",handler,arg1,arg2,arg3)

I therefore have written: 

data.connect("new-data-point", handler,'text')


and defined the handler function as suggested: def handler(object,arg1,arg2,arg3)

def handler(data,argument):
    print data
    print argument

However, when i do execute the "connect" function, i get the error message: 
"connect takes exactly 3 arguments (4 given). 

Could you tell me how i could then specify arguments for the functions to be called when the signal is given ? 

Bests,

Pierre
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
zahra rokni | 23 Apr 08:14
Picon
Favicon

gtk.window hide by closing trash

hi all
i have an pygtk application. i run it full screen  in the gnome start-up. when i open trash and close it, application will be hide! i know it is running yet but didn't show.  this problem only occur with trash not another nautilus windows or other applications.
do you have any suggestion why this problem happen?
tanks
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Chen Lion | 20 Apr 16:40
Picon

How to set a wiget, eg a button size?

Hi All,
       when i put some buttons in a hbutton box, the hbutton box becomes very long....
       i don't know how to set a button size, set_size_request has no effect....

       could anybody help me how to set the size for widgets?
       thanks

      Lion

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Gmane