piotr maliński | 1 Dec 2008 08:59
Picon

Re: PyQt4-extrawidgets project

~~ Update ~~

QTermWdiget fixed no-resize bug
QfMacNavBar - added missing methods

Those two widgets are "done". and should work without problems. Some more to come.

http://code.google.com/p/pyqt4-extrawidgets/


W dniu 12 listopada 2008 11:10 użytkownik piotr maliński <riklaunim <at> gmail.com> napisał:
Thanks for the help. I fixed the code and commited to trunk

2008/11/12, Jim Bublitz <jbublitz <at> nwinternet.com>:
> On Tuesday 11 November 2008 09:04, piotr maliński wrote:
>  > I've started a project at code.google.com that contains all PyQt4
>  > widgets made by me with the help of SIP.
>  >
>  > http://code.google.com/p/pyqt4-extrawidgets/
>  >
>  > Currently there are two widgets: QTermWidget and qt-macnavbar
>  > (screenshot:
>  > http://www.fotosik.pl/pokaz_obrazek/pelny/cb4b8531394f7906.html). Both do
>  > work, but some small issues still remain that I have to fix. QTermWidget
>  > doesn't want to resize (I'll have to probably bind all core header files
>  > for it), and Qf-MacNavBar has few methods/properties commented out (but it
>  > works).
>  >
>  > SIP doesn't like such code:
>  > ##############
>  > QString title (void) const;
>  > bool isExpanded (void) const;
>  > ##############
>  >
>  > as it says: sip: QfNavBarGroup::title() unsupported function argument
>  > type - provide %Method code and a valid C++ signature. I'm not a
>  > C/C++/SIP guru so I can't fix this. Any solutions welcomed.
>
>
> Remove the 'void' in each function declaration (in the sip file - in the h
>  file it makes no difference)..
>
>
>  Jim
>
>
>  _______________________________________________
>  PyQt mailing list    PyQt <at> riverbankcomputing.com
>  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>

<div>
<p>~~ Update ~~<br><br>QTermWdiget fixed no-resize bug<br>QfMacNavBar - added missing methods<br><br>Those two widgets are "done". and should work without problems. Some more to come.<br><br><a href="http://code.google.com/p/pyqt4-extrawidgets/">http://code.google.com/p/pyqt4-extrawidgets/</a><br><br><br></p>
<div class="gmail_quote">W dniu 12 listopada 2008 11:10 u&#380;ytkownik piotr mali&#324;ski <span dir="ltr">&lt;<a href="mailto:riklaunim <at> gmail.com">riklaunim <at> gmail.com</a>&gt;</span> napisa&#322;:<br><blockquote class="gmail_quote">
Thanks for the help. I fixed the code and commited to trunk<br><br>
2008/11/12, Jim Bublitz &lt;<a href="mailto:jbublitz <at> nwinternet.com">jbublitz <at> nwinternet.com</a>&gt;:<br><div>
<div></div>
<div class="Wj3C7c">&gt; On Tuesday 11 November 2008 09:04, piotr mali&#324;ski wrote:<br>
&gt; &nbsp;&gt; I've started a project at <a href="http://code.google.com" target="_blank">code.google.com</a> that contains all PyQt4<br>
&gt; &nbsp;&gt; widgets made by me with the help of SIP.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; <a href="http://code.google.com/p/pyqt4-extrawidgets/" target="_blank">http://code.google.com/p/pyqt4-extrawidgets/</a><br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Currently there are two widgets: QTermWidget and qt-macnavbar<br>
&gt; &nbsp;&gt; (screenshot:<br>
&gt; &nbsp;&gt; <a href="http://www.fotosik.pl/pokaz_obrazek/pelny/cb4b8531394f7906.html" target="_blank">http://www.fotosik.pl/pokaz_obrazek/pelny/cb4b8531394f7906.html</a>). Both do<br>
&gt; &nbsp;&gt; work, but some small issues still remain that I have to fix. QTermWidget<br>
&gt; &nbsp;&gt; doesn't want to resize (I'll have to probably bind all core header files<br>
&gt; &nbsp;&gt; for it), and Qf-MacNavBar has few methods/properties commented out (but it<br>
&gt; &nbsp;&gt; works).<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; SIP doesn't like such code:<br>
&gt; &nbsp;&gt; ##############<br>
&gt; &nbsp;&gt; QString title (void) const;<br>
&gt; &nbsp;&gt; bool isExpanded (void) const;<br>
&gt; &nbsp;&gt; ##############<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; as it says: sip: QfNavBarGroup::title() unsupported function argument<br>
&gt; &nbsp;&gt; type - provide %Method code and a valid C++ signature. I'm not a<br>
&gt; &nbsp;&gt; C/C++/SIP guru so I can't fix this. Any solutions welcomed.<br>
&gt;<br>
&gt;<br>
&gt; Remove the 'void' in each function declaration (in the sip file - in the h<br>
&gt; &nbsp;file it makes no difference)..<br>
&gt;<br>
&gt;<br>
&gt; &nbsp;Jim<br>
&gt;<br>
&gt;<br>
&gt; &nbsp;_______________________________________________<br>
&gt; &nbsp;PyQt mailing list &nbsp; &nbsp;<a href="mailto:PyQt <at> riverbankcomputing.com">PyQt <at> riverbankcomputing.com</a><br>
&gt; &nbsp;<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
&gt;<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
Phil Thompson | 1 Dec 2008 10:21

