<commit_before>from shared.card import CARD_PLACEHOLDER_LENGTH

import wx

class CurrCardWindow(wx.Panel):
  def __init__(self, parent):
    wx.Panel.__init__(self, parent=parent,
                      name="current card panel(this is a name)")

    self.SetLabel("current card panel(this is a label)")
    self.SetBackgroundColour("white")


    self.current_card_panel = wx.Panel(parent=self, size=(200, 200),
                                       name="current card (name)",
                                       style=wx.SIMPLE_BORDER)
    self.current_card_panel.SetLabel("current card (label)")
    self.current_card_panel.SetBackgroundColour("black")
    self.current_card_text = wx.TextCtrl(parent=self.current_card_panel, id=-1,
                                         size=(150, 150),
                                         style=wx.TE_MULTILINE,
                                         name="text control for current card")
    self.current_card_text.SetBackgroundColour(
      self.current_card_panel.GetBackgroundColour())
    self.current_card_text.SetForegroundColour("white")
    self.current_card_text.CenterOnParent()


    self.radio_black = wx.RadioButton(self, label="black card", )
    self.radio_black.SetValue(True)
    self.radio_black.Bind(wx.EVT_RADIOBUTTON, self.SetColors)
    self.radio_white = wx.RadioButton(self, label="white card")
    self.radio_white.Bind(wx.EVT_RADIOBUTTON, self.SetColors)


    self.button_del_text = wx.Button(self, label="delete text")
    self.button_del_text.Bind(wx.EVT_BUTTON, self.DeleteCardText)
    self.button_del_card = wx.Button(self, label="delete card")
    #self.button_del_card.Bind(wx.EVT_BUTTON, self.DeleteCard)
    self.button_save_card = wx.Button(self, label="save card")
    self.button_save_card.Bind(wx.EVT_BUTTON, self.SaveCard)
    self.button_ins_ph = wx.Button(self, label="insert placeholder")
    self.button_ins_ph.Bind(wx.EVT_BUTTON, self.InsertPlaceholder)


    self.box = wx.BoxSizer(wx.VERTICAL)

    self.box.Add(self.radio_black)
    self.box.Add(self.radio_white)

    self.box.AddStretchSpacer(1)
    self.box.Add(self.current_card_panel, 0, wx.ALIGN_CENTER)
    self.box.AddStretchSpacer(1)

    self.hbox = wx.BoxSizer()
    self.grid = wx.GridBagSizer()
    self.grid.Add(self.button_del_text, (0, 0))
    self.grid.Add(self.button_ins_ph, (0, 2), flag=wx.ALIGN_RIGHT)
    self.grid.Add(self.button_del_card, (1, 0))
    self.grid.Add(self.button_save_card, (1, 2), flag=wx.ALIGN_RIGHT)
    self.grid.AddGrowableCol(1)

    self.hbox.Add(self.grid, 1, wx.EXPAND)
    self.box.Add(self.hbox, 0, wx.EXPAND)
    self.SetSizer(self.box)


  def SetColors(self, event):
    if self.radio_black.GetValue():
      self.current_card_panel.SetBackgroundColour("black")
      self.current_card_text.SetBackgroundColour("black")
      self.current_card_text.SetForegroundColour("white")
      self.button_ins_ph.Enable()
    else:
      self.current_card_panel.SetBackgroundColour("white")
      self.current_card_text.SetBackgroundColour("white")
      self.current_card_text.SetForegroundColour("black")
      self.button_ins_ph.Disable()

    self.Refresh()


  def DeleteCardText(self, event):
    self.current_card_text.SetValue('')

  #def DeleteCard(self, event):


  def SaveCard(self, event):
    # get value of textctrl with
    string = self.current_card_text.GetValue()
    # get value of radiobuttons with
    #bool = self.radio_black.GetValue() and
    #bool = self.radio_black.GetValue()

  def InsertPlaceholder(self, event):
    current_text = self.current_card_text.GetValue()
    current_position = self.current_card_text.GetInsertionPoint()
    current_text = current_text[:current_position]+"_"*CARD_PLACEHOLDER_LENGTH+current_text[current_position:]
    self.current_card_text.SetValue(current_text)
    self.current_card_text.SetInsertionPoint(current_position+CARD_PLACEHOLDER_LENGTH)<commit_msg>insert placeholder: automatically move focus to text control after pressing the button<commit_after>from shared.card import CARD_PLACEHOLDER_LENGTH

import wx

