python-3.3

Python + Pygame + PygButton detecting

感情迁移 提交于 2019-12-25 04:25:15
问题 I'm using Python 3.3 with Pygame and PygButton (low rep don't allow me more than two links) My files at the moment are [ int.py http://pastebin.com/sDRhieCG ] and [ scene.py http://pastebin.com/Y2Mgsgmr ]. The idea is making a mainloop in int.py the smaller as possible. The code has a commented-out example of the start_screen buttons at the mainloop. It works, but with every new screen the mainloop would be bloated. So I created a Scene class to apply background, texts and buttons. It works,

Crash on call from boost::python::exec( anything )

你。 提交于 2019-12-25 01:44:57
问题 I'm trying to implement some Python stuff into my program and I've decided to use Boost::Python, so I compiled it according to the instructions, with bjam, using mingw/gcc, getting dlls and .a files I'm using Code::Blocks for this, so I've put the dlls in the working directory of my project, where the rest of dlls I use are, and decided to run boost::python::exec("b = 5"); Instantly I get a crash. Ideas? #include <boost/python.hpp> float func(int a) { return a*a-0.5; } BOOST_PYTHON_MODULE

How do I check if a checkbox is checked or unchecked? (In QTreeWidget)

℡╲_俬逩灬. 提交于 2019-12-24 12:05:36
问题 I have written the code below: from PyQt4 import QtCore, QtGui import sys class window(QtGui.QMainWindow): def __init__(self, parent=None): super(window, self).__init__(parent) self.TreeWidget = QtGui.QTreeWidget() self.TreeWidget.setColumnCount(1) item1 = QtGui.QTreeWidgetItem(["Item 1"]) item1.setCheckState(0, QtCore.Qt.Checked) item2 = QtGui.QTreeWidgetItem(["Item 2"]) item2.setCheckState(0, QtCore.Qt.Unchecked) item3 = QtGui.QTreeWidgetItem(["Item 3"]) item3.setCheckState(0, QtCore.Qt

pywin32-220 installer “high risk” file

时光怂恿深爱的人放手 提交于 2019-12-24 11:55:22
问题 When I try to install pywin32-220 it will be stopped by Norton saying that it's threat name "SONAR.Heuristic.132" and a "High risk file". It removes the pywin32-220 installer... So how can I get pywin32? Pywin32 download - http://sourceforge.net/projects/pywin32/files/?source=navbar SONAR.Heuristic.132 threat: (Norton link to details) http://www.symantec.com/security_response/writeup.jsp?docid=2015-061517-5721-99&vid=4294925827&product=Norton%20Internet%20Security&version=22.5.5.15&plang=sym

How to print with end=“ ” immediately in Python 3?

醉酒当歌 提交于 2019-12-24 11:34:30
问题 How can I use print statement without newline and execute this immediately? Because this: print("first", end=" ") time.sleep(5) print("second") will print after 5 sec both: first second But I want to write 'first', wait for five seconds, and then write 'second'... 回答1: You need to flush stdout : print("first", end=" ", flush=True) stdout is line buffered, which means the buffer is flushed to your screen every time you print a newline. If you are not printing a newline, you need to flush

ImportError: No module named 'matplotlib.pyplot'; matplotlib is not a package

落爺英雄遲暮 提交于 2019-12-23 21:05:23
问题 I am trying to use matplotlib for real-time analysis from ECG-signals, but the problem starts even before. I use the PyCharm IDE, currently working with Python 3.3 and my os is Windows 8.1. For Matplotlib I downloaded matplotlib and the dependencies (numpy, six, dateutil, pyparsing, pytz) from here (the versions for Python 3.3): http://www.lfd.uci.edu/~gohlke/pythonlibs/ and installed it in the Python33 folder. Now if I try: from matplotlib.pyplot import plot, show plot(range(10)) show() or:

How to use nltk3 for python33?

匆匆过客 提交于 2019-12-23 16:35:49
问题 I successfully installed NLTK 2.0.4, but when I tried to download the NLTK packages, i.e. nltk.download('stopwords') it doesn't work, so I am trying to install an updated version of NLTK for python 3 but it gives this error: >>> import nltk Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\Prashant\AppData\Roaming\Python\Python33\site-packages\nltk\_ nit__.py", line 37 except IOError, ex: ^ SyntaxError: invalid syntax Is there any way to install NLTK for

How do I sort data highest to lowest in Python from a text file?

不羁岁月 提交于 2019-12-23 06:08:54
问题 I have tried multiple methods in doing this but none of them seem to work The answer comes up alphabetically instead f=open("class2.txt", "r") scores=myfile.readlines() print(sorted(scores)) f.close() ['Anne, 3\n', 'Dave, 10', 'Jack, 4\n', 'Lucy, 8\n'] Also is there any way to get rid of the "/n" when it goes to the shell? 回答1: Based on the inputs and outputs, I'm guessing you're trying to sort the input names by the associated values. To sort numerically, you can either parse all the values

Missing tkinter attributes after converting to py2exe executable

拜拜、爱过 提交于 2019-12-23 05:08:13
问题 I have a Python 3.3 script which uses tkinter and tkinter.filedialog . The latter is being used in this particular line of one of the classes: self.root_folder = os.path.realpath(tk.filedialog.askdirectory(**self.dir_opt)) The code runs well in IDLE. However, after being converted to a binary executable using py2exe , the program runs, but raises the following exception when trying to call the named line: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python33\lib

Python3.3 rounding up

ⅰ亾dé卋堺 提交于 2019-12-22 18:38:10
问题 In Python I would like to divide two numbers and if the answer is not an integer I want the number to be rounded up to the number above. For example 100/30 not to give 33.3 but to give 4. Can anyone suggest how to do this? Thanks. 回答1: you can use the ceil function in math library that python has, but also you can take a look why in a logical sense a = int(100/3) # this will round down to 3 b = 100/3 # b = 33.333333333333336, a and b are not equal so we can generalize into the following def