Re: Attribute error message

On Sun, 30 Nov 2008 23:16:18 +0100, "Filip Gruszczyński"
<gruszczy <at> gmail.com> wrote:
> Right now, when a Python object subclasses QObject and then casts
> Attribute error the message holds only the name of the attribute. This
> is a bit inconvenient, because you have to either check all possible
> classes from which that object was derived or put a print statement
> and rerun the program. For pure Python object there is information
> about the type of the object. Could the same be done for objects
> subclassing QObject or is it deliberately done this way, because it
> cannot be done otherwise?

It will be fixed in SIP v4.8.

Thanks,
Phil
Filip Gruszczyński | 1 Dec 2008 10:26
Picon

Re: Attribute error message

> Thanks,

I guess this should be my line, as it will make my debugging easier :)

--

-- 
Filip Gruszczyński

piotr maliński | 1 Dec 2008 11:23
Picon

Problem with UTF-8 files and QScintilla

I'm trying to use QScintilla with a file opened with QFile (and not Python functions). With files that contain ascii only characters it works, but for utf-8 files with non-ascii character it doesn't - the code snippet:
############################
self.ui.editor.setUtf8(True)
...
text =QtCore.QFile(url)
text.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text)
txt = QtCore.QString(text.readAll())
self.ui.editor.setText(txt)
text.close()
############################

If I use:
self.ui.editor.setText(txt.toUtf8())
QSci will thow exception (TypeError: argument 1 of QsciScintilla.setText() has an invalid type) as it wants QString and not QByteArray :) Is there a file encoding safe way to open a text file and pass it to QScintilla widget? I was using codecs and normal open with try/except - try another way/ solution but it was bit uggly, and had problems with some files encodings.

<div><p>I'm trying to use QScintilla with a file opened with QFile (and not Python functions). With files that contain ascii only characters it works, but for utf-8 files with non-ascii character it doesn't - the code snippet:<br>
############################<br>self.ui.editor.setUtf8(True)<br>...<br>text =QtCore.QFile(url)<br>text.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text)<br>txt = QtCore.QString(text.readAll())<br>self.ui.editor.setText(txt)<br>
text.close()<br>############################<br><br>If I use:<br>self.ui.editor.setText(txt.toUtf8())<br>QSci will thow exception (TypeError: argument 1 of QsciScintilla.setText() has an invalid type) as it wants QString and not QByteArray :) Is there a file encoding safe way to open a text file and pass it to QScintilla widget? I was using codecs and normal open with try/except - try another way/ solution but it was bit uggly, and had problems with some files encodings.<br></p></div>
Phil Thompson | 1 Dec 2008 12:05

Re: Problem with UTF-8 files and QScintilla

