|
Three cheers for tef, this is uber-helpful.
|
# ? Feb 15, 2013 10:46 |
|
|
# ? May 31, 2024 04:18 |
|
Suspicious Dish posted:No, it's: Oh, yeah you're right. It was late
|
# ? Feb 15, 2013 11:54 |
|
I want to make a log viewer in python that will tail logs from various linux servers, I think I can handle the tailing part easily enough. But I would like to have it in GUI form. I've seen some software made in PyQT that runs nicely but the QT Designer is totally weird to me. It only generates a template and doesn't let you make the code that actually does things within it, which is super annoying compared to using something more akin to Visual Studio. Is there anything like the Visual Studio way of doing things in Python? I'm not deadset on Qt or anything.
|
# ? Feb 15, 2013 16:19 |
|
Any recommendations for adding simple graphics to a python program? Don't need anything more complex than drawing a few colored squares on the screen.
|
# ? Feb 15, 2013 21:49 |
|
Drunk Badger posted:Any recommendations for adding simple graphics to a python program? Don't need anything more complex than drawing a few colored squares on the screen. pygame works pretty well and is easy to pick up. It's got a 2d layer IIRC, which will be a lot faster to get going for you especially if you're not used to Direct3D / OpenGL stuff. edit: the name makes it sound like it's for games mostly, but I've used it for scientific applications and such before and it's good at basic display also
|
# ? Feb 15, 2013 21:55 |
|
Emacs Headroom posted:pygame works pretty well and is easy to pick up. It's got a 2d layer IIRC, which will be a lot faster to get going for you especially if you're not used to Direct3D / OpenGL stuff. That should work great for what I need, thanks.
|
# ? Feb 15, 2013 22:01 |
|
Can I ask about Python CGI scripts in this thread? I'm doing an experiment for a university research paper that involves timing how long people take to read a web page I've made. Basically, the timer starts when they load the page and stops when they click the link to the next page, whose URL contains a query string with the time it took the user to read the page. The second page then gets the time from the URL and stores it in a Javascript variable I called "querystr". Because of the nature of the experiment, I can't tell the user that they're going to be timed before they read the page, which means that afterwards I have to offer them the option to either opt out of having their data analysed or agree for it to be used. Here's where the CGI script comes in: if they allow me to analyse their data, I need their time to then be added to a database on the university web server so that I can easily read it off. I've done the client-side end of things (measuring how long they spend on the page and storing it in a variable) but I'm not really sure how to go about passing that variable on to a database if they don't check the box indicating that they want to opt out. I'm still sort of coming to terms with Python, and I don't know much about server-side applications at all - am I in over my head here? Is the script I want relatively simple, and if so, do I just dump whatever .py file in a folder on the web server and get it to create a HTML page with the data?
|
# ? Feb 16, 2013 00:34 |
|
Dwayne Bensey posted:Can I ask about Python CGI scripts in this thread? You can, but don't expect anybody to help you. CGI is an old protocol, and it's fairly obsolete. Python's startup speed is slow, meaning that the CGI model of "start up a process, translate HTTP into environment variables and command lines, and let the Python script translate all that back into HTTP again" won't be too performant.
|
# ? Feb 16, 2013 00:41 |
|
Django would be the overkill choice for you. Flask would probably be the more logical choice. Both will have instructions on their documentation for how to get set up with Apache. Is the database MySQL or something like that? Are you allowed to make new tables in it? Or do you have an existing table you want to write into? One final idea: if you don't have a ton of time to play around with learning server-side scripting and databases etc., I bet you could pay someone about 200 bucks to do all this for you. If you've got some research money you can use.
|
# ? Feb 16, 2013 00:43 |
|
Emacs Headroom posted:Django would be the overkill choice for you. Flask would probably be the more logical choice. Both will have instructions on their documentation for how to get set up with Apache. Something like Flask or CherryPy is actually pretty hilariously easy to use. Find their quickstart script, write an HTML template. Write two functions, one which returns the template and one that accepts GET request headers wtih the info you need and puts whatever you want in a database. If you know how to use Git you could put all of this on Heroku for free with a PostgreSQL database and write a couple lines of SQLAlchemy to stick your info in there since it seems unlikely that kind of data would generate more than the tiny limit the free database has. OnceIWasAnOstrich fucked around with this message at 00:56 on Feb 16, 2013 |
# ? Feb 16, 2013 00:46 |
|
Emacs Headroom posted:pygame works pretty well and is easy to pick up. It's got a 2d layer IIRC, which will be a lot faster to get going for you especially if you're not used to Direct3D / OpenGL stuff. Any issues with using the version for Python 3.1 (Or the alpha for 3.2) with Python 3.3?
|
# ? Feb 16, 2013 02:54 |
|
I don't actually have a database set up. I had a look at Flask but couldn't get it to install on Ubuntu for some reason. Got some help in the form of a small PHP script that accepts a variable and makes a text file with the data that I need in it, so that should do the trick anyway. Thanks for the suggestions though
|
# ? Feb 16, 2013 14:57 |
|
Did anyone see this? It was accepted today. http://www.python.org/dev/peps/pep-0427/
|
# ? Feb 16, 2013 17:27 |
|
That seems really nice... hunting for the right package flavor can be really obnoxious as it is. At least this looks like fewer variants would have to be shuttled between the package index and a development network that doesn't have Internet access.
|
# ? Feb 16, 2013 18:48 |
|
tef, that was invaluable. Thank you so much for the effort and the write, very, very helpful.
|
# ? Feb 16, 2013 20:37 |
|
I'm working on refactoring a library that I've been using to read/write binary files. I was curious if there are any guides to the optimal layout for a project. Maybe even a link to a similar type of project that has a logical layout? I'm thinking something like the following: code:
|
# ? Feb 18, 2013 22:52 |
|
I'm trying to whip up a script to convert between Unicode and ASCII HTML entities for some website work, but am failing somewhere on the Unicode conversion. The conversion to named entities works fine, but fails when I convert back to accented Unicode, and specifically on the & rsquo ; entity. What am I missing? Full code at Pastebin code:
onionradish fucked around with this message at 16:39 on Feb 19, 2013 |
# ? Feb 19, 2013 16:35 |
|
Sylink posted:I want to make a log viewer in python that will tail logs from various linux servers, I think I can handle the tailing part easily enough. But I would like to have it in GUI form. I'd recommend either Glade or wxFormBuilder. Both are pretty similar in functionality, although I would say wxformbuilder is overall a bit more intuitive for someone used to Visual Studio-type GUI building. Here's a screenshot of a GUI I made for work that utilizes the skype API to automatically add contacts for accounts (since skype is a pain in the rear end and for some reason doesn't include this feature in their business account manager thing, wtf?): Hopefully the "object tree" structure in that image will give you a head start on how you can layout the GUI. Just remember that the first thing you have to start off with is a frame to place objects in, and you'll need at least one sizer to layout the elements of your GUI. If you check out the tabs at the bottom, you'll see that the builder automatically generates the python code you need, and alls you have to do is then import it like so: Easy as py! Feral Integral fucked around with this message at 18:36 on Feb 19, 2013 |
# ? Feb 19, 2013 18:29 |
|
So I'm doing game stuff in python, and I'm trying to figure something out. If I have a a loop that looks like Python code:
|
# ? Feb 19, 2013 21:20 |
|
babyeatingpsychopath posted:So I'm doing game stuff in python, and I'm trying to figure something out. Python code:
|
# ? Feb 19, 2013 22:11 |
|
peepsalot posted:doubtful that it would factor it out, and could vary between implementations (maybe pypy would be smart about it? *shrug*) best to be explicit if you are concerned about performance, and you already know what you want to optimize. Yeah, I know I can do it by hand, but I'm really trying to get away from premature optimization. It was more a philosophical question about the python interpreter/bytecode compiler/etc. If it's implementation-dependent, that's cool. If it looks like that specific part is the slow part, I'll optimize it the old-fashioned way.
|
# ? Feb 19, 2013 22:38 |
|
It's doubtful to matter that much, but it doesn't cost anything to do it, and also makes it clearer to other people (and static analyzers, etc.) that cosTheta will not change during the loop.
|
# ? Feb 20, 2013 00:26 |
|
onionradish posted:I'm trying to whip up a script to convert between Unicode and ASCII HTML entities for some website work, but am failing somewhere on the Unicode conversion. The conversion to named entities works fine, but fails when I convert back to accented Unicode, and specifically on the & rsquo ; entity. What am I missing? You're over-thinking this. code:
|
# ? Feb 20, 2013 03:01 |
|
babyeatingpsychopath posted:So I'm doing game stuff in python, and I'm trying to figure something out. cpython will not hoist out expressions like that: code:
To eke performance out of pure python, without resorting to cython, Numba, PyPy, SWIG, or hand-rolled extension modules, people will sometimes even hoist dotted namespace lookups out of loop. (i.e foo = bar.foo) But you might have an argument about diminishing returns and proper tool choices at that point. BigRedDot fucked around with this message at 06:22 on Feb 20, 2013 |
# ? Feb 20, 2013 06:10 |
|
BigRedDot posted:
Even if it knew that the builtin cos is side-effect free and always returns the same value, it'd also have to 'prove' that the cos in scope there is always the 'right' cos, which can get very messy.
|
# ? Feb 20, 2013 06:15 |
|
UTF/HTML stuff...The Insect Court posted:You're over-thinking this.
|
# ? Feb 20, 2013 16:38 |
|
Windows has always gotten and will always get proper Unicode support wrong.
|
# ? Feb 20, 2013 18:21 |
|
I have another unicode question, for some reason Google Translate has begun returning values in iso-8859-1, and had previously been returning them in utf8, and I cannot figure out why this isn't working.code:
code:
code:
|
# ? Feb 20, 2013 22:58 |
|
Innocent Bystander posted:I have another unicode question, for some reason Google Translate has begun returning values in iso-8859-1, and had previously been returning them in utf8, and I cannot figure out why this isn't working. Google is returning a UNICODE string to you. This means that you can encode it using whatever character set you want (as long as it is able to interpret all of the characters). The output of your print statements are the raw byte strings corresponding to the 'latin' and 'utf8' representations of the unicode string returned by google. In your case, that character is a lower-case umlaut u. Of course they aren't going to be the same because UTF-8 and 'latin-1' are two different encodings and therefore will have different codes for the same unicode character. Your line that you're trying to run is doing this following code:
When you use the following, you're actually seeing the byte-string that represents the umlaut u in UTF-8 which is what you want code:
code:
I would highly recommend you watch Ned Batchelder's talk about unicode to save yourself a lot of headaches (http://nedbatchelder.com/text/unipain.html)
|
# ? Feb 20, 2013 23:44 |
|
Anyone here well versed in nose? I can't figure out how to get a single test to run. I have a test runner that invokes nose.core.TestProgram(). Passing the something like ['my_file.py:TestClass.test_method'] to defaultTest runs all the tests in the TestClass, and not the individual method as I would expect it to. Houston Rockets fucked around with this message at 02:04 on Feb 21, 2013 |
# ? Feb 21, 2013 01:54 |
|
'my_file.py:TestClass.test_method' this form of test specifying usually goes by module instead of filename. I'm curious what would happen if you passed 'my_file:TestClass.test_method' instead (notice the missing .py) ah, too bad VVVVVVVVVVV Lurchington fucked around with this message at 03:14 on Feb 21, 2013 |
# ? Feb 21, 2013 03:04 |
|
Lurchington posted:'my_file.py:TestClass.test_method' Same result unfortunately. Here's the documentation I've been looking at in order to try and figure it out: http://nose.readthedocs.org/en/latest/usage.html#selecting-tests
|
# ? Feb 21, 2013 03:09 |
|
I'm at my wits end, so I figure I'll ask here: I'm making a simple game in python curses to teach myself programming. I'm in windows, where the curses module doesn't work natively, so after a bit of googling I found the windows version for 3.2 here. When I use initscr() to bring up the curses terminal, it defaults to a 25 line, 80 column size. I want a bigger size than that. The python documentation says window.resizeterm(lines, cols) should resize the window, but it keeps throwing an error saying 'resizeterm' isn't in the module curses. hasattr(curses, 'resizeterm') does indeed return false. I find another windows curses version, unicurses, but it doesn't have the resizeterm command at all! So I do more googling, and find that I can change the default size of the window by doing os.environ['LINES'] = 'blah' and os.environ['COLS'] = 'blah' which does indeed change the terminal size. But, the actual program window doesn't change size to match the terminal! A picture of how it looks: http://imgur.com/kVWESjj The LINES and COLS values are in the top left. LINES is 80, COLS is 60. A box is drawn around the actual python window to show what should be being drawn. As you can see, the program is actually getting resized, and all the test entries in my menu are printed off screen. I can still interact with them, scroll back up, etc. The border continues offscreen as well, so I know the program thinks it's 80x60, but the Windows window is still stuck at the 25x80 size. How can I fix this? edit: figured it out. All I had to do was right click the border, hit properties, and change the Window size. os.system("mode con cols=80 lines=60") works. Done. Cantorsdust fucked around with this message at 08:36 on Feb 21, 2013 |
# ? Feb 21, 2013 03:44 |
|
Well, I've picked back up on Python. I'm terrible at this, and have nobody's brain to pick but yours, so I suppose I get back to the ignorant questions. I'm using tkinter and trying to create basic GUI's right now, and I'm loving with buttons and just trying to get really basic poo poo to work. I can't get past this error:quote:C:\Users\Gothmog\Desktop\Python\HelpGui>MainWindow.py I know it's something stupid, probably coming from my lack of understanding on how classes work still. Please don't vomit on your keyboards when you see this: code:
|
# ? Feb 21, 2013 04:59 |
|
New_window isn't a Tk widget. You pass it as the "parent" argument on the last Text() call. You want to pass "top" instead.
Scaevolus fucked around with this message at 05:07 on Feb 21, 2013 |
# ? Feb 21, 2013 05:05 |
|
Houston Rockets posted:Same result unfortunately. Here's the documentation I've been looking at in order to try and figure it out: It seems to be some problem with multiprocessing. Not the first time this has bitten me. Multiprocessing breaks a lot of other nose options as well. I had to use some random dev's custom noseplugins to get xunit report output to work with multiprocessing. I'll just disable multiprocessing if individual tests are selected using the test runner. Ugh. Wish I had time to contribute and get some pull requests going.
|
# ? Feb 21, 2013 19:41 |
|
Houston Rockets posted:It seems to be some problem with multiprocessing. Not the first time this has bitten me. Multiprocessing breaks a lot of other nose options as well. I had to use some random dev's custom noseplugins to get xunit report output to work with multiprocessing. I'll just disable multiprocessing if individual tests are selected using the test runner. Ugh. Fixing nose to get xunit output and multiprocessing output to work together is a major architectural reworking that will almost certainly never get done. I haven't had to deal with I/O-bound test suites in a while, so I don't know what the status of this issue is with nose2, but it should at least be a bit more tractable, if not solved. Edit: for at least the trivial case I tested, nose2's multiprocessing and junit-xml plugins do play nicely together. good jovi fucked around with this message at 20:59 on Feb 21, 2013 |
# ? Feb 21, 2013 20:50 |
|
Scaevolus posted:New_window isn't a Tk widget. You pass it as the "parent" argument on the last Text() call. You want to pass "top" instead. This is where my ignorance shines. How do I manage to do that?
|
# ? Feb 22, 2013 02:07 |
|
Gothmog1065 posted:This is where my ignorance shines. How do I manage to do that? Replace "self" with "top"
|
# ? Feb 22, 2013 02:21 |
|
|
# ? May 31, 2024 04:18 |
|
Well I feel stupid now. I must not have saved the file before running it again. Now to find out why the program locks up. Running the debugger in IDLE, I can step all the way through until it comes back to the root.mainloop, then locks up on some random line in another module. Takes a beginner to lock something up this bad. Gothmog1065 fucked around with this message at 03:44 on Feb 22, 2013 |
# ? Feb 22, 2013 03:29 |