Sign in:

read us on

Мониторинг в Python проекте

Аннотации во благо

Новое в Python 3.7

Sending email with EZGmail and Python

Have you ever wanted to send an email with GMail using the Python programming language? In 2018, Al Sweigart, best-selling author of Automate the Boring Stuff with Python, created a package called EZGmail. You can also use Google’s own bindings to do this sort of thing, but it’s a lot more complicated than using EZGmail. In this article, we will take a quick look at how to use this package. Setting Up Your first step is to install EZGmail using pip. Here’s how: pip install ezgmail Then go to and click the Enable the Gmail API button. This will allow you to download a credentials.json file and also give you a client ID and client secret. You can use the latter credentials with Google’s Python API client and you can manage these credentials here if you need to. Now copy the credentials file to the location that you plan on writing your code. You will then need to run Python in your terminal in the same location that your downloaded credentials file is located. The next step is to run ezgmail.init(). This will open up a web browser to Gmail where it will ask you to allow access to your application. If you grant access, EZGmail will download a tokens file so that it doesn’t need to have you reauthorize it every time you use it. To verify everything is working correctly, you can run the following code: >>> ezgmail.EMAIL_ADDRESS '' This should cause your Gmail account name to print out. Continue reading Sending email with EZGmail and Python →

Getting the Correct Notebook Tab Across Platforms in wxPython

I was recently working on a GUI application that had a wx.Notebook in it. When the user changed tabs in the notebook, I wanted the application to do an update based on the newly shown (i.e. selected) tab. I quickly discovered that while it is easy to catch the tab change event, getting the right tab is not as obvious. This article will walk you through my mistake and show you two solutions to the issue. Here is an example of what I did originally: #   import random import wx     class TabPanel(wx.Panel):   def __init__(self, parent, name): """""" super().__init__(parent=parent) = name   colors = ["red", "blue", "gray", "yellow", "green"] self.SetBackgroundColour(random.choice(colors))   btn = wx.Button(self, label="Press Me") sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(btn, 0, wx.ALL, 10) self.SetSizer(sizer)     class DemoFrame(wx.Frame): """ Frame that holds all other widgets """     def __init__(self): """Constructor""" super().__init__(None, wx.ID_ANY, "Notebook Tutorial", size=(600,400) ) panel = wx.Panel(self)   self.notebook = wx.Notebook(panel) self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_tab_change) tabOne = TabPanel(self.notebook, name='Tab 1') self.notebook.AddPage(tabOne, "Tab 1")   tabTwo = TabPanel(self.notebook, name='Tab 2') self.notebook.AddPage(tabTwo, "Tab 2")   sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 5) panel.SetSizer(sizer) self.Layout()   self.Show()   def on_tab_change(self, event): # Works on Windows and Linux, but not Mac current_page = self.notebook.GetCurrentPage() print( event.Skip()     if __name__ == "__main__": app = wx.App(False) frame = DemoFrame() app.MainLoop() Continue reading Getting the Correct Notebook Tab Across Platforms in wxPython →

Book Review: Practical Python and OpenCV

I bought Practical Python and OpenCV a couple of years ago during one of its authors Kickstarters. I started reading it and then got busy with other things. The past couple of weeks, I decided to give the book another go and was able to finish it. Note that I started reading the 3rd edition of the book without realizing there was a 4th edition. After finished the 3rd edition, I compared it to the 4th side by side and it looks like they are nearly identical, so I don’t think it matters all that much. Quick Review Why I picked it up: Computer vision / machine learning sounds interesting to me and the author has a fun blog Why I finished it: It’s short and the writing style is engaging I’d give it to: Anyone looking to get started with OpenCV in Python Continue reading Book Review: Practical Python and OpenCV →


Fresh Tutorials on Full Stack Python

There are a bunch of new tutorials on Full Stack Python that were written since the last time I sent out an email newsletter. These range from getting started with some popular open source projects to integrating third party APIs to... (read more)


Adding Okta Authentication to an Existing Flask Web App

It can be a lot of work to piece together a full authentication system if you have an existing Flask web application that you are coding. Okta makes it much easier to drop-in a complete user authentication system without a lot of additional effort. In this tutorial we... (read more)


Introduction to Ansible video course released!

Check out the just-launched video course, Introduction to Ansible on Talk Python Training. This is the perfect course for you if you want to learn to configure servers and deploy web apps... (read more)