Re: calendar from python to html
Well, you need a web server, a webpage, a database (could just be a
file), a cgi script, and the datetime module. Optionally, you can use a
web framework like CherryPy or Django, which covers a lot of these by
itself.
I only know Python 2, but here are some examples:
A basic web server:
webdir = '.'
port = 80
import os, sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
if len(sys.argv) > 1: webdir = sys.argv[1]
if len(sys.argv) > 2: port = int(sys.argv[2])
print 'webdir "%s", port %s' % (webdir, port)
#Windows only hack
if sys.platform[:3] == 'win':
CGIHTTPRequestHandler.have_popen2 = False
CGIHTTPRequestHandler.have_popen3 = False
sys.path.append('cgi-bin')
os.chdir(webdir)
srvraddr = ("", port)
srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler)
srvrobj.serve_forever()
Start the script in the same directory as the cgi script and HTML.
Assuming you have a file that holds '1' time per date, you could
write a program to pickle and unpickle dictionaries that
are derived from form data:
import pickle
import cgi
file = open('dates.pkl', 'rb')
mydates = pickle.load(file)
file.close()
html = """
Schedule
"""
dates = ['april01', 'april02', 'april03', 'april04']
if form.has_key('submitted'):
newdates = {}
for d in dates:
if form.has_key(d):
newdates[d] = form[d].value
else:
newdates[d] = ''
mydates = newdates
output = open('dates.pkl', 'wb')
pickle.dump(mydates, output)
output.close()
else:
for d in dates:
if not mydates.has_key(d):
mydates[d] = ''
print html % mydates
Then you could write an additional program that runs
in the background or something:
import pickle
from datetime import date, datetime
mycode = 'print "Hello World!"'
file = open('dates.pkl', 'rb')
mydates = pickle.load(file)
file.close()
while True:
today = date.today()
if today.month == 4 and today.day == 01:
hour = datetime.time(datetime.now()).hour
min = datetime.time(datetime.now()).minute
if hour == int(mydates['april04'][0]) and min ==
int(mydates['april04'][-2:]):
exec mycode
_exec_ executes a Python string like a program. To execute an actual
python script use subprocess instead:
import subprocess
subprocess.call(["python", "myscript.py"])
Hope this helps.
On 10/05/2012 11:55 AM, Luca Sanna wrote:
hi,
I enter a calendar in an html page
in each calendar day, I enter a time that is used by the program to perform
actions with python
What can I use to do this?
thanks
--
http://mail.python.org/mailman/listinfo/python-list
Re: python game develop:framework?
Pygame is my favorite. It's mature, has good documentation, and has lots of unfinished and finished games on its website. It also supports OpenGL. http://www.pygame.org/ On 10/14/2012 01:58 AM, nepaul wrote: Something good framwork? -- http://mail.python.org/mailman/listinfo/python-list
Proper place for everything
Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a strange question, but I might as well start somewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
Yeah, alright. I've just found that if you mention anything about a library that has well established competitors, the post will tend to get ignored here. On 11/02/2012 04:38 AM, Robert Kern wrote: On 11/2/12 11:20 AM, Jason Benjamin wrote: Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a strange question, but I might as well start somewhere. There are plenty of good, free blog hosting options. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
It's a *really* old post, but it was back when I was first started learning Python when Python 3 wasn't out yet. It was a dumb question so I can see why people wouldn't have had interest in answering it, but I had been developing a game and wanted to find a recommendation on a GUI toolkit. Now that that's out, yes, I realize I could have searched the Internet for some ideas, but I tend to have tunnel vision when it comes to the Internet, much like modern teenagers seem to only realize they can communicate with Facebook. The incident may have been isolated, but I stereotype. On 11/02/2012 10:31 AM, Dennis Lee Bieber wrote: On Fri, 02 Nov 2012 06:49:18 -0700, Jason Benjamin declaimed the following in gmane.comp.python.general: Yeah, alright. I've just found that if you mention anything about a library that has well established competitors, the post will tend to get ignored here. Interesting... The oldest post still in my news reader's cache is October 17. Since that time, there are only two posts under your name in that cache, both in this thread. You should maybe provide some link to such a post so late-comers or others can find them... a message-ID could be useful... I'll concede some posts may have been removed from the cache due to filter actions (though for this group as found on gmane I only have three active filters, and your name is not in any of them). -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
On another note, it appears that Google (the only archive I can find for this group) only has a little under 400 messages archived for this group, while the slackware newsgroup has upwards 40,000 and contains posts I can't even remember that were made with one of the first emails I've ever used. On 11/02/2012 10:31 AM, Dennis Lee Bieber wrote: On Fri, 02 Nov 2012 06:49:18 -0700, Jason Benjamin declaimed the following in gmane.comp.python.general: Yeah, alright. I've just found that if you mention anything about a library that has well established competitors, the post will tend to get ignored here. Interesting... The oldest post still in my news reader's cache is October 17. Since that time, there are only two posts under your name in that cache, both in this thread. You should maybe provide some link to such a post so late-comers or others can find them... a message-ID could be useful... I'll concede some posts may have been removed from the cache due to filter actions (though for this group as found on gmane I only have three active filters, and your name is not in any of them). -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
Yeah, now that I take a look at the said old post on this group, I can see why the post was ignored: http://markmail.org/thread/mnxpzt4jzx3zjeio On 11/02/2012 01:05 PM, Tim Golden wrote: On 02/11/2012 18:51, Jason Benjamin wrote: On another note, it appears that Google (the only archive I can find for this group) only has a little under 400 messages archived for this group http://mail.python.org/pipermail/python-list/ http://markmail.org/search/?q=python#query:python%20list%3Aorg.python.python-list+page:1+state:facets and doubtless others. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: Import by filename is not supported when unpickleing
On Wed, 27 Jul 2016 17:25:43 -0400, Larry Martell wrote: > When I try and unpickle an object with pickle.loads it fails with: > > ImportError: Import by filename is not supported when unpickleing > > I've never used pickle before. Why do I get this and how can I fix it? Try using *pickle.load* instead of *pickle.loads*. pickle.loads is for strings. Retrieved from documentation: help(pickle) after importing pickle. -- [The Computer] was the first machine man built that assisted the power of his brain instead of the strength of his arm. - Grace Hopper -- https://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to draw a BUTTON?
On Wed, 27 Jul 2016 13:18:16 -0700, huey.y.jiang wrote: > Hi Folks, > > It is common to put a BUTTON on a canvas by the means of coding. > However, in my application, I need to draw a circle on canvas, and then > make this circle to work as if it is a button. When the circle is > clicked, it triggers a new image to be displayed. Somebody can help? > Thanks! It depends on what GUI toolkit you use. Can you give more specific information? Since a canvas is refreshed (updated) every time the function for redraw is called, it is as simple as changing the variable for what should be drawn when a click event is sent to the canvas and the area hot-spot is the same as the area of the button. Buffered drawing is similar. -- [The Computer] was the first machine man built that assisted the power of his brain instead of the strength of his arm. - Grace Hopper -- https://mail.python.org/mailman/listinfo/python-list
