Re: (no subject)

Aivar Annamaa <[email protected]> Wed, 4 Mar 2020 22:47:26 +0200
Newsgroups gmane.comp.python.tkinter
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============3898147774529471507==
Content-Type: multipart/alternative;
 boundary="------------F0C5A4C7671F99EF088B91FB"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------F0C5A4C7671F99EF088B91FB
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

This question is discussed here: 
https://stackoverflow.com/questions/20891710/what-magic-prevents-tkinter-programs-from-blocking-in-interactive-shell

Best regards,
Aivar


On 04.03.2020 17:33, Vasilis Vlachoudis wrote:
> I had the impression that tkinter is single threaded, but it seems 
> that the breakpoint() or input()
> does not block the mainloop to continue
> If one clicks the second button that waits for an input or enter in 
> the breakpoint()
> the mainloop is still responsive while it waits for an input. So one 
> can click any button
> the first to display the message or the second that will abort with a 
> message that readline cannot
> be re-entered?
>
> Why is that? What other commands can trigger such a behavior?
>
> import tkinter as tk
>
> def boinc():
> for i in range(10):
> print("boinc...")
>
> def debug():
> #breakpoint()
> print("Breakpoint")
> print("Input: ",end="")
> s = input()
> print("Entered:", s)
>
> #-------------------------------------------------------------------------------
> if __name__ == "__main__":
> root = tk.Tk()
> b = tk.Button(root, text="Boinc", command=boinc)
> b.pack()
> b = tk.Button(root, text="Debug", command=debug)
> b.pack()
> root.mainloop()
>
> _______________________________________________
> Tkinter-discuss mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/tkinter-discuss

--------------F0C5A4C7671F99EF088B91FB
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>This question is discussed here: <a
href="https://stackoverflow.com/questions/20891710/what-magic-prevents-tkinter-programs-from-blocking-in-interactive-shell">https://stackoverflow.com/questions/20891710/what-magic-prevents-tkinter-programs-from-blocking-in-interactive-shell</a></p>
    <p>Best regards,<br>
      Aivar</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 04.03.2020 17:33, Vasilis Vlachoudis
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style>#cVim-command-bar, #cVim-command-bar-mode, #cVim-command-bar-input, #cVim-command-bar-search-results,
.cVim-completion-item, .cVim-completion-item .cVim-full, .cVim-completion-item .cVim-left,
.cVim-completion-item .cVim-right {
  font-family: Helvetica, Helvetica Neue, Neue, sans-serif, monospace, Arial;
  font-size: 10pt !important;
  -webkit-font-smoothing: antialiased !important;
}

#cVim-command-bar {
  position: fixed;
  z-index: 2147483646;
  background-color: #1b1d1e;
  color: #bbb;
  display: none;
  box-sizing: content-box;
  box-shadow: 0 3px 3px rgba(0,0,0,0.4);
  left: 0;
  width: 100%;
  height: 20px;
}

#cVim-command-bar-mode {
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  padding-left: 2px;
  height: 100%;
  width: 10px;
  padding-top: 2px;
  color: #888;
}

#cVim-command-bar-input {
  background-color: #1b1d1e;
  color: #bbb;
  height: 100%;
  right: 0;
  top: 0;
  width: calc(100% - 10px);
  position: absolute;
}

#cVim-command-bar-search-results {
  position: fixed;
  width: 100%;
  overflow: hidden;
  z-index: 2147483647;
  left: 0;
  box-shadow: 0 3px 3px rgba(0,0,0,0.4);
  background-color: #1c1c1c;
}

.cVim-completion-item, .cVim-completion-item .cVim-full, .cVim-completion-item .cVim-left, .cVim-completion-item .cVim-right {
  text-overflow: ellipsis;
  padding: 1px;
  display: inline-block;
  box-sizing: border-box;
  vertical-align: middle;
  overflow: hidden;
  white-space: nowrap;
}

.cVim-completion-item:nth-child(even) {
  background-color: #1f1f1f;
}

.cVim-completion-item {
  width: 100%; left: 0;
  color: #bcbcbc;
}

.cVim-completion-item[active] {
  width: 100%; left: 0;
  color: #1b1d1e;
  background-color: #f1f1f1;
}

.cVim-completion-item[active] span {
  color: #1b1d1e;
}

.cVim-completion-item .cVim-left {
  color: #fff;
  width: 37%;
}

.cVim-completion-item .cVim-right {
  font-style: italic;
  color: #888;
  width: 57%;
}


#cVim-link-container, .cVim-link-hint,
#cVim-hud, #cVim-status-bar {
  font-family: Helvetica, Helvetica Neue, Neue, sans-serif, monospace, Arial;
  font-size: 10pt !important;
  -webkit-font-smoothing: antialiased !important;
}

#cVim-link-container {
  position: absolute;
  pointer-events: none;
  width: 100%; left: 0;
  height: 100%; top: 0;
  z-index: 2147483647;
}

.cVim-link-hint {
  position: absolute;
  color: #302505 !important;
  background-color: #ffd76e !important;
  border-radius: 2px !important;
  padding: 2px !important;
  font-size: 8pt !important;
  font-weight: 500 !important;
  text-transform: uppercase !important;
  border: 1px solid #ad810c;
  display: inline-block !important;
  vertical-align: middle !important;
  text-align: center !important;
  box-shadow: 2px 2px 1px rgba(0,0,0,0.25) !important;
}

.cVim-link-hint_match {
  color: #777;
  text-transform: uppercase !important;
}


#cVim-hud {
  background-color: rgba(28,28,28,0.9);
  position: fixed !important;
  transition: right 0.2s ease-out;
  z-index: 24724289;
}

#cVim-hud span {
  padding: 2px;
  padding-left: 4px;
  padding-right: 4px;
  color: #8f8f8f;
  font-size: 10pt;
}

#cVim-frames-outline {
  position: fixed;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  right: 0;
  z-index: 9999999999;
  box-sizing: border-box;
  border: 3px solid yellow;
}
</style>
      <style type="text/css" id="owaParaStyle"></style>
      <div style="direction: ltr;font-family: Tahoma;color:
        #000000;font-size: 10pt;">I had the impression that tkinter is
        single threaded, but it seems that the breakpoint() or input()
        <div>does not block the mainloop to continue<br>
          <div>If one clicks the second button that waits for an input
            or enter in the breakpoint()</div>
          <div>the mainloop is still responsive while it waits for an
            input. So one can click any button</div>
          <div>the first to display the message or the second that will
            abort with a message that readline cannot</div>
          <div>be re-entered?</div>
          <div><br>
          </div>
          <div>Why is that? What other commands can trigger such a
            behavior?</div>
          <div><br>
          </div>
          <div>
            <div><span style="font-size: 13.3333px;">import tkinter as
                tk</span></div>
            <div><span style="font-size: 13.3333px;"><br>
              </span></div>
            <div><span style="font-size: 13.3333px;">def boinc():</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>for
                i in range(10):</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>print("boinc...")</span></div>
            <div><span style="font-size: 13.3333px;"><br>
              </span></div>
            <div><span style="font-size: 13.3333px;">def debug():</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>#breakpoint()</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>print("Breakpoint")</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>print("Input:
                ",end="")</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>s
                = input()</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>print("Entered:",
                s)</span></div>
            <div><span style="font-size: 13.3333px;"><br>
              </span></div>
            <div><span style="font-size: 13.3333px;">#-------------------------------------------------------------------------------</span></div>
            <div><span style="font-size: 13.3333px;">if __name__ ==
                "__main__":</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>root
                = tk.Tk()</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>b
                = tk.Button(root, text="Boinc", command=boinc)</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>b.pack()</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>b
                = tk.Button(root, text="Debug", command=debug)</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>b.pack()</span></div>
            <div><span style="font-size: 13.3333px;"><span style="white-space:pre"></span>root.mainloop()</span></div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Tkinter-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/tkinter-discuss">https://mail.python.org/mailman/listinfo/tkinter-discuss</a>
</pre>
    </blockquote>
  </body>
</html>

--------------F0C5A4C7671F99EF088B91FB--

--===============3898147774529471507==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss

--===============3898147774529471507==--