On Mon, 1 Dec 2008 11:23:38 +0100, "piotr maliński" <riklaunim <at> gmail.com>
wrote:
> I'm trying to use QScintilla with a file opened with QFile (and not
Python
> functions). With files that contain ascii only characters it works, but
for
> utf-8 files with non-ascii character it doesn't - the code snippet:
> ############################
> self.ui.editor.setUtf8(True)
> ...
> text =QtCore.QFile(url)
> text.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text)

Have you tried it without the Text flag?

> txt = QtCore.QString(text.readAll())
> self.ui.editor.setText(txt)
> text.close()
> ############################
> 
> If I use:
> self.ui.editor.setText(txt.toUtf8())
> QSci will thow exception (TypeError: argument 1 of
QsciScintilla.setText()
> has an invalid type) as it wants QString and not QByteArray :) Is there a
> file encoding safe way to open a text file and pass it to QScintilla
> widget?
> I was using codecs and normal open with try/except - try another way/
> solution but it was bit uggly, and had problems with some files
encodings.

You could also try QsciScintilla.read().

Note, QScintilla has its own mailing list.

Phil
piotr maliński | 1 Dec 2008 12:18
Picon

Re: Problem with UTF-8 files and QScintilla



2008/12/1 Phil Thompson <phil <at> riverbankcomputing.com>
On Mon, 1 Dec 2008 11:23:38 +0100, "piotr maliński" <riklaunim <at> gmail.com>
wrote:
> I'm trying to use QScintilla with a file opened with QFile (and not
Python
> functions). With files that contain ascii only characters it works, but
for
> utf-8 files with non-ascii character it doesn't - the code snippet:
> ############################
> self.ui.editor.setUtf8(True)
> ...
> text =QtCore.QFile(url)
> text.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text)

Have you tried it without the Text flag?


Removing it doesn't help

 

> txt = QtCore.QString(text.readAll())
> self.ui.editor.setText(txt)
> text.close()
> ############################
>
> If I use:
> self.ui.editor.setText(txt.toUtf8())
> QSci will thow exception (TypeError: argument 1 of
QsciScintilla.setText()
> has an invalid type) as it wants QString and not QByteArray :) Is there a
> file encoding safe way to open a text file and pass it to QScintilla
> widget?
> I was using codecs and normal open with try/except - try another way/
> solution but it was bit uggly, and had problems with some files
encodings.

You could also try QsciScintilla.read().

Note, QScintilla has its own mailing list.

Phil

Didn't seen that one ;)

I'll stick to codecs for now. Next will be detecting file encoding and encode the text accordingly so it would display correctly :)
<div>
<br><br><div class="gmail_quote">2008/12/1 Phil Thompson <span dir="ltr">&lt;<a href="mailto:phil <at> riverbankcomputing.com">phil <at> riverbankcomputing.com</a>&gt;</span><br><blockquote class="gmail_quote">
On Mon, 1 Dec 2008 11:23:38 +0100, "piotr mali&#324;ski" &lt;<a href="mailto:riklaunim <at> gmail.com">riklaunim <at> gmail.com</a>&gt;<br>
wrote:<br><div class="Ih2E3d">&gt; I'm trying to use QScintilla with a file opened with QFile (and not<br>
Python<br>
&gt; functions). With files that contain ascii only characters it works, but<br>
for<br>
&gt; utf-8 files with non-ascii character it doesn't - the code snippet:<br>
&gt; ############################<br>
&gt; self.ui.editor.setUtf8(True)<br>
&gt; ...<br>
&gt; text =QtCore.QFile(url)<br>
&gt; text.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text)<br><br>
</div>Have you tried it without the Text flag?<br><div class="Ih2E3d"></div>
</blockquote>
<div>
<br><br>Removing it doesn't help<br><br>&nbsp;</div>
<blockquote class="gmail_quote">
<div class="Ih2E3d">
<br>
&gt; txt = QtCore.QString(text.readAll())<br>
&gt; self.ui.editor.setText(txt)<br>
&gt; text.close()<br>
&gt; ############################<br>
&gt;<br>
&gt; If I use:<br>
&gt; self.ui.editor.setText(txt.toUtf8())<br>
&gt; QSci will thow exception (TypeError: argument 1 of<br>
QsciScintilla.setText()<br>
&gt; has an invalid type) as it wants QString and not QByteArray :) Is there a<br>
&gt; file encoding safe way to open a text file and pass it to QScintilla<br>
&gt; widget?<br>
&gt; I was using codecs and normal open with try/except - try another way/<br>
&gt; solution but it was bit uggly, and had problems with some files<br>
encodings.<br><br>
</div>You could also try QsciScintilla.read().<br><br>
Note, QScintilla has its own mailing list.<br><br>
Phil<br>
</blockquote>
</div>
<br>Didn't seen that one ;) <br><br>I'll stick to codecs for now. Next will be detecting file encoding and encode the text accordingly so it would display correctly :)<br>
</div>
piotr maliński | 1 Dec 2008 16:43
Picon

