Grammalecte  Check-in [20cfc29a6c]

Overview
Comment:[lo] launch Python console from About dialog
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: 20cfc29a6c59719b37644b660f3966dbf6bfc40fd71cb85500c6af197c72c119
User & Date: olr on 2019-07-12 15:03:05
Other Links: manifest | tags
Context
2019-07-12
17:40
[lo] update helpers check-in: cec1932c20 user: olr tags: trunk, lo
15:03
[lo] launch Python console from About dialog check-in: 20cfc29a6c user: olr tags: trunk, lo
13:19
[fr] ajustements et faux positif check-in: c208e13e3e user: olr tags: trunk, fr
Changes

Modified gc_core/py/oxt/helpers.py from [f1e81ad455] to [fdf5448ff6].

1
2
3
4

5
6
7
8
9
10
11
12


13
14
15
16
17
18
19







20

21
22
23

24
25
26
27
28
29
30

31
32
33
34
35
36
37
1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38

39
40
41
42
43
44
45
46




+







-
+
+







+
+
+
+
+
+
+
-
+


-
+






-
+







# Helpers for LibreOffice extension

import os
import traceback
import subprocess

import uno

from com.sun.star.beans import PropertyValue
from com.sun.star.uno import RuntimeException as _rtex


def apso_console ():
def start_console ():
    "open console from APSO extension"
    try:
        ctx = uno.getComponentContext()
        ctx.ServiceManager.createInstance("apso.python.script.organizer.impl")
        # now we can import apso_utils library
        from apso_utils import console
        console()
    except:
        try:
            ctx = uno.getComponentContext()
            xSvMgr = ctx.getServiceManager()
            xPathSettings = xSvMgr.createInstanceWithContext("com.sun.star.util.PathSettings", ctx)
            spPyInstallion = uno.fileUrlToSystemPath(xPathSettings.Module)
            subprocess.Popen(spPyInstallion + os.sep + "python")  # Start Python interactive Shell
        except:
        traceback.print_exc()
            traceback.print_exc()


def xray (myObject):
def xray (xObject):
    "XRay - API explorer"
    try:
        sm = uno.getComponentContext().ServiceManager
        mspf = sm.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory", uno.getComponentContext())
        scriptPro = mspf.createScriptProvider("")
        xScript = scriptPro.getScript("vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application")
        xScript.invoke((myObject,), (), ())
        xScript.invoke((xObject,), (), ())
        return
    except:
        raise _rtex("\nBasic library Xray is not installed", uno.getComponentContext())


def mri (ctx, xTarget):
    "MRI - API Explorer"

Modified gc_lang/fr/oxt/About/About.py from [2582b651e6] to [cd8f9ad8dc].

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84
85




86
87
88


89


90
91
92

93
94
95
96
97
98
99
100
101
102
103









104
105
106
107
108
109
110
111


112
113
114


115
116
117
118
119
120
121



122

123
124
47
48
49
50
51
52
53





54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71


72
73
74





75
76
77
78
79


80
81
82
83
84
85
86

87
88
89









90
91
92
93
94
95
96
97
98



99
100
101
102

103
104
105


106
107
108
109
110
111
112
113
114
115
116
117

118
119
120







-
-
-
-
-


















-
-
+


-
-
-
-
-
+
+
+
+

-
-
+
+

+
+


-
+


-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-




-
+
+

-
-
+
+







