[Tutor] Getting current listbox item index and bind it to button (Tkinter)

2018-08-07 Thread Ali M
If i delete this line "self.textbox.delete(1.0, tk.END)" in my enter_meaning function the listbox items won't lower down to 1 item and i just want 1 item to be shown after user searches the item in entrybox. what i want to do is: when user searches in entrybox, the listbox items lowers down to that

Re: [Tutor] Getting current listbox item index and bind it to button (Tkinter)

2018-08-07 Thread Alan Gauld via Tutor
On 06/08/18 20:50, Ali M wrote: > If i delete this line "self.textbox.delete(1.0, tk.END)" in my > enter_meaning function the listbox items won't lower down to 1 item and i > just want 1 item to be shown after user searches the item in entrybox. So just display 1 item. What you are currently doing

[Tutor] How to write a function which reads files

2018-08-07 Thread Rafael Knuth
Hi there, I got this here: file_path = "C:\\Users\\...\\MyFile.txt" # path shortened for better readability with open(file_path) as file_object: contents = file_object.read() print(contents) It works. Now I want to convert the code above into a function. This is what I wrote: def FileR

Re: [Tutor] How to write a function which reads files

2018-08-07 Thread Chris Warrick
On Tue, 7 Aug 2018 at 15:07, Rafael Knuth wrote: > def FileReader(file_path): > with open(file_path) as file_object: > contents = file_object.read > return contents > > print(FilePrinter("C:\\Users\\...\\MyFile.txt")) # path shortened for > better readability > > I got this err

Re: [Tutor] How to write a function which reads files

2018-08-07 Thread Alan Gauld via Tutor
On 07/08/18 13:46, Rafael Knuth wrote: > Now I want to convert the code above into a function. > This is what I wrote: > > def FileReader(file_path): > with open(file_path) as file_object: > contents = file_object.read > return contents > > print(FilePrinter("C:\\Users\\...\\

Re: [Tutor] How to write a function which reads files

2018-08-07 Thread Rafael Knuth
> You forgot the parentheses (), and are returning a reference to the > function instead of calling it and returning its result. Do this: > contents = file_object.read() oh, my bad. Thanks! > Also, consider using snake_case instead of PascalCase for your > function name, since the latter

[Tutor] python3 - °F/°C printing those degree signs

2018-08-07 Thread Evuraan
Greetings! How to print °F/°C etc in python3? (This works on a WSL): ~$ python3 Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.release() '4.4.0-17134-Microsoft' >

Re: [Tutor] python3 - °F/°C printing those degree signs

2018-08-07 Thread Alan Gauld via Tutor
On 07/08/18 22:32, Evuraan wrote: print('\u00b0'+ " F") > ° F > > Elsewhere, it no longer seem to work: > > $ python3 > Python 3.5.2 (default, Nov 23 2017, 16:37:01) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" for more information. import platfor

Re: [Tutor] How to write a function which reads files

2018-08-07 Thread Mats Wichmann
Question is already answered, just wanted to add a mini-note. def FileReader(file_path):with open(file_path) as file_object: contents = file_object.readreturn contents you /can/ return the read method here, which is what this typo does. And the caller of the function can use it to

Re: [Tutor] python3 - °F/°C printing those degree signs

2018-08-07 Thread Steven D'Aprano
On Tue, Aug 07, 2018 at 02:32:58PM -0700, Evuraan wrote: > Greetings! How to print °F/°C etc in python3? In Python 3, you should be able to do: print('°F/°C') directly. If you can't, your configuration is broken. If you are including this is a .py file, make sure your text editor is set

Re: [Tutor] python3 - °F/°C printing those degree signs

2018-08-07 Thread Evuraan
> > You could try setting > > PYTHONIOENCODING="UTF-8" > > in your OS shell and see if that helps, but I suspect > there's a better way to deal with it... > Thank you! That was it! Exporting thusly made it behave: $ export PYTHONIOENCODING="UTF-8" $ python3 Python 3.5.2 (default, Nov 23 2017, 16