Introducing PyDingo

I've created a project called PyDingo, which is a PyQt4 application – file manager, text editor, and "more". The concept of the application is similar to Konqueror – a tabbed multi purpose app, but aside "basic" file/text management options it will allow creating widgets for other things for example display system stats with pystatgrab by typing url like "stats://" and so on – call a widget determined by URL.

It won't overcome existing applications like Kate, Konqueror, Dolphin, Nautilus, TextMate, Windows Commander etc. but it will be useful. The main goal of this application is to get to the useful stage – solving various problems (cross platform, feature implementation and so on) on the way (than can be nicely documented).

Current stage is very Alpha. I have to add few basic elements to get to 0.1, 0.2 stage from which more "fun" can be squeezed from PyDingo coding :) I'm looking for feedback about the code/used implementations and so on, especially when it stabilize a bit with 0.2 release. Also coders wanting to hack a bit on PyDingo in the future are welcomed.

 http://code.google.com/p/pydingo/






<div>
<p>I've created a project called PyDingo,
which is a PyQt4 application &ndash; file manager, text editor, and
"more". The concept of the application is similar to Konqueror &ndash;
a tabbed multi purpose app, but aside "basic" file/text
management options it will allow creating widgets for other things
for example display system stats with pystatgrab by typing url like
"stats://" and so on &ndash; call a widget determined by URL.</p>
<p>It won't overcome existing applications
like Kate, Konqueror, Dolphin, Nautilus, TextMate, Windows Commander
etc. but it will be useful. The main goal of this application is to
get to the useful stage &ndash; solving various problems (cross platform,
feature implementation and so on) on the way (than can be nicely
documented).</p>

<p>Current stage is very Alpha. I have to
add few basic elements to get to 0.1, 0.2 stage from which more "fun"
can be squeezed from PyDingo coding :) I'm looking for feedback about
the code/used implementations and so on, especially when it stabilize
a bit with 0.2 release. Also coders wanting to hack a bit on PyDingo
in the future are welcomed.</p>
<p>&nbsp;<a href="http://code.google.com/p/pydingo/">http://code.google.com/p/pydingo/</a></p>
<p><br></p>
<p><br></p>
<p><br></p>
<p><br></p>
<br>
</div>
Christian Aubert | 1 Dec 2008 19:24

Re: Intro and question

Right, this is a keyboard shortcut. I'm looking for a modifier that
applies to the mouse click, so that when your ctrl-click or alt-click or
right-click, the button has a different behavior.

Christian