+
+
+
-
+


            self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
            self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))

            # xWidgets
            nLblWidth = 140
            nURLcolor = 0x4444FF

            xFD0 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
            xFD0.Height = 20
            #xFD0.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
            xFD0.Name = "Verdana"

            xFD1 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
            xFD1.Height = 10
            xFD1.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
            xFD1.Name = "Verdana"

            xFD2 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
            xFD2.Height = 10
            xFD2.Name = "Verdana"

            xFD3 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
            xFD3.Height = 12
            xFD3.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
            xFD3.Name = "Verdana"

            # logo
            xDefaultContext = self.ctx.ServiceManager.DefaultContext
            xPackageInfoProvider = xDefaultContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider")
            sExtPath = xPackageInfoProvider.getPackageLocation("French.linguistic.resources.from.Dicollecte.by.OlivierR")
            #imgLogo = self._addWidget('imgLogo', 'ImageControl', 5, 5, 50, 50, ImageURL = sExtPath+"/img/logo100.png", Border = 0, ScaleMode = 1)
            imgMainLogo = self._addWidget('imgMainLogo', 'ImageControl', 5, 5, 150, 80, ImageURL = sExtPath+"/img/logo120_text.png", Border = 0, ScaleMode = 1)
            self._addWidget('imgMainLogo', 'ImageControl', 5, 5, 150, 80, ImageURL = sExtPath+"/img/logo120_text.png", Border = 0, ScaleMode = 1)

            # Infos
            #lblTitle = self._addWidget('lblTitle', 'FixedText', 60, 5, 100, 20, Label = dUI.get('title', "#err"), Align = 0, FontDescriptor = xFD0)
            lblVersion = self._addWidget('lblVersion', 'FixedText', 5, 90, nLblWidth, 10, Label = dUI.get('version', "#err"), Align = 1, FontDescriptor = xFD2)
            lblLicense = self._addWidget('lblLicense', 'FixedText', 5, 100, nLblWidth, 10, Label = dUI.get('license', "#err"), Align = 1, FontDescriptor = xFD2)
            lblWebsite = self._addWidget('lblWebsite', 'FixedHyperlink', 5, 110, nLblWidth, 10, Label = dUI.get('website', "#err"), Align = 1, \
                                         URL="https://grammalecte.net/?from=grammalecte-lo", FontDescriptor = xFD1, TextColor = nURLcolor)
            self._addWidget('lblVersion', 'FixedText', 10, 90, nLblWidth, 10, Label = dUI.get('version', "#err"), Align = 1, FontDescriptor = xFD2)
            self._addWidget('lblLicence', 'FixedText', 10, 100, nLblWidth, 10, Label = dUI.get('license', "#err"), Align = 1, FontDescriptor = xFD2)
            self._addWidget('lblWebsite', 'FixedHyperlink', 10, 110, nLblWidth, 10, Label = dUI.get('website', "#err"), Align = 1, \
                            URL="https://grammalecte.net/?from=grammalecte-lo", FontDescriptor = xFD1, TextColor = nURLcolor)

            # Python version
            self._addWidget('lblpython', 'FixedText', 10, 125, nLblWidth, 10, Align = 1, TextColor = 0x888888, FontDescriptor = xFD2, \
            # Python
            self._addWidget('lblpython', 'FixedText', 10, 125, nLblWidth-50, 10, Align = 1, TextColor = 0x666666, FontDescriptor = xFD2, \
                            Label = dUI.get('pythonver', "#err") + "{0[0]}.{0[1]}.{0[2]}".format(sys.version_info))
            xConsoleButton = self._addWidget('console_button', 'Button', nLblWidth-30, 124, 40, 10, \
                                             Label = dUI.get('console', "#err"), FontDescriptor = xFD2, TextColor = 0x666666)

            # other
            line = self._addWidget('line', 'FixedLine', 10, 140, nLblWidth, 10)
            self._addWidget('line', 'FixedLine', 10, 140, nLblWidth, 10)

            # sponsors
            lblMsg = self._addWidget('lblMsg', 'FixedText', 10, 155, nLblWidth, 10, Label = dUI.get('message', "#err"), FontDescriptor = xFD2, Align = 1)
            lblURL1 = self._addWidget('lblURL1', 'FixedHyperlink', 10, 170, nLblWidth, 10, Label = dUI.get('sponsor', "#err"), \
                                      Align = 1, URL="http://lamouette.org/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            imgSponsor = self._addWidget('imgSponsor', 'ImageControl', 5, 180, 150, 50, ImageURL = sExtPath+"/img/LaMouette_small.png", Border = 0, ScaleMode = 1)
            lblURL2 = self._addWidget('lblURL2', 'FixedHyperlink', 10, 235, nLblWidth, 10, Label = dUI.get('sponsor2', "#err"), \
                                      Align = 1, URL="https://www.algoo.fr/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            imgSponsor2 = self._addWidget('imgSponsor2', 'ImageControl', 5, 245, 150, 50, ImageURL = sExtPath+"/img/Algoo_logo.png", Border = 0, ScaleMode = 1)
            lblURL3 = self._addWidget('lblURL3', 'FixedHyperlink', 10, 300, nLblWidth, 10, Label = dUI.get('link', "#err"), \
                                      Align = 1, URL="https://grammalecte.net/#thanks", FontDescriptor = xFD1, TextColor = nURLcolor)
            self._addWidget('lblMsg', 'FixedText', 10, 155, nLblWidth, 10, Label = dUI.get('message', "#err"), FontDescriptor = xFD2, Align = 1)
            self._addWidget('lblURL1', 'FixedHyperlink', 10, 170, nLblWidth, 10, Label = dUI.get('sponsor', "#err"), \
                            Align = 1, URL="http://lamouette.org/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            self._addWidget('imgSponsor', 'ImageControl', 5, 180, 150, 50, ImageURL = sExtPath+"/img/LaMouette_small.png", Border = 0, ScaleMode = 1)
            self._addWidget('lblURL2', 'FixedHyperlink', 10, 235, nLblWidth, 10, Label = dUI.get('sponsor2', "#err"), \
                            Align = 1, URL="https://www.algoo.fr/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            self._addWidget('imgSponsor2', 'ImageControl', 5, 245, 150, 50, ImageURL = sExtPath+"/img/Algoo_logo.png", Border = 0, ScaleMode = 1)
            self._addWidget('lblURL3', 'FixedHyperlink', 10, 300, nLblWidth, 10, Label = dUI.get('link', "#err"), \
                            Align = 1, URL="https://grammalecte.net/#thanks", FontDescriptor = xFD1, TextColor = nURLcolor)
            # button
            #button = self._addWidget('close', 'Button', self.xDialog.Width - 25, self.xDialog.Height - 20, 20, 14, \
            #                         Label = dUI.get('close', "#err"), FontDescriptor = xFD1, TextColor = 0x004400)

            # container
            self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
            self.xContainer.setModel(self.xDialog)
            #self.xContainer.getControl('close').addActionListener(self)
            self.xContainer.getControl('console_button').addActionListener(self)
            self.xContainer.getControl('console_button').setActionCommand('Console')
            self.xContainer.setVisible(False)
            toolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
            self.xContainer.createPeer(toolkit, None)
            xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
            self.xContainer.createPeer(xToolkit, None)
            self.xContainer.execute()
        except:
            traceback.print_exc()

    # XActionListener
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Console':
                helpers.start_console()
            else:
            self.xContainer.endExecute()
                self.xContainer.endExecute()
        except:
            traceback.print_exc()

Modified gc_lang/fr/oxt/About/ab_strings.py from [cb9cefc663] to [4684039c06].

9
10
11
12
13
14
15
16


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


33
34
35
36
37
38
39
40
41
9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
42
43







-
+
+















-
+
+









    "fr": {
            "windowtitle": "À propos…",
            "title": "Grammalecte",
            "version": "Version : ${version}",
            "license": "Licence : GPL 3",
            "website": "Site web",

            "pythonver": "Machine virtuelle Python : v",
            "pythonver": "Machine Python : v",
            "console": "Console",

            "message": "Avec le soutien de",
            "sponsor": "La Mouette…",
            "sponsor2": "Algoo…",
            "link": "… et de nombreux contributeurs.",

            "close": "~OK"
          },
    "en": {
            "windowtitle": "About…",
            "title": "Grammalecte",
            "version": "Version: ${version}",
            "license": "License: GPL 3",
            "website": "Web site",

            "pythonver": "Python virtual machine: v",
            "pythonver": "Python machine: v",
            "console": "Console",

            "message": "With the support of",
            "sponsor": "La Mouette…",
            "sponsor2": "Algoo…",
            "link": "… and many contributors.",

            "close": "~OK"
          }
}