Форум сайта python.su
выравнивание (justify)Однако
Допустимыми значениями являются строки: “left” (по левому краю), “center” (по центру), “right” (по правому краю) и “fill” (по ширине).
txt.tag_configure('filled',justify='fill') txt.tag_add('filled','1.0','end')
_tkinter.TclError: bad justification “fill”: must be left, right, or centerУ меня Python 3.1.3.
but = QtGui.QPushButton(view) self.scene.addWidget(but)
"QGraphicsProxyWidget::setWidget: cannot embed widget 0x1fa8a20 which is not a toplevel widget, and is not a child of an embedded widget"
import mptt from django.db import models from mptt.models import MPTTModel, TreeForeignKey class Folder(MPTTModel): name = models.CharField(max_length=255, default='/', verbose_name=u'Имя') parent = TreeForeignKey('self', null=True, blank=True,related_name='child') def __unicode__(self): return self.name class MPTTMeta: parent_attr = 'parent' class Product(models.Model): parent = models.ForeignKey(Folder, blank=True, null = True, related_name='child_product') name = models.CharField(max_length=255, db_index=True, verbose_name=u'Имя') price = models.CharField(max_length=8, db_index=True, verbose_name=u'Цена') def __unicode__(self): return self.name mptt.register(Folder) mptt.register(Product)
from offers.models import Product, Folder from django_mptt_admin.admin import DjangoMpttAdmin from django.contrib import admin admin.site.register(Product, DjangoMpttAdmin) admin.site.register(Folder, DjangoMpttAdmin)
var1 = netsnmp.Varbind('1.3.6.1.4.1.171.12.1.2.1.1.3',3, '10.100.1.100','IPADDR') res1 = netsnmp.snmpset(var1, Version = 2, DestHost = ipsw, Community='private')
SYS.VERSION: 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] SYS.PLATFORM: linux2 PLATFORM.MACHINE: x86_64 PLATFORM.PROCESSOR: PLATFORM.UNAME.RELEASE: 2.6.32.26 PLATFORM.LINUX_DISTRIBUTION: debian 6.0.6 NUMPY.VERSION: 1.6.2 OpenGL_accelerate module loaded Using accelerated ArrayDatatype Unable to load numpy_formathandler accelerator from OpenGL_accelerate Unable to load registered array format handler numeric Traceback (most recent call last): File "makehuman.py", line 310, in <module> main() File "makehuman.py", line 300, in main from mhmain import MHApplication File "./core/mhmain.py", line 32, in <module> import mh File "./lib/mh.py", line 29, in <module> from glmodule import updatePickingBuffer, grabScreen, hasRenderSkin, renderSkin File "./lib/glmodule.py", line 33, in <module> from OpenGL.GL import * File "/usr/lib/python2.7/dist-packages/OpenGL/GL/__init__.py", line 3, in <module> from OpenGL.raw.GL.annotations import * File "/usr/lib/python2.7/dist-packages/OpenGL/raw/GL/annotations.py", line 40, in <module> 'v', File "/usr/lib/python2.7/dist-packages/OpenGL/arrays/arrayhelpers.py", line 197, in setInputArraySizeType function.setPyConverter( argName, asArrayTypeSize(type, size) ) File "arraydatatype.pyx", line 393, in OpenGL_accelerate.arraydatatype.AsArrayTypedSizeChecked.__init__ (src/arraydatatype.c:7688)
while True: c=stdscr.getch() if c == ord ('q'): break if c == ord ('w'): cl.scroll (0, -1) if c == ord ('a'): cl.scroll (-1, 0) if c == ord ('s'): cl.scroll (0, 1) if c == ord ('d'): cl.scroll (+1, 0) cl.refresh ()
def scroll (self, __x, __y): """Change _x, _y according to arguments. Does not refresh,\ but sets variables for refresh() to run. """ assert isinstance (__x, int) assert isinstance (__y, int) if self._x == self.lvl.min_x - 2*self.draw_length and __x < 0: __x = 0 elif self._x == self.lvl.max_x + 2*self.draw_length+15 and __x > 0: __x = 0 self._x +=__x if self._y == self.lvl.min_y - 2*self.draw_length and __y < 0: __y = 0 elif self._y == self.lvl.max_y + 2*self.draw_length+15 and __y > 0: __y = 0 self._y +=__y
In [5]: l Out[5]: Level (room_size_min = 5, room_size_max = 7, room_type = "random", digger_where_to = (2, 4, 6, 8), digger_stamina = 6, doors_are_useful = True, min_rooms = 5, max_rooms = 10, room_times = 1) In [6]: l.size_y, l.size_x Out[6]: (121, 101) In [7]: cl.pad.getmaxyx() Out[7]: (123, 103)
// Define the interface to the hello library. #include <qlabel.h> #include <qwidget.h> #include <qstring.h> class Hello : public QLabel { // This is needed by the Qt Meta-Object Compiler. Q_OBJECT public: Hello(QWidget *parent); private: // Prevent instances from being copied. Hello(const Hello &); Hello &operator=(const Hello &); }; //void setDefault(const QString &def);
#include "hello.h" #include "stdio.h" /* void setDefault(const QString &def) { } */ Hello::Hello(QWidget *parent = 0):QLabel(parent) { printf("First Qt example function"); } Hello::Hello(const Hello &) { } Hello &Hello::operator=(const Hello &) { return *this; }
QT += core gui TARGET = hello TEMPLATE = lib SOURCES += hello.cpp HEADERS += hello.h
// Define the SIP wrapper to the hello library. %Module hello %Import QtGui/QtGuimod.sip %If (Qt_4_2_0 -) class Hello : public QLabel { %TypeHeaderCode #include <hello.h> %End public: Hello(QWidget *parent /TransferThis/ = 0); private: Hello(const Hello &); }; %End
import os import sipconfig from PyQt4 import pyqtconfig # The name of the SIP build file generated by SIP and used by the build # system. build_file = "hello.sbf" # Get the PyQt configuration information. config = pyqtconfig.Configuration() # Get the extra SIP flags needed by the imported PyQt modules. Note that # this normally only includes those flags (-x and -t) that relate to SIP's # versioning system. pyqt_sip_flags = config.pyqt_sip_flags # Run SIP to generate the code. Note that we tell SIP where to find the qt # module's specification files using the -I flag. os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "-I", config.pyqt_sip_dir, pyqt_sip_flags, "hello.sip"])) # We are going to install the SIP specification file for this module and # its configuration module. installs = [] installs.append(["hello.sip", os.path.join(config.default_sip_dir, "hello")]) installs.append(["helloconfig.py", config.default_mod_dir]) # Create the Makefile. The QtGuiModuleMakefile class provided by the # pyqtconfig module takes care of all the extra preprocessor, compiler and # linker flags needed by the Qt library. makefile = pyqtconfig.QtGuiModuleMakefile( configuration=config, build_file=build_file, installs=installs ) # Add the library we are wrapping. The name doesn't include any platform # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the # ".dll" extension on Windows). makefile.extra_libs = ["hello"] # Generate the Makefile itself. makefile.generate() # Now we create the configuration module. This is done by merging a Python # dictionary (whose values are normally determined dynamically) with a # (static) template. content = { # Publish where the SIP specifications for this module will be # installed. "hello_sip_dir": config.default_sip_dir, # Publish the set of SIP flags needed by this module. As these are the # same flags needed by the qt module we could leave it out, but this # allows us to change the flags at a later date without breaking # scripts that import the configuration module. "hello_sip_flags": pyqt_sip_flags } # This creates the helloconfig.py module from the helloconfig.py.in # template and the dictionary. sipconfig.create_config_module("helloconfig.py", "helloconfig.py.in", content)
from PyQt4 import pyqtconfig # These are installation specific values created when Hello was configured. # The following line will be replaced when this template is used to create # the final configuration module. # @SIP_CONFIGURATION@ class Configuration(pyqtconfig.Configuration): """The class that represents Hello configuration values. """ def __init__(self, sub_cfg=None): """Initialise an instance of the class. sub_cfg is the list of sub-class configurations. It should be None when called normally. """ # This is all standard code to be copied verbatim except for the # name of the module containing the super-class. if sub_cfg: cfg = sub_cfg else: cfg = [] cfg.append(_pkg_config) pyqtconfig.Configuration.__init__(self, cfg) class HelloModuleMakefile(pyqtconfig.QtGuiModuleMakefile): """The Makefile class for modules that %Import hello. """ def finalise(self): """Finalise the macros. """ # Make sure our C++ library is linked. self.extra_libs.append("hello") # Let the super-class do what it needs to. pyqtconfig.QtGuiModuleMakefile.finalise(self)
import hello h = hello.Hello() print h
$qmake-qt4 $make # это я собираю библиотеку libhello.so $ python ./configure.py $ make /usr/bin/ld: cannot find -lhello collect2: error: ld returned 1 exit status make: *** [hello.so] Error 1 Эту ошибку я исправил добавлением -L. в Makefile $ ls configure.py hello.cpp hello.o hello.so libhello.so.1.0 moc_hello.cpp pythontest.py siphellocmodule.o helloconfig.py hello.exp hello.sbf libhello.so libhello.so.1.0.0 moc_hello.o sipAPIhello.h siphelloHello.cpp helloconfig.py.in hello.h hello.sip libhello.so.1 Makefile proj.pro siphellocmodule.cpp siphelloHello.o
Traceback (most recent call last): File "./pythontest.py", line 1, in <module> import hello ImportError: libhello.so.1: cannot open shared object file: No such file or directory
x=np.arange(0,11,1) t=np.arange(0,21000,1000) x,t=np.meshgrid(x,t) uu=[] for j in range(11): l = [round(u[j,1000*i]) for i in range(21)] uu.append(l)
chall, solution = cap.solve_recaptcha(grab.clone()) print "======================= "+str(chall) print "======================= "+str(solution) grab.set_input('username', site_data['login']) grab.set_input('password', site_data['password']) grab.set_input('recaptcha_response_field', solution) grab.set_input('recaptcha_challenge_field', chall) grab.submit()
class ItemsList(ListView): template_name = 'items_list.html' queryset = Item.objects.all() def get_context_data(self, **kwargs): context = super(ItemsList, self).get_context_data(**kwargs) context['form'] = SearchForm() return context def search(request): if 'search' in request.GET and request.GET['search']: search = request.GET['search'] form = SearchForm(request.GET) if form.is_valid(): art = Item.objects.filter(Q(title__icontains=search)) else: art = [] else: form = SearchForm() art = [] c = RequestContext(request, {'items':art, 'form':form}) return render_to_response('search_list.html',c)
import math import pyaudio import wave myfile = open(r"C:\Users\kulikov_aa\test.txt") i=0 for line in myfile.readlines(): wf = wave.open( r"C:\Users\kulikov_aa\test.wav", 'rb') i+=1; length=line.__len__();#the length by line one= line.find(' ') firstFragment=""; firstFragment=line[0:one]#first fragment two=firstFragment.__len__()#the lenght of fragment firstontwo=line[two+1:length];#one step for two fragment three=firstontwo.find(' '); twoFragment=firstontwo[0:three];#two fragment four=twoFragment.__len__() five=firstontwo[four:length]#three fragment if int(five)==1: WAVE_OUTPUT_FILENAME = r"C:\Users\kulikov_aa\testA"+str(i)+".wav" p = pyaudio.PyAudio() print firstFragment+" "+twoFragment; start = float(firstFragment)*(math.pow(10,-7)) end = float(twoFragment)*(math.pow(10,-7)) frameRate = wf.getframerate() nChannels = wf.getnchannels() sampWidth = wf.getsampwidth() wf.setpos(start*frameRate) data = wf.readframes(int((end-start)*frameRate)) wf3 = wave.open(WAVE_OUTPUT_FILENAME, 'wb') wf3.setnchannels(nChannels) wf3.setsampwidth(sampWidth) wf3.setframerate(frameRate) wf3.writeframes(data) wf3.close() p.terminate()
Gdk.threads_init() win = MainWnd() Gtk.main() Gdk.threads_leave()