Iliya Gogolev wrote:
> Took from Qt API 4.4:
> 
> A command button is rectangular and typically displays a text label
> describing its action. A shortcut key can be specified by preceding the
> preferred character with an ampersand in the text. For example:
> 
>  QPushButton *button = new QPushButton("&Download", this);
> 
> In this example the shortcut is Alt+D. See the QShortcut documentation for
> details (to display an actual ampersand, use '&&').
> 
> 
> 
> -----Original Message-----
> From: pyqt-bounces <at> riverbankcomputing.com
> [mailto:pyqt-bounces <at> riverbankcomputing.com] On Behalf Of Christian Aubert
> Sent: Thursday, November 27, 2008 3:27 AM
> To: pyqt <at> riverbankcomputing.com
> Subject: [PyQt] Intro and question
> 
> Hi everyone,
> 
> Thanks to Mark for telling me about the list. I got started with pyqt
> about 3 months ago, love the functionality, hope to be able to
> contribute here.
> 
> I have a GUI using a QPushButton, does anyone know of a way to use
> modifiers on buttons (CTRL, ALT, Right-click)?
> 
> _______________________________________________
> PyQt mailing list    PyQt <at> riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 

Michał Andrzej Woźniak | 1 Dec 2008 20:04
Picon
Favicon

Re: Introducing PyDingo

Dnia poniedziałek 01 grudzień 2008, piotr maliński napisał(a):
> I've created a project called PyDingo, which is a PyQt4 application –
> file manager, text editor, and "more". The concept of the application
> is similar to Konqueror – a tabbed multi purpose app, but aside "basic"
> file/text management options it will allow creating widgets for other
> things for example display system stats with pystatgrab by typing url
> like "stats://" and so on – call a widget determined by URL.
>
> It won't overcome existing applications like Kate, Konqueror, Dolphin,
> Nautilus, TextMate, Windows Commander etc. but it will be useful. The
> main goal of this application is to get to the useful stage – solving
> various problems (cross platform, feature implementation and so on) on
> the way (than can be nicely documented).
>
> Current stage is very Alpha. I have to add few basic elements to get to
> 0.1, 0.2 stage from which more "fun" can be squeezed from PyDingo
> coding :) I'm looking for feedback about the code/used implementations
> and so on, especially when it stabilize a bit with 0.2 release. Also
> coders wanting to hack a bit on PyDingo in the future are welcomed.
>
>  http://code.google.com/p/pydingo/

One question comes to mind: will it support KParts? It would make the 
whole thing easier, more robust and more "pluggable" (you could use 
Konqueror's or Kate's, or KWord's KParts to show files and edit text or 
documents, resp.)?

Or, maybe, will it export some functionality ("stats://"?) through a 
KPart, so that it could be used in other KPart-compatible apps (like 
Konqueror)?

If not, please treat the above as feature requests/ideas. ;)

Good luck with the project!

dboddie | 1 Dec 2008 20:21

Re: Intro and question

On Mon Dec 1 18:24:38 GMT 2008, Christian Aubert wrote:

> Right, this is a keyboard shortcut. I'm looking for a modifier that
> applies to the mouse click, so that when your ctrl-click or alt-click or
> right-click, the button has a different behavior.

The signal that tells you when the button has been clicked doesn't carry this
kind of information, unfortunately. However, you can create a subclass that
emits a signal with the state of the modifier keys:

from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import *

class KeyButton(QPushButton):
    def __init__(self, *args):
        QPushButton.__init__(self, *args)
        self.modifiers = Qt.NoModifier
        self.connect(self, SIGNAL("clicked()"), self.handleClick)

    def mousePressEvent(self, event):
        self.modifiers = event.modifiers()
        QPushButton.mousePressEvent(self, event)

    def handleClick(self):
        self.emit(SIGNAL("clicked(Qt::KeyboardModifiers)"), self.modifiers)

Basically, the mousePressEvent() method handles the low-level event for mouse
button presses and records the state of the modifier keys, but passes the
event on to the base class's implementation so that the button behaves
normally.

In the __init__() method, we connected the button's standard clicked() signal
to a new handleClick() method, where we emit our own signal. The rest of the
code shows how you could use it:

app = QApplication([])

def fn(modifiers):
    if modifiers & Qt.ShiftModifier:
        print "Shift"
    if modifiers & Qt.ControlModifier:
        print "Ctrl"
    if modifiers & Qt.AltModifier:
        print "Alt"

button = KeyButton("Click me")
button.show()

button.connect(button, SIGNAL("clicked(Qt::KeyboardModifiers)"), fn)
app.exec_()

Good luck!

David

Gmane