Форум сайта python.su
#!/usr/bin/env python
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
# Some of the PyQt libs
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
def onLoadFinished(result):
print "result - " + str(result)
sys.exit(0)
manager = QNetworkAccessManager()
proxy = QNetworkProxy()
proxy.setHostName("123.123.123.123")
proxy.setPort(123)
proxy.setType(proxy.Socks5Proxy)
manager.setProxy(proxy)
app = QApplication(sys.argv)
webpage = QWebPage()
webpage.setNetworkAccessManager(manager)
webpage.connect(webpage, SIGNAL("loadFinished(bool)"), onLoadFinished)
webpage.mainFrame().load(QUrl("http://2ip.ru"))
#webpage.mainFrame().load(QUrl("http://188.40.74.10"))
sys.exit(app.exec_())
webpage.mainFrame().load(QUrl("http://188.40.74.10"))
tf = sphc.TagFactory()
doc = tf.HTML()
doc.body = tf.BODY()
doc.body.content = tf.H1("Title.")
f = open('rel.html','w')
f.write(doc)
f.close()
Error converting Pyrex file to C:
------------------------------------------------------------
...
iter = plugin.purple_plugins_get_protocols()
protocol_list = []
while iter:
pp = <plugin.PurplePlugin*> iter.data
if pp.info and pp.info.name:
^
------------------------------------------------------------
/home/user/python-purple/purple.pyx:430:17: Cannot convert 'PurplePluginInfo *' to Python object
Error converting Pyrex file to C:
------------------------------------------------------------
...
iter = blist.purple_find_buddies(self._get_structure(), NULL)
while iter:
c_alias = NULL
c_buddy = <blist.PurpleBuddy *> iter.data
if <blist.PurpleBuddy *> c_buddy and \
^
------------------------------------------------------------
/home/user/python-purple/account.pyx:570:19: Cannot convert 'PurpleBuddy *' to Python object
running build
running build_ext
building 'purple' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c c_purple.c -o build/temp.linux-i686-2.6/c_purple.o -I/usr/local/include/libpurple -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c purple.c -o build/temp.linux-i686-2.6/purple.o -I/usr/local/include/libpurple -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
purple.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
error: command 'gcc' failed with exit status 1
from threading import Thread
from Tkinter import *
class TR():
def __init__(self):
self.t1 = Thread(target = self.prog1, args = ())
self.t2 = Thread(target = self.prog2, args = ())
self.root = Tk()
self.t1.start()
def prog1(self):
#Что-то делаем
if self.t2.isAlive():
self.t2.run()
else:
self.t2.start()
def prog2(self):
#Что-то делаем
self.t1.run()
def prog3(self):
#Окно рисуем и тд
self.root.mainloop()
tr = TR()
tr.prog3()
from cmd2 import Cmd, make_option, options
import sys, optparse
class CmdLineApp(Cmd):
@options([make_option('-a', '--append', action="store_true", help="Help for append"),
make_option('-b', '--prepend', action="store_true", help="Help for prepend")
])
def do_test(self, arg, opts=None):
pass
app = CmdLineApp()
func = getattr(app, 'do_test')
print func
#как получить список опций?
#! /usr/bin/env python
# coding: utf-8
import gtk, gobject
class entryDate(gtk.Entry):
def __init__(self):
gtk.Entry.__init__(self)
self.Entry = gtk.Entry()
self.Entry.connect("key-press-event", self.onKeyPress )
def onKeyPress(self, widget, event):
print "key pressed"
Traceback (most recent call last):
File "mysoft.py", line 32, in bookLoad
book.setUrl(QtCore.QUrl(y))
TypeError: arguments did not match any overloaded call:
QUrl(): too many arguments
QUrl(QString): argument 1 has unexpected type 'QTreeWidgetItem'
QUrl(QUrl): argument 1 has unexpected type 'QTreeWidgetItem'
QUrl(QString, QUrl.ParsingMode): argument 1 has unexpected type 'QTreeWidgetItem'
def bookLoad(y):
book.setUrl(QtCore.QUrl(y))
book = QWebView()
book.load(QtCore.QUrl(f)) # Дефолтная страница.
QtCore.QObject.connect(tree, QtCore.SIGNAL('itemClicked(QTreeWidgetItem *, int)'), bookLoad)
class MainForm(QtGui.QWidget):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.ui = UIMainForm.UIMainForm()
self.ui.setupUi(self)
frm = MainForm.MainForm()
frm.ui.btnShutdown.setEnabled(False)
frm.show()