class CurrCardWindow(wx.Panel):
  def __init__(self, parent):
    wx.Panel.__init__(self, parent=parent,
                      name="current card panel(this is a name)")

    self.SetLabel("current card panel(this is a label)")
    self.SetBackgroundColour("white")


    self.current_card_panel = wx.Panel(parent=self, size=(200, 200),
                                       name="current card (name)",
                                       style=wx.SIMPLE_BORDER)
    self.current_card_panel.SetLabel("current card (label)")
    self.current_card_panel.SetBackgroundColour("black")
    self.current_card_text = wx.TextCtrl(parent=self.current_card_panel, id=-1,
                                         size=(150, 150),
                                         style=wx.TE_MULTILINE,
                                         name="text control for current card")
    self.current_card_text.SetBackgroundColour(
      self.current_card_panel.GetBackgroundColour())
    self.current_card_text.SetForegroundColour("white")
    self.current_card_text.CenterOnParent()


    self.radio_black = wx.RadioButton(self, label="black card", )
    self.radio_black.SetValue(True)
    self.radio_black.Bind(wx.EVT_RADIOBUTTON, self.SetColors)
    self.radio_white = wx.RadioButton(self, label="white card")
    self.radio_white.Bind(wx.EVT_RADIOBUTTON, self.SetColors)


    self.button_del_text = wx.Button(self, label="delete text")
    self.button_del_text.Bind(wx.EVT_BUTTON, self.DeleteCardText)
    self.button_del_card = wx.Button(self, label="delete card")
    #self.button_del_card.Bind(wx.EVT_BUTTON, self.DeleteCard)
    self.button_save_card = wx.Button(self, label="save card")
    self.button_save_card.Bind(wx.EVT_BUTTON, self.SaveCard)
    self.button_ins_ph = wx.Button(self, label="insert placeholder")
    self.button_ins_ph.Bind(wx.EVT_BUTTON, self.InsertPlaceholder)


    self.box = wx.BoxSizer(wx.VERTICAL)

    self.box.Add(self.radio_black)
    self.box.Add(self.radio_white)

    self.box.AddStretchSpacer(1)
    self.box.Add(self.current_card_panel, 0, wx.ALIGN_CENTER)
    self.box.AddStretchSpacer(1)

    self.hbox = wx.BoxSizer()
    self.grid = wx.GridBagSizer()
    self.grid.Add(self.button_del_text, (0, 0))
    self.grid.Add(self.button_ins_ph, (0, 2), flag=wx.ALIGN_RIGHT)
    self.grid.Add(self.button_del_card, (1, 0))
    self.grid.Add(self.button_save_card, (1, 2), flag=wx.ALIGN_RIGHT)
    self.grid.AddGrowableCol(1)

    self.hbox.Add(self.grid, 1, wx.EXPAND)
    self.box.Add(self.hbox, 0, wx.EXPAND)
    self.SetSizer(self.box)


  def SetColors(self, event):
    if self.radio_black.GetValue():
      self.current_card_panel.SetBackgroundColour("black")
      self.current_card_text.SetBackgroundColour("black")
      self.current_card_text.SetForegroundColour("white")
      self.button_ins_ph.Enable()
    else:
      self.current_card_panel.SetBackgroundColour("white")
      self.current_card_text.SetBackgroundColour("white")
      self.current_card_text.SetForegroundColour("black")
      self.button_ins_ph.Disable()

    self.Refresh()


  def DeleteCardText(self, event):
    self.current_card_text.SetValue('')

  #def DeleteCard(self, event):


  def SaveCard(self, event):
    # get value of textctrl with
    string = self.current_card_text.GetValue()
    # get value of radiobuttons with
    #bool = self.radio_black.GetValue() and
    #bool = self.radio_black.GetValue()

  def InsertPlaceholder(self, event):
    current_text = self.current_card_text.GetValue()
    current_position = self.current_card_text.GetInsertionPoint()
    current_text = current_text[:current_position]+"_"*CARD_PLACEHOLDER_LENGTH+current_text[current_position:]
    self.current_card_text.SetValue(current_text)
    self.current_card_text.SetInsertionPoint(current_position+CARD_PLACEHOLDER_LENGTH)
    self.current_card_text.SetFocus()
{'fraction_non_alphanumeric': 0.11396549552953028, 'fraction_numerical': 0.00680015111446921, 'mean_word_length': 3.5253561253561254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3790098', 'n_tokens_mistral': 2682, 'n_tokens_neox': 2604, 'n_words': 367}