In Mechanize, how to set the x,y value of ImageButton?
Question: I am using Mechanize Python as the web client to submit a form. However, I did
not find a way to set the x,y of ImageButton in this form.

I have tried different ways:

1) the first is to find the control:

    
    
    bt = frm.find_control('ImageButtonID')
    bt.x = 88
    bt.y = 10
    

2) the second one is to use a dictionary:

    
    
    ctls = {}
    ctls['ImageButton1.x'] = 88
    ctls['ImageButton1.y'] = 10
    data = urllib.urlencode(ctls)
    br.open(url,data)
    

But none of the ways works, Is there any solution? thanks a lot

Here is the html code:

TITLE function EnterTo(){ if (window.event.keyCode == 13){ form1.submit(); } }
function ChangeImage() { document.getElementById("yzm").src =
document.getElementById("yzm").src+'?'; }

    
    
    <input name="deptID" type="hidden" id="deptID" value="1" /> <input name="dateType" type="hidden" id="dateType" value="Today" />
    <input name="timeType" type="hidden" id="timeType" value="AM" />
    
    <div class="numberBG">
    <div class="Repeater">
        <table class="Item">
    
        <tr>
            <td>
                                        <input type="image" name="Repeater1$ctl00$ImageButton1" id="Repeater1_ctl00_ImageButton1" title="XXXXXXXX" src="images/1_1.jpg" style="border-width:0px;" />
            </td>
        </tr>
    </table>        
    <table class="table">
        <tr>
            <td style="width:100px;" class="txt">the code</td>
            <td style="width:90px;"><input name="Txt_Yzm" type="text" id="Txt_Yzm" onkeydown="if(event.keyCode==13)event.keyCode=9 " style="width:90px;" />
            <td style="width:50px;"><img src="../../gif.aspx?" id="yzm" onclick="ChangeImage();" alt="try again" style="width:50px;height:24px"></td>
            </tr>
        <tr>
        <td colSpan="3" style="width:240px;"><select name="DropDownList1" id="DropDownList1" style="width:240px;">
    

From the Chrome, I find the post data is

__VIEWSTATE=%2FwEPDwUJMjE0NzU0MTk4D2QWAmYPZBYIAgMPDxYCHgRUZXh0BQnotKLliqHpg6hkZAIEDw8WAh8ABRfnlKjmiLfvvJo1NTczL%2BWImOWtpuS6rmRkAgUPFgIeC18hSXRlbUNvdW50AgQWCGYPZBYEAgEPDxYCHwAFLOWFseWPluWPt1s3NV3lvZPliY3lj7dbMT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gkCz6%2BuzAH2E8Hvp9iYVUtn77jo3FKnheOfhg%3D%3D


Answer: From the look of the HTML mechanize can't handle submitting of this form. As
you already know which data to post try to do it manually by using `urllib`
and `urllib2` to post data:

    
    
    import urllib
    import urllib2
    url = 'http://example.com'
    form_data = {'field1': 'value1', 'field2': 'value2'}
    params = urllib.urlencode(form_data)
    response = urllib2.urlopen(url, params)
    data = response.read()
    

