Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror text in the rich text control #1708

Open
1kamma opened this issue Jul 2, 2020 · 6 comments
Open

Mirror text in the rich text control #1708

1kamma opened this issue Jul 2, 2020 · 6 comments

Comments

@1kamma
Copy link

1kamma commented Jul 2, 2020

hello. when I use richtextctrl, the text is mirrored, in English and hebrew.
when I use textctrl however, everything is just fine.
I checked if the problem is just in my code, or it is in every wxpython code, (like wxFormBuilder), and the problem is global with this specific widget

Windows 10 2004
wxPython 4.1.0 & pip 20.1.1
python 3.8.3

Description of the problem:

class main_panel(wx.Panel):
    def __init__(self, parent):
        super().__init__(parent)
        # self.Sizer = wx.BoxSizer()
        self.Font = wx.Font( 16, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "SBL BibLit" )
        self.text = rch.RichTextCtrl(self)
        # self.text.Bind(wx.EVT_LEFT_DOWN,self.pr)
        self.text.SetFont(self.Font)

        # self.tex
        self.Sizer = wx.GridSizer(1 , 0 , 0)
        self.Sizer.Add(self.text, flag = wx.EXPAND | wx.SIZE_AUTO)
        # self.text.Size = wx.Size(1800,60)
        # self.text.Size = wx.Size(800,600)
        # self.text.SetFont(self.Font)
        # self.Sizer.Add(self.text, flag = 1 | wx.EXPAND |wx.SIZE_AUTO|wx.SIZE_AUTO_WIDTH)

image

@swt2c
Copy link
Collaborator

swt2c commented Jul 7, 2020

Hi, can you please provide a complete runnable example code that demonstrates the problem?

@1kamma
Copy link
Author

1kamma commented Jul 8, 2020

full code:

import wx.lib.buttons as btn
import wx.richtext as rch

books = {'בראשית': 'Genesis', 'שמות': 'Exodus', 'ויקרא': 'Leviticus', 'במדבר': 'Numbers', 'דברים': 'Deuteronomy', 'יהושע': 'Joshua', 'שופטים': 'Judges', 'שמואל א': '1 Samuel', 'שמואל ב': '2 Samuel', 'מלכים א': '1 Kings', 'מלכים ב': '2 Kings', 'ישעיהו': 'Isaiah', 'ירמיהו': 'Jeremiah', 'יחזקאל': 'Ezekiel', 'תרי עשר' : '12 Minor' , 'תהילים': 'Psalms', 'משלי': 'Proverbs', 'איוב': 'Job', 'שיר השירים': 'Song of songs', 'רות': 'Ruth', 'איכה': 'Lamentations', 'קהלת': 'Ecclesiastes', 'אסתר': 'Esther', 'דניאל': 'Daniel', 'עזרא': 'Ezra', 'ונחמיה': 'Nehemiah', 'דברי הימים א': '1 Chronicles', 'דברי הימים ב': '2 Chronicles'}
twelve_minor_prophets = {'הושע': 'Hosea', 'יואל': 'Joel', 'עמוס': 'Amos', 'עובדיה': 'Obadiah', 'יונה': 'Jonah', 'מיכה': 'Micah', 'נחום': 'Nahum', 'חבקוק': 'Habakkuk', 'צפניה': 'Zephaniah', 'חגי': 'Haggai', 'זכריה': 'Zechariah', 'מלאכי': 'Malachi'}
# class font(wx.Font):
#     def __init__(self, pointSize, family, style, faceName):
#         super().__init__(pointSize=pointSize, family = family, style = style, faceName = faceName)

class book_panel(wx.Panel):
    def __init__(self, parent):
        super().__init__(parent)
        self.Sizer = wx.BoxSizer(wx.VERTICAL)
        global books
        for b in books:
            self.Sizer.Add(btn.GenToggleButton(self,label = b ,style = wx.SIZE_AUTO | wx.EXPAND),flag = wx.EXPAND)
        self.Sizer.Layout()
        self.Bind(wx.EVT_BUTTON,self.choose_chap)
    
    def choose_chap(self, event: wx.Event):
        for b in self.Sizer.GetChildren():
            if b.GetWindow().GetValue() and b.GetWindow().Label != event.GetEventObject().Label:
                b.GetWindow().SetValue(False)
        print(event.GetEventObject().Label)

class main_panel(wx.Panel):
    def __init__(self, parent):
        super().__init__(parent)
        # self.Sizer = wx.BoxSizer()
        self.Font = wx.Font( 16, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "SBL BibLit" )
        self.text = rch.RichTextCtrl(self)
        # self.text.Bind(wx.EVT_LEFT_DOWN,self.pr)
        self.text.SetFont(self.Font)

        # self.tex
        self.Sizer = wx.GridSizer(1 , 0 , 0)
        self.Sizer.Add(self.text, flag = wx.EXPAND | wx.SIZE_AUTO)
        # self.text.Size = wx.Size(1800,60)
        # self.text.Size = wx.Size(800,600)
        # self.text.SetFont(self.Font)
        # self.Sizer.Add(self.text, flag = 1 | wx.EXPAND |wx.SIZE_AUTO|wx.SIZE_AUTO_WIDTH)
    
    def pr(self, event: wx.Event):
        print(event.EventObject.GetStyle())
    
class main_frame(wx.Frame):
    def __init__(self, parent, title = ""):
        super().__init__(parent,title = title)
        self.MinSize = wx.Size(800,600)
        self.MenuBar = wx.MenuBar()
        self.MenuBar.Label = "תפריט טקסטים"
        self.menu_tanakh = wx.Menu("מקרא")
        self.MenuBar.Append(self.menu_tanakh,"מקרא")
        self.Sizer = wx.FlexGridSizer(2,2,wx.Size(5,5))
        self.Sizer.AddSpacer(-5)
        self.choise = wx.RadioBox(self,choices = ["Consonants","Vowels","Accents","Morphology"] , label = "Biblical Options", style = wx.ALIGN_RIGHT)
        self.choise.Selection = 2
        self.Sizer.Add(self.choise)
        self.books = book_panel(self)
        self.Sizer.AddGrowableRow(1)
        self.Sizer.AddGrowableCol(1)
        self.Sizer.Add(self.books , flag = wx.EXPAND | wx.SIZE_AUTO)
        self.main_text = main_panel(self)
        self.Sizer.Add(self.main_text , flag = wx.EXPAND)
        self.Sizer.Fit(self)
        
 
        
        
class main_app(wx.App):
    def OnInit(self):
        self.frame = main_frame(None,"בורר טקסטים")
        self.frame.Show()
        return True
    
if __name__ == "__main__":
    app = main_app()
    app.MainLoop()```

@swt2c
Copy link
Collaborator

swt2c commented Jul 8, 2020

Is there anything particular I need to do in order to cause the problem to occur using the sample? I don't think that I'm seeing the problem (yet?):
Screenshot from 2020-07-08 10-26-57

@1kamma
Copy link
Author

1kamma commented Jul 9, 2020

In my computer (which is in windows 10 2004 in Hebrew) the problem occurs. I don't know why in ubuntu is not
I also checked in w10 1803, and it still mirrors the text

@swt2c
Copy link
Collaborator

swt2c commented Jul 9, 2020

So your system language is set to Hebrew?

@1kamma
Copy link
Author

1kamma commented Jul 10, 2020

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants