Created
December 31, 2019 01:17
-
-
Save glof2/8fa6a96b8591202bf2be2493c73d0dad to your computer and use it in GitHub Desktop.
Text character replacer with gui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kivy | |
from kivy.app import App | |
from kivy.uix.label import Label | |
from kivy.uix.gridlayout import GridLayout | |
from kivy.uix.textinput import TextInput | |
from kivy.uix.button import Button | |
from kivy.config import Config | |
Config.set('input', 'mouse', 'mouse,multitouch_on_demand') | |
#GUI | |
class MyGridLayout(GridLayout): | |
def __init__(self, **kwargs): | |
super(MyGridLayout, self).__init__(**kwargs) | |
self.textinputs = GridLayout() | |
self.textinputs.cols = 3 | |
self.cols = 1 | |
self.text_ = TextInput(text = "Text") | |
self.textinputs.add_widget(self.text_) | |
self.toremove = TextInput(text = "What to replace") | |
self.textinputs.add_widget(self.toremove) | |
self.replace = TextInput(text = "What to replace with") | |
self.textinputs.add_widget(self.replace) | |
self.add_widget(self.textinputs) | |
self.output = TextInput(text = "Output") | |
self.add_widget(self.output) | |
self.confirm = Button(text = "Confirm", font_size = 40) | |
self.confirm.bind(on_press=self.pressed) | |
self.add_widget(self.confirm) | |
#On button press | |
def pressed(self, instance): | |
outputtxt = self.output | |
replacewith = self.replace | |
txt = self.text_ | |
toreplace = self.toremove | |
outputtxt.text = txt.text.replace(toreplace.text, replacewith.text) | |
# | |
class Replacer(App): | |
def build(self): | |
self.icon = "icon.png" | |
return MyGridLayout() | |
# | |
if __name__ == "__main__": | |
Replacer().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment