Using wx.html2, there are some strange points when using button tag

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using wx.html2, there are some strange points when using button tag

다크매터
import wx.html2
import re
import os
import cx_Oracle


class Main(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, style=wx.DEFAULT_FRAME_STYLE)
        self.MainHtml2WebView = wx.html2.WebView.New(self, size=(0, 0), backend=wx.html2.WebViewBackendIE)

        self.MainFirstPage()

    def MainFirstPage(self):
        self.FirstPage = """
        <!DOCTYPE html>
            <html lang=ko>
            <style text=text/css>   
                html, body{{height:100%;}}      
                div.up{{margin:50px auto;}}                         
                .button{{               
                    width:400px;
                    background-color:orange;
                    border:none;
                    color:#fff;
                    padding:100px;
                    text-align:center;
                    text-decoration:none;   
                    font-weight:bold;            
                    font-size:100px;
                    margin:300px auto;
                    cursor:pointer;     
                }}
            </style>
                <head>
                    <meta charset=UTF-8>    
                    <title>TITLE</title>    
                </head>                     
                <body scroll="no">
                    <div class=up>
                        <center><img src=9.png></center>                    
                    </div>                  
                    <div class=down>
                        <center><input type=button class=button value=clcik onclick="location.href='{nextpage}'"></input></center>
                    </div>  
                </body>         
            </html>         
        """
        self.Department()
        self.MainHtml2WebView.SetPage(self.FirstPage.format(nextpage=re.sub(r'\s+', " ", self.DepartmentChoie)), "")

    def Department(self):
        self.DepartmentChoie = """
        <!DOCTYPE html>
            <html lang=ko>
            <style text=text/css>   
                html, body{{height:100%;}}                                                  
                .obgy{{         
                    width:500px;
                    background-color:orange;
                    border:none;
                    color:white;
                    padding:100px;
                    text-align:center;
                    text-decoration:none;   
                    font-weight:bold;            
                    font-size:50px;
                    margin:50px auto;
                    cursor:pointer;     
                    position:relative;
                }}
                .pd{{       
                    width:500px;
                    background-color:pink;
                    border:none;
                    color:white;
                    padding:100px;
                    text-align:center;
                    text-decoration:none;   
                    font-weight:bold;            
                    font-size:50px;
                    margin:50px auto;
                    cursor:pointer;     
                    position:relative;      
                }}  
                .fm{{               
                    width:500px;
                    background-color:blue;
                    border:none;
                    color:white;
                    padding:100px;
                    text-align:center;
                    text-decoration:none;   
                    font-weight:bold;            
                    font-size:50px;
                    margin:50px auto;
                    cursor:pointer;     
                    position:relative;      
                }}          
            </style>
                <head>
                <meta charset=UTF-8 />  
                    <title>TITLE2</title>   
                </head>                     
                    <body scroll=no>
                        <div>                   
                            <center>
                                <input type=button class=obgy value=TEST1 onclick="location.href='{obgypage}'">
                                <input type=button class=pd value=TEST2>            
                                <input type=button class=fm value=TEST3>
                            </center>                   
                        </div>                                      
                    </body>         
            </html> 
            """
        self.obgy()
        self.MainHtml2WebView.SetPage(self.DepartmentChoie.format(obgypage=re.sub(r'\s+', " ", self.obgychoice)), "")

    def obgy(self):
        self.obgychoice = """
        <!DOCTYPE html>
            <html lang=ko>
            <style text=text/css>   
                html, body{{height:100%;}}                                                  
                .ob{{           
                    width:500px;
                    background-color:orange;
                    border:none;
                    color:white;
                    padding:100px;
                    text-align:center;
                    text-decoration:none;   
                    font-weight:bold;            
                    font-size:50px;
                    margin:50px auto;
                    cursor:pointer;     
                    position:relative;
                }}
                .gy{{       
                    width:500px;
                    background-color:pink;
                    border:none;
                    color:white;
                    padding:100px;
                    text-align:center;
                    text-decoration:none;   
                    font-weight:bold;            
                    font-size:50px;
                    margin:50px auto;
                    cursor:pointer;     
                    position:relative;      
                }}                
            </style>
                <head>
                <meta charset=UTF-8 />  
                    <title>TITLE2</title>   
                </head>                     
                    <body scroll=no>
                        <div>
                            <center>
                                <input type=button class=ob value=TEST1></input>                    
                                <input type=button class=gy value=TEST2></input>                           
                            </center>
                        </div>                                      
                    </body>         
            </html> 
            """

if __name__ == '__main__':
    app = wx.App()
    fream = Main()
    fream.Show(True)
    app.MainLoop()


My code is simple html like above using wx.html2. I'm using the input button tag to open the next page.

Serious here? I found something strange.

The first is that when you load the page, you can not load the page if you use a comma in all the html, and the second you have to make all the html code in one line with the regular expression.

I do not know why the comma is allowed, but this only worked onclick = "location.href = ''"function.

The first page can load self.DepartmentChoie html using onclick = "location.href = '{nextpage}'"

Second page onclick = "location.href = '{obgypage}'" can not be called. This is because the onclick = "location.href = ''" function has a comma. There is no word.

I've tried countless ways, but I could only load the first page with the onclick = "location.href = ''" function. Another way I would like to know how to load the self.FirstPage -> self.DepartmentChoie -> self.obgychoice page using the button. Other modules are also good. Other ways are also good. I really need help

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wx.html2, there are some strange points when using button tag

Tim Roberts
On May 11, 2018, at 9:03 PM, 다크매터 <[hidden email]> wrote:

My code is simple html like above using wx.html2. I'm using the input button tag to open the next page.

Serious here? I found something strange.

The first is that when you load the page, you can not load the page if you use a comma in all the html, and the second you have to make all the html code in one line with the regular expression.

What comma?  Where?  What regular expression?

The return here has to be a string.  If you do this:
    return "xyz", "abc"
you are returning a tuple, not a string.  You can certainly create your HTML as a tuple or a list, as long as you join it into a single string before you return it:
    return ''.join( ("xyz","abc") )


I do not know why the comma is allowed, but this only worked onclick = "location.href = ''"function.

I don't know what you mean, but the code you have there is Javascript that will be executed in the client, not Python that will be executed in the web server.

Second page onclick = "location.href = '{obgypage}'" can not be called. This is because the onclick = "location.href = ''" function has a comma. There is no word.

What comma?  Where?
— 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wx.html2, there are some strange points when using button tag

다크매터

Thank you for your reply.

1.html Comma separator. self.DepartmentChoie For example, if you create <body scroll = 'no'> in your html code, you can not call self.FirstPage html onclick = "location.href = '{nextpage}'". This is something strange. 2. Regular expressions make up one line of html code to load. This is the only way to load self.DepartmentChoie html from self.FirstPage onclick = "location.href = '{nextpage}'" code. Other than this, it did not succeed. 3. I was trying to load the self.obgychoice page from the self.DepartmentChoie html code, but I thought I could not load it because of the onclick = "location.href = '{}'" comma separator. In my opinion, when using the onclick = location.href function, I do not think it's due to the combo-delimited section.

2018년 5월 14일 월요일 오전 4시 30분 5초 UTC+9, Tim Roberts 님의 말:
On May 11, 2018, at 9:03 PM, 다크매터 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="G6FzrNkRCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">abel...@...> wrote:

My code is simple html like above using wx.html2. I'm using the input button tag to open the next page.

Serious here? I found something strange.

The first is that when you load the page, you can not load the page if you use a comma in all the html, and the second you have to make all the html code in one line with the regular expression.

What comma?  Where?  What regular expression?

The return here has to be a string.  If you do this:
    return "xyz", "abc"
you are returning a tuple, not a string.  You can certainly create your HTML as a tuple or a list, as long as you join it into a single string before you return it:
    return ''.join( ("xyz","abc") )


I do not know why the comma is allowed, but this only worked onclick = "location.href = ''"function.

I don't know what you mean, but the code you have there is Javascript that will be executed in the client, not Python that will be executed in the web server.

Second page onclick = "location.href = '{obgypage}'" can not be called. This is because the onclick = "location.href = ''" function has a comma. There is no word.

What comma?  Where?
— 
Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="G6FzrNkRCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wx.html2, there are some strange points when using button tag

Tim Roberts
On May 13, 2018, at 6:00 PM, 다크매터 <[hidden email]> wrote:

1.html Comma separator. self.DepartmentChoie For example, if you create <body scroll = 'no'> in your html code, you can not call self.FirstPage html onclick = "location.href = '{nextpage}'". This is something strange.

I understand there is a language barrier here, so I ask for patience while we work through this.

I simply do not understand what you mean by "html comma separator".  There aren't any commas in your HTML here.  Either you mean something else, or you're referring to commas in the Python, not in HTML.

However, you do have some very serious problems in your code.  When you use "{nextpage}", you are inserting the entire HTML of your second page in that spot (the contents of DepartmentChoie).  That's simply not how it works.  This is regular HTML being executed by a regular web browser.  The "location.href" value has to be a URL.  You can't just shove arbitrary HTML in there.

When you click that button, the browser will try to load that URL.  It will do that all on its own, as browsers always do, without involving your script at all.  It looks like you want those button clicks to call functions in your Python code.  THAT is complicated.  The WebView component can issue an EVT_WEBVIEW_NAVIGATING event when it is trying to switch to another page, and it is possible to catch that and provide the HTML code, but I'm wondering if wx.html2 is really the right solution for you.

It looks like you're trying to write a web application.  In that case, I'm wondering if you wouldn't be better off using something like Flask for CherryPy to write your web server.


2. Regular expressions make up one line of html code to load.

No, it absolutely does not.  You have a regular expression in your Python code, where you compact all long strings of spaces into a single space (which, by the way, is totally unnecessary).
 

This is the only way to load self.DepartmentChoie html from self.FirstPage onclick = "location.href = '{nextpage}'" code. Other than this, it did not succeed.

It's still not going to succeed.  self.DepartmentChoie is HTML code.  It is not a URL.  Location.href needs to be a URL.  It cannot be HTML.  It's just like writing a normal web page.


3. I was trying to load the self.obgychoice page from the self.DepartmentChoie html code, but I thought I could not load it because of the onclick = "location.href = '{}'" comma separator.

There is no comma there.  Again, I cannot guess what you're trying to say here.


In my opinion, when using the onclick = location.href function, I do not think it's due to the combo-delimited section.

No, your problems are misunderstanding the WebView control.  WebView is not tightly integrated with Python.  It is basically a standalone web browser.  In order to connect it to your Python code, you have to use events and callbacks.
— 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wx.html2, there are some strange points when using button tag

GadgetSteve


On 14/05/2018 03:18, Tim Roberts wrote:

> On May 13, 2018, at 6:00 PM, 다크매터 <[hidden email]
> <mailto:[hidden email]>> wrote:
>>
>> 1.html Comma separator. self.DepartmentChoie For example, if you
>> create <body scroll = 'no'> in your html code, you can not call
>> self.FirstPage html onclick = "location.href = '{nextpage}'". This is
>> something strange.
>
> I understand there is a language barrier here, so I ask for patience
> while we work through this.
>
> I simply do not understand what you mean by "html comma separator".
>   There aren't any commas in your HTML here.  Either you mean something
> else, or you're referring to commas in the Python, not in HTML.
>
Just to add a little clarity the Comma character or separator is , which
does not appear in any of the code example given. Please see
https://en.wikipedia.org/wiki/Comma for details.

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.
http://www.avg.com

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wx.html2, there are some strange points when using button tag

다크매터
In reply to this post by Tim Roberts
Thank you very much. 
I found a lot of answers. I thought I could load the self.DepartmentChoie html code from the self.FirstPage onclick = "location.href = '{nextpage}'" code so that I could load the next html code consecutively. The comma was quotation marks.

2018년 5월 14일 월요일 오전 11시 18분 31초 UTC+9, Tim Roberts 님의 말:
On May 13, 2018, at 6:00 PM, 다크매터 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="gbf0bSMoCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">abel...@...> wrote:

1.html Comma separator. self.DepartmentChoie For example, if you create <body scroll = 'no'> in your html code, you can not call self.FirstPage html onclick = "location.href = '{nextpage}'". This is something strange.

I understand there is a language barrier here, so I ask for patience while we work through this.

I simply do not understand what you mean by "html comma separator".  There aren't any commas in your HTML here.  Either you mean something else, or you're referring to commas in the Python, not in HTML.

However, you do have some very serious problems in your code.  When you use "{nextpage}", you are inserting the entire HTML of your second page in that spot (the contents of DepartmentChoie).  That's simply not how it works.  This is regular HTML being executed by a regular web browser.  The "location.href" value has to be a URL.  You can't just shove arbitrary HTML in there.

When you click that button, the browser will try to load that URL.  It will do that all on its own, as browsers always do, without involving your script at all.  It looks like you want those button clicks to call functions in your Python code.  THAT is complicated.  The WebView component can issue an EVT_WEBVIEW_NAVIGATING event when it is trying to switch to another page, and it is possible to catch that and provide the HTML code, but I'm wondering if wx.html2 is really the right solution for you.

It looks like you're trying to write a web application.  In that case, I'm wondering if you wouldn't be better off using something like Flask for CherryPy to write your web server.


2. Regular expressions make up one line of html code to load.

No, it absolutely does not.  You have a regular expression in your Python code, where you compact all long strings of spaces into a single space (which, by the way, is totally unnecessary).
 

This is the only way to load self.DepartmentChoie html from self.FirstPage onclick = "location.href = '{nextpage}'" code. Other than this, it did not succeed.

It's still not going to succeed.  self.DepartmentChoie is HTML code.  It is not a URL.  Location.href needs to be a URL.  It cannot be HTML.  It's just like writing a normal web page.


3. I was trying to load the self.obgychoice page from the self.DepartmentChoie html code, but I thought I could not load it because of the onclick = "location.href = '{}'" comma separator.

There is no comma there.  Again, I cannot guess what you're trying to say here.


In my opinion, when using the onclick = location.href function, I do not think it's due to the combo-delimited section.

No, your problems are misunderstanding the WebView control.  WebView is not tightly integrated with Python.  It is basically a standalone web browser.  In order to connect it to your Python code, you have to use events and callbacks.
— 
Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="gbf0bSMoCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.