Search Results

Search found 6 results on 1 pages for 'pythonscript'.

Page 1/1 | 1 

  • Segmentation fault when running a python script/GTKBuilder app?

    - by pythonscript
    I'm trying to learn GUI programming using python2 and GTKBuilder, but I get a segmentation fault when I run the code. This is my file, created in Glade as a GTKBuilder file: <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.0 --> <object class="GtkWindow" id="mainWindow"> <property name="can_focus">False</property> <child> <object class="GtkBox" id="box1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> <child> <object class="GtkBox" id="box2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> <property name="margin_left">146</property> <property name="margin_right">276</property> <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">label</property> </object> <packing> <property name="expand">True</property> <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkEntry" id="entryName"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="margin_bottom">4</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="invisible_char">?</property> <property name="placeholder_text">Please enter your name here...</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkButton" id="buttonWriteNameToFile"> <property name="label" translatable="yes">button</property> <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> <signal name="clicked" handler="buttonWriteNameToFile_clicked" swapped="no"/> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> <child> <placeholder/> </child> <child> <placeholder/> </child> </object> </child> </object> </interface> My python code, based on this question, is this: #!/usr/bin/env python import gtk class NameApp: def __init__(self): filename = "project.glade" builder = gtk.Builder() builder.add_from_file(filename) builder.connect_signals(self) builder.get_object("mainWindow").show_all() def buttonWriteNameToFile_clicked(self, widget): print("File write code...") if __name__ == "__main__": app = NameApp() gtk.main() Running the file with python2 yields this error: name.py:9: Warning: cannot create instance of abstract (non-instantiatable) type `GtkBox' builder.add_from_file(filename) ./geany_run_script.sh: line 5: 14897 Segmentation fault python2 "name.py" I thought I followed that example as closely as possible, and I don't see any differences outside of the GTKBuilder file. However, the example in the linked question runs successfully on my machine. I don't know if it's relevant, but I'm running Arch Linux x86_64.

    Read the article

  • Mathematica Plot3D does not produce a plot when graphing a user-defined function?

    - by pythonscript
    I'm writing a simple Mathematica implementation of the black-scholes model and using Plot3D to plot the pricing surface. However, when I run this code, no plot is produced. My call and put functions to produce correct values when run separately, but no plot is produced. Code: Clear[d1, d2, call, put, stockPrice, strikePrice, riskFreeRate, timeToExp, volatility] d1[stockPrice_, strikePrice_, riskFreeRate_, timeToExp_, volatility_] := (Log[stockPrice / strikePrice] + (riskFreeRate + 0.5*volatility^2)*timeToExp) / (volatility * Sqrt[timeToExp]) d2[stockPrice_, strikePrice_, riskFreeRate_, timeToExp_, volatility_] := d1[stockPrice, strikePrice, riskFreeRate, timeToExp, volatility] - volatility*Sqrt[timeToExp] call[stockPrice_, strikePrice_, riskFreeRate_, timeToExp_, volatility_] := stockPrice * CDF[NormalDistribution[0, 1], d1[stockPrice, strikePrice, riskFreeRate, timeToExp, volatility]] - strikePrice * Exp[-riskFreeRate*timeToExp] *CDF[NormalDistribution[0, 1], d2[stockPrice, strikePrice, riskFreeRate, timeToExp, volatility]] Plot3D[call[stockPrice, 500, 0.0030, timeToExp, 0.39], {stockPrice, 10, 1000}, {timetoExp, 0.0833333, 5}] Other plots, like this sample from the reference, do work. Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 4], BoxRatios -> Automatic]

    Read the article

  • Log of cron actions on OS X

    - by Doug Harris
    Does the cron which comes with OS X log its actions anywhere? I'm not looking for output of any particular cron job, but rather log of what cron is doing. On a couple linux machines I've checked, there's /var/log/cron which has contents like: Apr 26 11:00:01 localhost crond[27755]: (root) CMD (/root/bin/mysql-backup) Apr 26 11:01:01 localhost crond[27892]: (root) CMD (run-parts /etc/cron.hourly) Apr 26 11:07:01 localhost crond[28138]: (root) CMD (/usr/local/bin/python /home/ user1/scripts/pythonscript.py) Apr 26 11:18:18 localhost crontab[28921]: (user2) LIST (user2) Apr 26 11:18:22 localhost crontab[28929]: (user2) BEGIN EDIT (user2) Apr 26 11:18:59 localhost crontab[28929]: (user2) REPLACE (user2) This shows when jobs ran, when users viewed or edited crontabs, etc. This stuff is nowhere that I've found on my Snow Leopard machine.

    Read the article

  • Are there viable alternatives for Web 2.0 apps besides lots of Javascript?

    - by djembe
    If you say find C-style syntax to be in the axis of evil are you just hopelessly condemned to suck it up and deal with it if you want to provide your users with cool web 2.0 applications - for example stuff that's generally done using JQuery and Ajax etc? Are there no other choices out there? We're currently building intranet apps using pylons and a bunch of JavaScript along with a bit of Evoque. So obviously for us the world would be a better place if instead something equivalent existed written in like PythonScript. But I've yet to seen anything approaching that aside from the Android system's ASE - but obviously that's something rather unrelated. Still - if browsers could support other scripting languages....

    Read the article

  • What is the best way to parse python script file in C/C++ code

    - by alexpov
    I am embedding python in C/C++ program. What I am trying to do is to parse the python script file from the C/C++ program, break the file to "blocks" so that each "block" is an a valid command in python code. Each block I need to put into std::string. For example: #PythonScript.py import math print "Hello Python" i = 0; while (i < 10): print "i = " , i; i = i + 1; print "GoodBye Python" In this script are 5 different "blocks": the first one is "import math;" the second is "print "Hello Python;" the third is "i = 0;" and the fourth is while (i < 10):\n\tprint "i = " , i;\n\ti = i + 1; My knowledge in python is very basic and I am not familiar with the python code syntax. What is the best way to do this, is there any Python C/C++ API function that supports this? why i need it - for GUI purpose. My program , which is writen in C, uses python to make some calculations. I run from C code , using python C API , python script and what i need is a way to capture python's output in my program. I catch it and evrything is ok, the problem is when the script involves user input. What happens is that i capture python's output after the script is finished , therefore, when there is an input command in the script i get a black screen .... i need to get all the printings before the input command. The first solution i tried is to parss the script to valid commands and run each comand, one after the other , seperatly .... for this i need to pars the script and deside what is a command and what is not ... The question is : what is the best way to do this and if there is somthing that allready does ?

    Read the article

  • cgi.FieldStorage always empty - never returns POSTed form Data

    - by Dan Carlson
    This problem is probably embarrassingly simple. I'm trying to give python a spin. I thought a good way to start doing that would be to create a simple cgi script to process some form data and do some magic. My python script is executed properly by apache using mod_python, and will print out whatever I want it to print out. My only problem is that cgi.FieldStorage() is always empty. I've tried using both POST and GET. Each trial I fill out both form fields. <form action="pythonScript.py" method="POST" name="ARGH"> <input name="TaskName" type="text" /> <input name="TaskNumber" type="text" /> <input type="submit" /> </form> If I change the form to point to a perl script it reports the form data properly. The python page always gives me the same result: number of keys: 0 #!/usr/bin/python import cgi def index(req): pageContent = """<html><head><title>A page from""" pageContent += """Python</title></head><body>""" form = cgi.FieldStorage() keys = form.keys() keys.sort() pageContent += "<br />number of keys: "+str(len(keys)) for key in keys: pageContent += fieldStorage[ key ].value pageContent += """</body></html>""" return pageContent I'm using Python 2.5.2 and Apache/2.2.3. This is what's in my apache conf file (and my script is in /var/www/python): <Directory /var/www/python/> Options FollowSymLinks +ExecCGI Order allow,deny allow from all AddHandler mod_python .py PythonHandler mod_python.publisher </Directory>

    Read the article

1