I have a problem regarding the sending of data, I have already done a research in this subject but I did not find my answer so I ask for your help
I am building a desktop application with pyqt5 and python, and I would like that the information entered in the form on page 1 to be transferred to page 2
I don't see how to do it at all.
i never worked with PyQt but i can suggest for you a solution , you can use a class
with a static variable on the first page , and make a methode that can alter this variable
whenever you want , and in the other page you can import the class and get the value with a getter , for instance :
Page 1
class Class1 :
your_variable = ''
def set_variable(self,val) :
self.your_variable = val
def get_variable(self) :
return self.your_variable
Page 2
from Page1 import Class1
varibale = Class1.getvariable()
Related
I am not sure if this is possible but let me try to explain.
I am trying to post data from a form but before my data gets posted the website encrypts some of it, with a public key, that i am able to achieve from the response.text
I found the javascript that is used
var myVal = 123
n = (myVal, ClassName.create(publicKey);
n.encrypt(myVal)
The .encrypt returns the string that is passed to the form. My question is can I somehow bring that javascript into my script so I can execute that .encrypt method to pass that properly to the form?
if the script is simple,I will use pyexecjs
import execjs
js_cmd = '''
function add(x,y){
return x+y
}
'''
cxt = execjs.compile(js_cmd)
print(cxt.eval("add(3,4)"))
I have been working on this for couple days now. Can not really find how to make this work. I am fairly new to aspx websites and fetching information out of them.
I am trying to login/authenticate on a website that uses aspx pages. So I followed this thread which really helped me get this in motion. (Last Answer)
Following those directions, I write:
url = "http://samplewebsite/Main/Index.aspx" # Logon page
username = "user"
password = "password"
browser = RoboBrowser(history=True)
# This retrieves __VIEWSTATE and friends
browser.open(url)
signin = browser.get_form(id='form1')
print(signin)
This is the outcome of that print statement:
<RoboForm __VIEWSTATE=/wEPDwULLTE5ODM2NTU1MzJkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQlidG5TdWJtaXRriD1xvrfrHuJ/0xbQM08yEjyoUg==, __VIEWSTATEGENERATOR=E78488FE, adminid=, btnSubmit=, pswd=>
So it is obvious that I am retrieving the information correctly. Now I have 3 input fields:
adminid
btnSubmit
pswd
Which I can use in the following manner:
signin["adminid"].value = username
signin["pswd"].value = password
signin["btnSubmit"].value = "btnSubmit.x=29&btnSubmit.y=22"
My only problem is the last field btnSubmit which I do not know how to input a value since this is of the following type:
<input type="image" name="btnSubmit" id="btnSubmit" tabindex="3" src="../image/login_btn.gif" style="height:41px;width:57px;border-width:0px;" />
when I submit on the website, using the Chrome Tools I get the following outcome:
__VIEWSTATE:/wEPDwULLTE5ODM2NTU1MzJkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQlidG5TdWJtaXRriD1xvrfrHuJ/0xbQM08yEjyoUg==
__VIEWSTATEGENERATOR:E78488FE
adminid:user
btnSubmit.x:23
btnSubmit.y:15
pswd:password
Where basically the x,y positions are where I clicked on the page. Really do not know how to do this request through Python. Used this to no avail.
When you click on an input object of type image, two form values are set, the button name plus .x for the first, and .y for the other.
However, pressing Enter in a regular text input field will also submit a form, so you don't have to click on a submit button. I'd just leave the value empty altogether.
There is not much flexibility in the way robobrowser handles form submits, to avoid using the submit button you'd have to delete it from the form outright:
del signin.fields['btnSubmit']
before submitting.
If you must submit using the image button, then you'll have to teach Robobrowser how to handle that type; currently it has no handling for these. The following adds that:
from functools import wraps
from robobrowser.forms import form
from robobrowser.forms.fields import Submit, Input
class ImageSubmit(Submit):
def serialize(self):
return {self.name + '.x': '0', self.name + '.y': '0'}
def include_image_submit(parse_field):
#wraps(parse_field)
def wrapper(tag, tags):
field = parse_field(tag, tags)
if type(field) is Input: # not a subclass, exactly this class
if field._parsed.get('type') == 'image':
field = ImageSubmit(field._parsed)
return field
return wrapper
form._parse_field = include_image_submit(form._parse_field)
at which point you can use browser.submit_form(signin, signin['btnSubmit']) to submit the form and the correct fields will be included.
I've submitted a pull request to the robobrowser project to add image submit support.
I am learning website module of Odoo 9 and want to know the format of route expression. I am aware about the regex but could not get it completely. Take a look to this :-
class WebsiteBlog(http.Controller):
_blog_post_per_page = 20
_post_comment_per_page = 10
# codes
#http.route([
'/blog/<model("blog.blog"):blog>',
'/blog/<model("blog.blog"):blog>/page/<int:page>',
'/blog/<model("blog.blog"):blog>/tag/<string:tag>',
'/blog/<model("blog.blog"):blog>/tag/<string:tag>/page/<int:page>',
], type='http', auth="public", website=True)
def blog(self, blog=None, tag=None, page=1, **opt):
print 123
# etc
You can find this code on Git: Website Blog Module
I want to understand these expression. I can understand that this function will be executed if any one of these four URL will be requested by the browser and blog, tag and page are the variables but what is the meaning of this model(blog.blog) here ?
It defines that you are passing a value in URL is the record of the model blog.blog.
Ex.
your url like this..
localhost:8069/blog/3
Then in the controller you will get the record of model blog.blog which is having id = 3.
I am working with python web.py framework,i had an anchor tag with html code as below for example
<p><a href = "/edit.py?tr=%d"%1>Edit</a></p>
So when i click this link it goes to edit.py file in my project directory, but as you observe i am passing some values after edit.py like /edit.py?tr=%d"%1. Actually i will pass these values dynamically in further process.
Here after redirecting to edit.py, how to access the values after ? from the py file?
because my intention is to edit the record after saving in to database.
You can get them using web.input, e.g.
def GET(self):
data = web.input()
tr = data.tr
Documentation is avaliable here: http://webpy.org/cookbook/input
As the title suggests, I'm trying to pass parameters into my cgi script so that when you type in (for example): www.helloworld.com/cgi-bin/world.py?post=101, the script will display that post
I've tried the following:
link = 'test' % postNumber
link = cgi.FieldStorage()
id = link.getvalue('post')
print id
but the value of id is nothing. It's like it's not reading the link properly or something.
Please help!
How about:
id = link["post"].value
print id