A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Quick Python question, if anyone can help: How can I create a script to call up an image? The said script creates a Win32 Console and displays interactive messages and responses, in a simple way. I want to have that same script call up an image with certain responses, and I was thinking that the best end to that mean would be to use a COM server to call up a System-intrinsic viewing program (the script is only suited for Win32 systems), and direct it to open a specific directory and image corresponding with the response printed to the console. Thank you for any help!

  • This Question is Closed
  1. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    I work on Linux, so I can't offer much advice about Windows, but you can just make a system call in Python which should do what you want. import os cmd = 'some system command' os.system(cmd) I use IPython and I've got a bunch of hooks for this type of stuff set up, but I usually send images, pdfs and that kind of stuff to my web-browser, Chrome. I don't have much of a desktop, I'm on fluxbox day to day, so this works for me. You might want to consider writing a real simple server, Bottle is good for this, and then running that locally and firing up Chrome passing some URL your server will know what to do with. Let me know where you're at and I'll try and be more specific. I'll offer a few tips on using Bottle as well if it interests you.

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you for your assistance, but I have no idea how to implement a server in the way you mentioned. The usage of the web browser is actually a great alternative method, but can you create the server and send the image on cue and still maintain a "blackbox" effect? (i.e.; user doesn't know that a server is being set up and no confusing prompts ask for their input, etc) Also, is Bottle a Python module or another program? And, since the server is local, are there any registry entries or temporary files/directories that would be left behind requiring cleanup? I would be extremely thankful for any help!

  3. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Yes, Bottle is a Python module, it's a single module, you can just grab a copy of bottle.py and drop it in. You can run the server locally like any other app and it should behave like any other app ~ once it quits, it shouldn't leave any files behind unless you've told it to explicitly. Your server can return images or web pages containing images when ever it is told to by the client, a browser normally. In a simple set up, the user would start the application in the normal way and the app would be the server. Once the server is running, you'd need to make a request to it from the browser, but you could bookmark the page to request in the browser. You could also write a little script that'll fire up the server as a background app, then, once it's running, fire up your browser, passing the url of the local server as a command line argument. That way the browser will fire up and immediately open at your page. I'm not sure how you'd do this on Windows, but I reckon it'd be easy enough to figure out. It can be wrapped up so the user doesn't have to do anything technical, but it'd be obvious to anyone at all familiar with a computer that you're running a server locally and that is what's providing services to the browser. There's normally no harm in this though. I've attached a copy of bottle.py

    1 Attachment
  4. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    To actually use the server, you'll be needing these docs... http://bottlepy.org/docs/dev/ I'm pretty sure this is the latest version, so just follow the instructions on the above page. The new tutorials wont work with the old versions. Let me know how you get on.

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.