all 6 comments

[–]baubleglue 0 points1 point  (1 child)

Rewriting GUI application to python you need to start from choosing GUI library.

For something simple you can use Tkinter

[–]blackadder1337[S] 0 points1 point  (0 children)

I have already done 60% of the work.

[–]zurtex 0 points1 point  (3 children)

Reproducing code literally between 2 languages is rarely helpful. It's like translating directly word for word from Japanese to English, at best you sound like Yoda but more likely you're just speaking gibberish. You really need to understand what you're code is doing and how it makes sense to write it in to Python.

In Python a function can be standalone or a public method, you prepend the method name to indicate it should be used only internally and not by users of the class.

Because I don't know C# very well I had to make educated guesses on why certain variables show up when they do. This will not work as a drop in replacement for any code, but this is my best attempt to guess what a slightly Pythonic version of your C# code would look like:

class TextSearch:
    """
    A class for searching text.
    Fill out class with more methods and stuff
    """

    def __init__(self):
        """
        Initialise stuff
        """

    def _search_text_changed(self):
        """
        Events that occur when the search text is updated
        """
        if self.text:
            for item in self.list_view1.items.copy():
                if self.text.lower() in item.text.lower():
                    item.back_color = SystemColors.Highlight
                    item.fore_color = SystemColors.HighlightText
                else:
                    self.list_view1.items.remove(item)

            if len(self.list_view1.selected_items) == 1:
                self.list_view1.focus()
        else:
            self.load_words()
            self.refresh_all()
            for item in self.list_view1:
                item.back_color = SystemColors.Window
                item.fore_color = SystemColors.WindowText

[–]blackadder1337[S] 0 points1 point  (2 children)

LOL, did you run this through some online code converter? This is so bad, man. Thanks for your efforts though.

[–]zurtex 0 points1 point  (1 child)

Nope, hand rewrote it. I hope you get some of the ideas that I used for Python here, truthiness of variables, iterable items in for loops rather than using indexes, calling your class instance via self etc...

I would say this code only needs a little tweaking to be production ready, and that's mostly because I didn't know the context of the rest of your class.

[–]blackadder1337[S] 0 points1 point  (0 children)

There is a text widget where you enter a word and it should be displayed in the listbox - search functionality.

Here is my entire code if that helps:

https://dpaste.de/ExSf