Inkscape.org
Using Inkscape with Other Programs Tkinter- How to avoid this blank pop-up for Inkscape?
  1. #1
    PlsHelp PlsHelp @PlsHelp
    *

    Hi everyone, I have a problem to test the Tkinter in Inkscape

    I would like to request someone who have use Tkinter before with Inkscape could solve my doubt or lead me. I have made a Tkinter extension for Inkscape

    My expected output with Tkinter is it can be read the various shape elements' id by selecting them one by one.

    However,I realize that there is a blank pop-up window when I am using Tkinter with Inkscape, does anyone know is there possible to disable that?

    Next, since there is a blank pop-out window, it might block me to interact with Inkscape while the Tkinter program is runnning. When I select other shape element Inkscape would force to not responding.

    I really hope someone can solve this problem.

    There are the attachment of video and the code to show my current problem 

    Thank You

    gui_WhatisThisID.py

    import inkex

    import tkinter as tk

    root = tk.Tk()

    root.title("What is this ID?")

    root.geometry("300x200")

    id_var = tk.StringVar()

    id_label = tk.Label(root, text = 'What is this element ID? ', font=("Times Roman",12)).pack(padx = 10, pady=10)

    class WhatisThisIDExtension(inkex.EffectExtension):

        

        def effect(self):

            

            my_objects = self.svg.selected

            id_entry = tk.Entry(root, textvariable = id_var, width = 15)

            id_entry.pack(padx =10 ,pady = 10) 

            for object in my_objects:

                my_id = object.attrib['id']

                id_entry.delete(0,'end')

                id_entry.insert(0,my_id)

    if __name__ == '__main__':

        WhatisThisIDExtension().run()

        root.mainloop()

    whatisthisid.inx

    <?xml version="1.0" encoding="UTF-8"?>

    <inkscape-extension>

        <_name>Problem</_name>

        <id>org.inkscape.whatisthisid</id>

        <dependency type="executable" location="extensions">gui_WhatisThisID.py</dependency>

        <dependency type="executable" location="extensions">inkex.py</dependency> 

      <effect needs-live-preview="false" implements-custom-gui = "True">

        <object-type>all</object-type>

        <effects-menu>

          <submenu name="Problem"/>

        </effects-menu>

      </effect>

     

      <script>

            <command reldir="extensions" interpreter="python">gui_WhatisThisObject.py</command>

      </script>

     

    </inkscape-extension>

     

     

  2. #2
    inklinea inklinea @inklinea⛰️

     

    <?xml version="1.0" encoding="UTF-8"?>

    <inkscape-extension>

        <_name>Problem</_name>

        <id>org.inkscape.whatisthisid</id>

      <effect needs-live-preview="false" implements-custom-gui="true">

        <object-type>all</object-type>

        <effects-menu>

          <submenu name="Problem"/>

        </effects-menu>

      </effect>

     

      <script>

            <command reldir="extensions" interpreter="python">gui_WhatisThisID.py</command>

      </script>
     
    </inkscape-extension>

    Screenshot From 2021 06 28 17 07 45
  3. #3
    PlsHelp PlsHelp @PlsHelp

    Hi, inklinea. First of all for reply me my question. I have tried to remove those dependency tags as you mentioned above. It's worked and the blank pop-up did not appear anymore. Thank You.


    However, I still have the problem as I stated lastly, I cannot interact with the Inkscape when the Tkinter is running. it will force you to not responding...


    There is the attachment of the video to show my problem

    Thank you very much.

  4. #4
    inklinea inklinea @inklinea⛰️

    It's not possible. 

    Inkscape runs the python script, and passes the svg and metadata.

    Tkinter or GTK3 both are part of the python script.

    They can access the svg and metadata which was passed to them, but they cannot either pass back a selection or trigger a preview update.

    The python script must terminate to return to Inkscape.

Inkscape Inkscape.org Inkscape Forum Using Inkscape with Other Programs Tkinter- How to avoid this blank pop-up for Inkscape?